Esempio n. 1
0
    @Override
    public void onRunAnimation() {
      final MapView mapview = MapController.this.mOsmv;
      final IGeoPoint mapCenter = mapview.getMapCenter();
      final int stepDuration = this.mStepDuration;
      try {
        int newMapCenterLatE6;
        int newMapCenterLonE6;

        for (int i = 0; i < this.mSmoothness; i++) {

          final double delta = Math.pow(0.5, i + 1);
          final int deltaLatitudeE6 = (int) (this.mPanTotalLatitudeE6 * delta);
          final int detlaLongitudeE6 = (int) (this.mPanTotalLongitudeE6 * delta);

          newMapCenterLatE6 = mapCenter.getLatitudeE6() - deltaLatitudeE6;
          newMapCenterLonE6 = mapCenter.getLongitudeE6() - detlaLongitudeE6;
          mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6);

          Thread.sleep(stepDuration);
        }
        mapview.setMapCenter(super.mTargetLatitudeE6, super.mTargetLongitudeE6);
      } catch (final Exception e) {
        this.interrupt();
      }
    }
Esempio n. 2
0
    @Override
    public void onRunAnimation() {
      final MapView mapview = MapController.this.mOsmv;
      final IGeoPoint mapCenter = mapview.getMapCenter();
      final int stepDuration = this.mStepDuration;
      final float amountStretch = this.mAmountStretch;
      try {
        int newMapCenterLatE6;
        int newMapCenterLonE6;

        for (int i = 0; i < this.mSmoothness; i++) {

          final double delta =
              (this.mYOffset + Math.cos(this.mStepIncrement * i + this.mStart)) * amountStretch;
          final int deltaLatitudeE6 = (int) (this.mPanTotalLatitudeE6 * delta);
          final int deltaLongitudeE6 = (int) (this.mPanTotalLongitudeE6 * delta);

          newMapCenterLatE6 = mapCenter.getLatitudeE6() - deltaLatitudeE6;
          newMapCenterLonE6 = mapCenter.getLongitudeE6() - deltaLongitudeE6;
          mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6);

          Thread.sleep(stepDuration);
        }
        mapview.setMapCenter(super.mTargetLatitudeE6, super.mTargetLongitudeE6);
      } catch (final Exception e) {
        this.interrupt();
      }
    }
Esempio n. 3
0
  private void saveState() {
    IGeoPoint point = map.getMapCenter();

    storage.writeInteger(solidKey + LONGITUDE_SUFFIX, point.getLongitudeE6());
    storage.writeInteger(solidKey + LATITUDE_SUFFIX, point.getLatitudeE6());
    storage.writeInteger(solidKey + ZOOM_SUFFIX, map.getZoomLevel());
  }
  private boolean onUp(MotionEvent event, MapView mapView) {
    if (this.onTargetClickListener != null && this.isAClick) {
      this.clickUpCoords[0] = event.getX();
      this.clickUpCoords[1] = event.getY();

      if (Math.abs(this.clickUpCoords[0] - this.clickDownCoords[0]) < 10
          && Math.abs(this.clickUpCoords[1] - this.clickDownCoords[1]) < 10) {
        IGeoPoint igeoPoint =
            mapView.getProjection().fromPixels((int) event.getX(), (int) event.getY());
        GeoPoint geoPoint = new GeoPoint(igeoPoint.getLatitudeE6(), igeoPoint.getLongitudeE6());
        if (event.getEventTime() - this.clickDownTime
                < android.view.ViewConfiguration.getLongPressTimeout()
            && isEventOnTarget(event, mapView)) {
          this.lockPosition = true;
          this.onTargetClickListener.onClick(getMyLocation());
          return true;
        } else if (this.lockPosition == false
            && event.getEventTime() - this.clickDownTime
                >= 0) { // android.view.ViewConfiguration.getP) {
          setLocation(geoPoint);
          mapView.invalidate();
          return true;
        }
      }
      this.isAClick = false;
    }
    return false;
  }
Esempio n. 5
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   IGeoPoint point = mOverlay.getGeoPoint();
   outState.putInt(MapsConstants.EXTRA_LATITUDE, point.getLatitudeE6());
   outState.putInt(MapsConstants.EXTRA_LONGITUDE, point.getLongitudeE6());
 }
Esempio n. 6
0
 /** Set the map views to the given center. There will be no animation. */
 @Override
 public void setCenter(final IGeoPoint point) {
   final Point p =
       TileSystem.LatLongToPixelXY(
           point.getLatitudeE6() / 1E6,
           point.getLongitudeE6() / 1E6,
           this.mOsmv.getZoomLevel(),
           null);
   final int worldSize_2 = TileSystem.MapSize(this.mOsmv.getZoomLevel()) / 2;
   this.mOsmv.scrollTo(p.x - worldSize_2, p.y - worldSize_2);
 }
