From 4e7f8977e59831e13a57d0ad17c6ec37a4f78719 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 4 Dec 2020 15:50:10 +0200 Subject: [PATCH] Fix map shifting during map rotation --- .../net/osmand/plus/views/layers/ContextMenuLayer.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java index 9ba3ee5f46..cc017d23ac 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java @@ -703,9 +703,16 @@ public class ContextMenuLayer extends OsmandMapLayer { RenderingContext rc = maps.getVisibleRenderingContext(); RenderedObject[] renderedObjects = null; if (rc != null && rc.zoom == tileBox.getZoom()) { + double sinRotate = Math.sin(Math.toRadians(rc.rotate - tileBox.getRotate())); + double cosRotate = Math.cos(Math.toRadians(rc.rotate - tileBox.getRotate())); float x = tileBox.getPixXFrom31((int) (rc.leftX * rc.tileDivisor), (int) (rc.topY * rc.tileDivisor)); float y = tileBox.getPixYFrom31((int) (rc.leftX * rc.tileDivisor), (int) (rc.topY * rc.tileDivisor)); - renderedObjects = nativeLib.searchRenderedObjectsFromContext(rc, (int) (point.x - x), (int) (point.y - y)); + float dx = point.x - x; + float dy = point.y - y; + int coordX = (int) (dx * cosRotate - dy * sinRotate); + int coordY = (int) (dy * cosRotate + dx * sinRotate); + + renderedObjects = nativeLib.searchRenderedObjectsFromContext(rc, coordX, coordY); } if (renderedObjects != null) { int TILE_SIZE = 256;