private Point getUpperLeftCornerOfCenterMapTileInScreen( final int[] centerMapTileCoords, final int tileSizePx, final Point reuse) { if (OpenStreetMapViewConstants.DEBUGMODE) Log.d("RMAPS-Me", "YandexTrafficOverlay getUpperLeftCornerOfCenterMapTileInScreen is Called"); final Point out = (reuse != null) ? reuse : new Point(); final int viewWidth = mMapView.getWidth(); final int viewWidth_2 = viewWidth / 2; final int viewHeight = mMapView.getHeight(); final int viewHeight_2 = viewHeight / 2; /* * Calculate the Latitude/Longitude on the left-upper ScreenCoords of the center MapTile. So in the end we can * determine which MapTiles we additionally need next to the centerMapTile. */ final BoundingBoxE6 bb = Util.getBoundingBoxFromMapTile( centerMapTileCoords, mMapView.getZoomLevel(), mRendererInfo.PROJECTION); final float[] relativePositionInCenterMapTile = bb.getRelativePositionOfGeoPointInBoundingBoxWithLinearInterpolation( mMapView.getMapCenterLatitudeE6(), mMapView.getMapCenterLongitudeE6(), null); final int centerMapTileScreenLeft = viewWidth_2 - (int) (0.5f + (relativePositionInCenterMapTile[1] * tileSizePx)); final int centerMapTileScreenTop = viewHeight_2 - (int) (0.5f + (relativePositionInCenterMapTile[0] * tileSizePx)); out.set(centerMapTileScreenLeft, centerMapTileScreenTop); return out; }
// TODO rework zoomToSpan public void zoomToSpan(final int reqLatSpan, final int reqLonSpan) { if (reqLatSpan <= 0 || reqLonSpan <= 0) return; final BoundingBoxE6 bb = this.mOsmv.getVisibleBoundingBoxE6(); final int curZoomLevel = this.mOsmv.getZoomLevel(); final int curLatSpan = bb.getLatitudeSpanE6(); final int curLonSpan = bb.getLongitudeSpanE6(); final float diffNeededLat = (float) reqLatSpan / curLatSpan; // i.e. 600/500 = 1,2 final float diffNeededLon = (float) reqLonSpan / curLonSpan; // i.e. 300/400 = 0,75 final float diffNeeded = Math.max(diffNeededLat, diffNeededLon); // i.e. 1,2 if (diffNeeded > 1) { // Zoom Out this.mOsmv.setZoomLevel(curZoomLevel - MyMath.getNextSquareNumberAbove(diffNeeded)); } else if (diffNeeded < 0.5) { // Can Zoom in this.mOsmv.setZoomLevel(curZoomLevel + MyMath.getNextSquareNumberAbove(1 / diffNeeded) - 1); } }
public void zoomToSpan(BoundingBoxE6 bb) { zoomToSpan(bb.getLatitudeSpanE6(), bb.getLongitudeSpanE6()); }