@Override public void onRunAnimation() { final OpenStreetMapView mapview = OpenStreetMapViewController.this.mOsmv; 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 = mapview.getMapCenterLatitudeE6() - deltaLatitudeE6; newMapCenterLonE6 = mapview.getMapCenterLongitudeE6() - detlaLongitudeE6; mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6); Thread.sleep(stepDuration); } mapview.setMapCenter(super.mTargetLatitudeE6, super.mTargetLongitudeE6); } catch (Exception e) { this.interrupt(); } }
@Override public void onRunAnimation() { final OpenStreetMapView mapview = OpenStreetMapViewController.this.mOsmv; 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 = mapview.getMapCenterLatitudeE6() - deltaLatitudeE6; newMapCenterLonE6 = mapview.getMapCenterLongitudeE6() - deltaLongitudeE6; mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6); Thread.sleep(stepDuration); } mapview.setMapCenter(super.mTargetLatitudeE6, super.mTargetLongitudeE6); } catch (Exception e) { this.interrupt(); } }
/** Start animating the map towards the given point. */ public void animateTo(final GeoPoint point) { final int x = mOsmv.getScrollX(); final int y = mOsmv.getScrollY(); final Point p = Mercator.projectGeoPoint(point, this.mOsmv.getPixelZoomLevel(), null); final int worldSize_2 = this.mOsmv.getWorldSizePx() / 2; mOsmv.mScroller.startScroll( x, y, p.x - worldSize_2 - x, p.y - worldSize_2 - y, ANIMATION_DURATION_DEFAULT); mOsmv.postInvalidate(); }
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 OpenStreetMapView mapview = OpenStreetMapViewController.this.mOsmv; int mapCenterLatE6 = mapview.getMapCenterLatitudeE6(); int mapCenterLonE6 = mapview.getMapCenterLongitudeE6(); this.mPanPerStepLatitudeE6 = (mapCenterLatE6 - aTargetLatitudeE6) / aSmoothness; this.mPanPerStepLongitudeE6 = (mapCenterLonE6 - aTargetLongitudeE6) / aSmoothness; this.setName("LinearAnimationRunner"); }
public AbstractAnimationRunner( final int aTargetLatitudeE6, final int aTargetLongitudeE6, final int aSmoothness, final int aDuration) { this.mTargetLatitudeE6 = aTargetLatitudeE6; this.mTargetLongitudeE6 = aTargetLongitudeE6; this.mSmoothness = aSmoothness; this.mDuration = aDuration; this.mStepDuration = aDuration / aSmoothness; /* Get the current mapview-center. */ final OpenStreetMapView mapview = OpenStreetMapViewController.this.mOsmv; int mapCenterLatE6 = mapview.getMapCenterLatitudeE6(); int mapCenterLonE6 = mapview.getMapCenterLongitudeE6(); this.mPanTotalLatitudeE6 = (mapCenterLatE6 - aTargetLatitudeE6); this.mPanTotalLongitudeE6 = (mapCenterLonE6 - aTargetLongitudeE6); }
@Override public void onRunAnimation() { final OpenStreetMapView mapview = OpenStreetMapViewController.this.mOsmv; 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 = mapview.getMapCenterLatitudeE6() - panPerStepLatitudeE6; newMapCenterLonE6 = mapview.getMapCenterLongitudeE6() - panPerStepLongitudeE6; mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6); Thread.sleep(stepDuration); } } catch (Exception e) { this.interrupt(); } }
/** Zoom out by one zoom level. */ public boolean zoomOut() { mZoomLevel--; final Scaler scaler = mOsmv.mScaler; if (scaler.isFinished()) { scaler.startScale(1.0f, 0.5f, ANIMATION_DURATION_SHORT); mOsmv.postInvalidate(); } else { scaler.extendDuration(ANIMATION_DURATION_SHORT); scaler.setFinalScale(scaler.getFinalScale() * 0.5f); } return true; }
/** Zoom in by one zoom level. */ public boolean zoomIn() { // final String nextBelowMaptileUrlString = this.mRendererInfo.getTileURLString(Mercator // .getMapTileFromCoordinates(this.mLatitudeE6, this.mLongitudeE6, this.mZoomLevel + 1, // null), this.mZoomLevel + 1); // this.mTileProvider.preCacheTile(nextBelowMaptileUrlString); mZoomLevel++; final Scaler scaler = mOsmv.mScaler; if (scaler.isFinished()) { scaler.startScale(1.0f, 2.0f, ANIMATION_DURATION_SHORT); mOsmv.postInvalidate(); } else { scaler.extendDuration(ANIMATION_DURATION_SHORT); scaler.setFinalScale(scaler.getFinalScale() * 2.0f); } return true; }
void onScalingFinished() { mOsmv.setZoomLevel(mZoomLevel); }
public int setZoom(int zoomlevel) { this.mZoomLevel = zoomlevel; return mOsmv.setZoomLevel(zoomlevel); }