Merge pull request #10335 from osmandapp/fix_309

Fix map shifting on tap during map rotation
This commit is contained in:
vshcherb 2020-12-04 16:49:22 +02:00 committed by GitHub
commit c59d86681e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -703,9 +703,16 @@ public class ContextMenuLayer extends OsmandMapLayer {
RenderingContext rc = maps.getVisibleRenderingContext(); RenderingContext rc = maps.getVisibleRenderingContext();
RenderedObject[] renderedObjects = null; RenderedObject[] renderedObjects = null;
if (rc != null && rc.zoom == tileBox.getZoom()) { 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 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)); 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) { if (renderedObjects != null) {
int TILE_SIZE = 256; int TILE_SIZE = 256;