protected void rotateToAnimate(float rotate) { if (isMapRotateEnabled()) { this.rotate = MapUtils.unifyRotationTo360(rotate); currentViewport.setRotate(this.rotate); refreshMap(); } }
public void setComplexZoom(int zoom, float scale) { if (mainLayer != null && zoom <= mainLayer.getMaximumShownMapZoom() && zoom >= mainLayer.getMinimumShownMapZoom()) { animatedDraggingThread.stopAnimating(); currentViewport.setZoom(zoom, scale, 0); currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0); refreshMap(); } }
private void changeZoomPosition(float dz, float angle) { final QuadPoint cp = initialViewport.getCenterPixelPoint(); float dx = cp.x - initialMultiTouchCenterPoint.x; float dy = cp.y - initialMultiTouchCenterPoint.y; final RotatedTileBox calc = initialViewport.copy(); calc.setLatLonCenter(initialCenterLatLon.getLatitude(), initialCenterLatLon.getLongitude()); float calcZoom = initialViewport.getZoom() + dz + initialViewport.getZoomScale(); float calcRotate = calc.getRotate() + angle; calc.setRotate(calcRotate); calc.setZoomAnimation(dz); final LatLon r = calc.getLatLonFromPixel(cp.x + dx, cp.y + dy); setLatLon(r.getLatitude(), r.getLongitude()); zoomToAnimate(calcZoom, true); rotateToAnimate(calcRotate); }
private void drawBasemap(Canvas canvas) { if (bufferImgLoc != null) { float rot = -bufferImgLoc.getRotate(); canvas.rotate(rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY()); final RotatedTileBox calc = currentViewport.copy(); calc.setRotate(bufferImgLoc.getRotate()); int cz = getZoom(); QuadPoint lt = bufferImgLoc.getLeftTopTile(cz); QuadPoint rb = bufferImgLoc.getRightBottomTile(cz); final float x1 = calc.getPixXFromTile(lt.x, lt.y, cz); final float x2 = calc.getPixXFromTile(rb.x, rb.y, cz); final float y1 = calc.getPixYFromTile(lt.x, lt.y, cz); final float y2 = calc.getPixYFromTile(rb.x, rb.y, cz); if (!bufferBitmap.isRecycled()) { canvas.drawBitmap(bufferBitmap, null, new RectF(x1, y1, x2, y2), paintImg); } canvas.rotate(-rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY()); } }
// for internal usage protected void zoomToAnimate(float tzoom, boolean notify) { int zoom = getZoom(); float zoomToAnimate = tzoom - zoom - getZoomScale(); if (zoomToAnimate >= 1) { zoom += (int) zoomToAnimate; zoomToAnimate -= (int) zoomToAnimate; } while (zoomToAnimate < 0) { zoom--; zoomToAnimate += 1; } if (mainLayer != null && mainLayer.getMaximumShownMapZoom() >= zoom && mainLayer.getMinimumShownMapZoom() <= zoom) { currentViewport.setZoomAndAnimation(zoom, zoomToAnimate); currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0); refreshMap(); if (notify && locationListener != null) { locationListener.locationChanged(getLatitude(), getLongitude(), this); } } }