Esempio n. 7
0
  /** Save map's zoom level and centre. You should not need to touch this method */
  @Override
  public void onSaveInstanceState(Bundle outState) {
    Log.d(LOG_TAG, "onSaveInstanceState");
    super.onSaveInstanceState(outState);

    if (mapView != null) {
      outState.putInt("zoomLevel", mapView.getZoomLevel());
      IGeoPoint cntr = mapView.getMapCenter();
      outState.putInt("latE6", cntr.getLatitudeE6());
      outState.putInt("lonE6", cntr.getLongitudeE6());
      Log.i("MapSave", "Zoom: " + mapView.getZoomLevel());
    }
  }
Esempio n. 8
0
    public LinearAnimationRunner(
        final int aTargetLatitudeE6,
        final int aTargetLongitudeE6,
        final int aSmoothness,
        final int aDuration) {
      super(aTargetLatitudeE6, aTargetLongitudeE6, aSmoothness, aDuration);

      /* Get the current mapview-center. */
      final MapView mapview = MapController.this.mOsmv;
      final IGeoPoint mapCenter = mapview.getMapCenter();

      this.mPanPerStepLatitudeE6 = (mapCenter.getLatitudeE6() - aTargetLatitudeE6) / aSmoothness;
      this.mPanPerStepLongitudeE6 = (mapCenter.getLongitudeE6() - aTargetLongitudeE6) / aSmoothness;

      this.setName("LinearAnimationRunner");
    }
Esempio n. 9
0
    public AbstractAnimationRunner(
        final int aTargetLatitudeE6,
        final int aTargetLongitudeE6,
        final int aSmoothness,
        final int aDuration) {
      this.mTargetLatitudeE6 = aTargetLatitudeE6;
      this.mTargetLongitudeE6 = aTargetLongitudeE6;
      this.mSmoothness = aSmoothness;
      this.mStepDuration = aDuration / aSmoothness;

      /* Get the current mapview-center. */
      final MapView mapview = MapController.this.mOsmv;
      final IGeoPoint mapCenter = mapview.getMapCenter();

      this.mPanTotalLatitudeE6 = mapCenter.getLatitudeE6() - aTargetLatitudeE6;
      this.mPanTotalLongitudeE6 = mapCenter.getLongitudeE6() - aTargetLongitudeE6;
    }
Esempio n. 10
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   final int id = item.getItemId();
   if (id == R.id.maps__menu_accept) {
     IGeoPoint point = mOverlay.getGeoPoint();
     Location location = new Location("medesmapprovider");
     location.setLatitude(point.getLatitudeE6() / (double) 1E6);
     location.setLongitude(point.getLongitudeE6() / (double) 1E6);
     setResult(RESULT_OK, new Intent().putExtra(MapsConstants.EXTRA_LOCATION, location));
     finish();
     return true;
   } else if (id == R.id.maps__menu_map) {
     showDialog(DIALOG_MAPMODE_ID);
     return true;
   } else if (id == R.id.maps__menu_place) {
     changeMyLocationState();
     return true;
   }
   return super.onOptionsItemSelected(item);
 }
Esempio n. 11
0
    @Override
    public void onRunAnimation() {
      final MapView mapview = MapController.this.mOsmv;
      final IGeoPoint mapCenter = mapview.getMapCenter();
      final int panPerStepLatitudeE6 = this.mPanPerStepLatitudeE6;
      final int panPerStepLongitudeE6 = this.mPanPerStepLongitudeE6;
      final int stepDuration = this.mStepDuration;
      try {
        int newMapCenterLatE6;
        int newMapCenterLonE6;

        for (int i = this.mSmoothness; i > 0; i--) {

          newMapCenterLatE6 = mapCenter.getLatitudeE6() - panPerStepLatitudeE6;
          newMapCenterLonE6 = mapCenter.getLongitudeE6() - panPerStepLongitudeE6;
          mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6);

          Thread.sleep(stepDuration);
        }
      } catch (final Exception e) {
        this.interrupt();
      }
    }
Esempio n. 12
0
 public CircleGeofence setCenter(IGeoPoint center) {
   this.latitudeE6 = center.getLatitudeE6();
   this.longitudeE6 = center.getLongitudeE6();
   this.cachedGeoPoint = center;
   return this;
 }
Esempio n. 13
0
 /** Start animating the map towards the given point. */
 @Override
 public void animateTo(final IGeoPoint point) {
   animateTo(point.getLatitudeE6() / 1E6, point.getLongitudeE6() / 1E6);
 }