From 032c084a4d2d58f9c8545e6d92ea6990a555ca6d Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 18 Sep 2016 20:45:19 +0200 Subject: [PATCH] Fix coordinates --- OsmAnd/assets/style.css | 1 - .../src/net/osmand/plus/views/ContextMenuLayer.java | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/OsmAnd/assets/style.css b/OsmAnd/assets/style.css index dea92413e9..ad58effea1 100644 --- a/OsmAnd/assets/style.css +++ b/OsmAnd/assets/style.css @@ -60,4 +60,3 @@ /***********help about****************************************************/ .about .surname{font-weight:bold;} .about h3{margin-top:30px;} -.contributorsbanner {width:100%;} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 377389aa0a..8c10b313ce 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -23,6 +23,7 @@ import android.widget.ImageView; import net.osmand.CallbackWithObject; import net.osmand.NativeLibrary.RenderedObject; +import net.osmand.RenderingContext; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.Amenity; import net.osmand.data.LatLon; @@ -510,7 +511,16 @@ public class ContextMenuLayer extends OsmandMapLayer { if (nativeLib != null) { //RenderingContext rc = new RenderingContext(activity.getMyApplication()); MapRenderRepositories maps = activity.getMyApplication().getResourceManager().getRenderer(); - RenderedObject[] renderedObjects = nativeLib.searchRenderedObjectsFromContext(maps.getVisibleRenderingContext(), (int)point.x, (int)point.y); + + RenderingContext rc = maps.getVisibleRenderingContext(); + RenderedObject[] renderedObjects = null; + if(rc.zoom == tileBox.getZoom()) { + double lat = MapUtils.get31LatitudeY((int)(rc.topY*rc.tileDivisor)); + double lon = MapUtils.get31LongitudeX((int)(rc.leftX*rc.tileDivisor)); + float x = tileBox.getPixXFromLatLon(lat, lon); + float y = tileBox.getPixYFromLatLon(lat, lon); + renderedObjects = nativeLib.searchRenderedObjectsFromContext(rc, (int)( point.x - x), (int)( point.y- y)); + } if (renderedObjects != null) { Log.e("111", "found " + renderedObjects.length + " object(s) at x=" + point.x + " y=" + point.y); for (RenderedObject renderedObject : renderedObjects) {