Merge pull request #5114 from osmandapp/FixPinLocationMarkerAndPinMisaligned

added check if selectedObj is amenity and get it`s location
This commit is contained in:
Alexander Sytnyk 2018-03-12 14:38:17 +02:00 committed by GitHub
commit a60f3bc0d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,6 +106,8 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
private boolean inPlanRouteMode; private boolean inPlanRouteMode;
private boolean defaultAppMode = true; private boolean defaultAppMode = true;
private List<Amenity> amenities = new ArrayList<>();
public MapMarkersLayer(MapActivity map) { public MapMarkersLayer(MapActivity map) {
this.map = map; this.map = map;
} }
@ -515,7 +517,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().USE_MAP_MARKERS.get()) { if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().USE_MAP_MARKERS.get()) {
return; return;
} }
amenities.clear();
OsmandApplication app = map.getMyApplication(); OsmandApplication app = map.getMyApplication();
int r = getDefaultRadiusPoi(tileBox); int r = getDefaultRadiusPoi(tileBox);
boolean selectMarkerOnSingleTap = app.getSettings().SELECT_MARKER_ON_SINGLE_TAP.get(); boolean selectMarkerOnSingleTap = app.getSettings().SELECT_MARKER_ON_SINGLE_TAP.get();
@ -535,7 +537,12 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
continue; continue;
} }
Amenity mapObj = getMapObjectByMarker(marker); 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,8 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
public LatLon getObjectLocation(Object o) { public LatLon getObjectLocation(Object o) {
if (o instanceof MapMarker) { if (o instanceof MapMarker) {
return ((MapMarker) o).point; return ((MapMarker) o).point;
} else if (o instanceof Amenity && amenities.contains(o)) {
return ((Amenity) o).getLocation();
} }
return null; return null;
} }