diff --git a/OsmAnd/src/net/osmand/activities/MapActivity.java b/OsmAnd/src/net/osmand/activities/MapActivity.java index 647a90e704..2630060a8d 100644 --- a/OsmAnd/src/net/osmand/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/activities/MapActivity.java @@ -315,10 +315,12 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso - ZoomControls zoomControls = (ZoomControls) findViewById(R.id.ZoomControls); + final ZoomControls zoomControls = (ZoomControls) findViewById(R.id.ZoomControls); zoomControls.setOnZoomInClickListener(new OnClickListener() { @Override public void onClick(View v) { + zoomControls.setIsZoomInEnabled(mapView.getZoom() + 1 < mapView.getMaximumShownMapZoom()); + zoomControls.setIsZoomOutEnabled(mapView.getZoom() + 1 > mapView.getMinimumShownMapZoom()); mapView.getAnimatedDraggingThread().stopAnimatingSync(); mapView.getAnimatedDraggingThread().startZooming(mapView.getZoom(), mapView.getZoom() + 1); showAndHideMapPosition(); @@ -331,6 +333,8 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso zoomControls.setOnZoomOutClickListener(new OnClickListener() { @Override public void onClick(View v) { + zoomControls.setIsZoomInEnabled(mapView.getZoom() - 1 < mapView.getMaximumShownMapZoom()); + zoomControls.setIsZoomOutEnabled(mapView.getZoom() - 1 > mapView.getMinimumShownMapZoom()); mapView.getAnimatedDraggingThread().stopAnimatingSync(); mapView.getAnimatedDraggingThread().startZooming(mapView.getZoom(), mapView.getZoom() - 1); showAndHideMapPosition(); diff --git a/OsmAnd/src/net/osmand/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/views/OsmandMapTileView.java index 6453af0186..982053c05f 100644 --- a/OsmAnd/src/net/osmand/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/views/OsmandMapTileView.java @@ -247,10 +247,25 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall public float getYTile() { return (float) MapUtils.getTileNumberY(getZoom(), latitude); } + + public int getMaximumShownMapZoom(){ + if(map == null){ + return 21; + } else { + return map.getMaximumZoomSupported() + OVERZOOM_IN; + } + } + + public int getMinimumShownMapZoom(){ + if(map == null){ + return 1; + } else { + return map.getMinimumZoomSupported(); + } + } public void setZoom(float zoom) { - if ((map == null && zoom < 22 && zoom > 0) - || (map != null && (map.getMaximumZoomSupported() + OVERZOOM_IN) >= zoom && map.getMinimumZoomSupported() <= zoom)) { + if (zoom <= getMaximumShownMapZoom() && zoom >= getMinimumShownMapZoom()) { animatedDraggingThread.stopAnimating(); this.zoom = zoom; refreshMap();