From 1d6c0a380a8b7fa633027856f11931c8989d06e8 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Sat, 3 Feb 2018 13:56:51 +0300 Subject: [PATCH] Fix #4746 --- .../mapcontextmenu/MapContextMenuFragment.java | 3 ++- .../net/osmand/plus/views/OsmandMapTileView.java | 15 +++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 312d4eeb86..44cbccb639 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -1572,7 +1572,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo int zoom = getZoom() + dZoom; LatLon latlon = getAdjustedMarkerLocation(y, menu.getLatLon(), center, zoom); - if (map.getLatitude() == latlon.getLatitude() && map.getLongitude() == latlon.getLongitude() && dZoom == 0) { + if (map.hasCustomMapRatio() + || (map.getLatitude() == latlon.getLatitude() && map.getLongitude() == latlon.getLongitude() && dZoom == 0)) { return; } diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 350a754451..58fb851fd5 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -130,7 +130,6 @@ public class OsmandMapTileView implements IMapDownloaderCallback { private float mapRatioX; private float mapRatioY; - private LatLon originalRatioCenterLatLon; private boolean showMapPosition = true; @@ -496,16 +495,20 @@ public class OsmandMapTileView implements IMapDownloaderCallback { public void setCustomMapRatio(float ratioX, float ratioY) { this.mapRatioX = ratioX; this.mapRatioY = ratioY; - originalRatioCenterLatLon = currentViewport.getCenterLatLon(); } public void restoreMapRatio() { + RotatedTileBox box = currentViewport.copy(); + float rx = (float)box.getCenterPixelX() / box.getPixWidth(); + float ry = (float)box.getCenterPixelY() / box.getPixHeight(); + if (mapPosition == OsmandSettings.BOTTOM_CONSTANT) { + ry -= 0.35; + } + box.setCenterLocation(rx, ry); + LatLon screenCenter = box.getLatLonFromPixel(box.getPixWidth() / 2, box.getPixHeight() / 2); mapRatioX = 0; mapRatioY = 0; - if (originalRatioCenterLatLon != null) { - setLatLon(originalRatioCenterLatLon.getLatitude(), originalRatioCenterLatLon.getLongitude()); - originalRatioCenterLatLon = null; - } + setLatLon(screenCenter.getLatitude(), screenCenter.getLongitude()); } public boolean hasCustomMapRatio() {