diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenu.java index a3843896a5..44b47949a0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenu.java @@ -117,12 +117,7 @@ public class MapMultiSelectionMenu extends BaseMenuController { pointDescription = contextObject.getObjectName(selectedObj); } if (ll == null) { - if (selectedObj instanceof Amenity) { - Amenity a = ((Amenity) selectedObj); - ll = a.getLocation(); - } else { ll = latLon; - } } if (pointDescription == null) { pointDescription = new PointDescription(latLon.getLatitude(), latLon.getLongitude()); diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 11f59134a4..8403db1b71 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -654,12 +654,7 @@ public class ContextMenuLayer extends OsmandMapLayer { pointDescription = provider.getObjectName(selectedObj); } if (latLon == null) { - if (selectedObj instanceof Amenity) { - Amenity a = ((Amenity) selectedObj); - latLon = a.getLocation(); - } else { - latLon = getLatLon(point, tileBox); - } + latLon = getLatLon(point, tileBox); } if (mInAddGpxPointMode) { String title = pointDescription == null ? "" : pointDescription.getName(); diff --git a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java index f99225907a..77da9c1d85 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java @@ -92,6 +92,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi private TIntArrayList tx = new TIntArrayList(); private TIntArrayList ty = new TIntArrayList(); + private List amenities = new ArrayList<>(); private Path linePath = new Path(); private LatLon fingerLocation; @@ -512,6 +513,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o, boolean unknownLocation) { + amenities.clear(); if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().USE_MAP_MARKERS.get()) { return; } @@ -535,7 +537,12 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi continue; } Amenity mapObj = getMapObjectByMarker(marker); - o.add(mapObj == null ? marker : mapObj); + if (mapObj != null) { + amenities.add(mapObj); + o.add(mapObj); + } else { + o.add(marker); + } } } } @@ -568,6 +575,11 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi public LatLon getObjectLocation(Object o) { if (o instanceof MapMarker) { return ((MapMarker) o).point; + } else if (o instanceof Amenity) { + Amenity amenity = (Amenity) o; + if (amenities.contains(amenity)) { + return amenity.getLocation(); + } } return null; }