Fix adding markers on map amenity
This commit is contained in:
parent
6cf701cd1f
commit
3b5ce64fed
6 changed files with 19 additions and 11 deletions
|
@ -609,10 +609,12 @@ public class MapMarkersHelper {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public MapMarker getMapMarker(@NonNull String mapObjectName) {
|
||||
public MapMarker getMapMarker(@NonNull String mapObjectName, @NonNull LatLon latLon) {
|
||||
for (MapMarker marker : mapMarkers) {
|
||||
if (marker.mapObjectName != null && marker.mapObjectName.equals(mapObjectName)) {
|
||||
return marker;
|
||||
if (marker.mapObjectName != null && marker.mapObjectName.equals(mapObjectName) && marker.point != null) {
|
||||
if (MapUtils.getDistance(latLon, marker.point) < 15) {
|
||||
return marker;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -38,7 +38,6 @@ import net.osmand.plus.mapcontextmenu.MenuController.MenuType;
|
|||
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController;
|
||||
import net.osmand.plus.transport.TransportStopRoute;
|
||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.PointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.RtePtEditor;
|
||||
|
@ -48,8 +47,8 @@ import net.osmand.plus.mapcontextmenu.other.ShareMenu;
|
|||
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
|
||||
import net.osmand.plus.mapmarkers.RenameMarkerBottomSheetDialogFragment;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.parkingpoint.ParkingPositionMenuController;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.transport.TransportStopRoute;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
|
@ -808,8 +807,13 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
MapActivity.clearPrevActivityIntent();
|
||||
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||
} else {
|
||||
String mapObjectName = null;
|
||||
if (object instanceof Amenity) {
|
||||
Amenity amenity = (Amenity) object;
|
||||
mapObjectName = amenity.getName() + "_" + amenity.getType().getKeyName();
|
||||
}
|
||||
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
|
||||
getPointDescriptionForMarker(), object instanceof Amenity ? ((Amenity) object).getName() : null);
|
||||
getPointDescriptionForMarker(), mapObjectName);
|
||||
}
|
||||
} else {
|
||||
mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(),
|
||||
|
|
|
@ -59,7 +59,8 @@ public class AmenityMenuController extends MenuController {
|
|||
}
|
||||
}
|
||||
|
||||
marker = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarker(amenity.getName());
|
||||
String mapNameForMarker = amenity.getName() + "_" + amenity.getType().getKeyName();
|
||||
marker = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarker(mapNameForMarker, amenity.getLocation());
|
||||
if (marker != null) {
|
||||
MapMarkerMenuController markerMenuController =
|
||||
new MapMarkerMenuController(mapActivity, marker.getPointDescription(mapActivity), marker);
|
||||
|
|
|
@ -624,7 +624,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
if (searchLatLon == null) {
|
||||
searchLatLon = tileBox.getLatLonFromPixel(point.x, point.y);
|
||||
}
|
||||
Amenity amenity = findAmenity(activity.getMyApplication(), renderedObject.getId() >> 7, names, searchLatLon);
|
||||
Amenity amenity = findAmenity(activity.getMyApplication(), renderedObject.getId() >> 7, names, searchLatLon, 50);
|
||||
if (amenity != null) {
|
||||
if (renderedObject.getX() != null && renderedObject.getX().size() > 1
|
||||
&& renderedObject.getY() != null && renderedObject.getY().size() > 1) {
|
||||
|
|
|
@ -556,7 +556,8 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
@Nullable
|
||||
public Amenity getMapObjectByMarker(@NonNull MapMarker marker) {
|
||||
if (marker.mapObjectName != null && marker.point != null) {
|
||||
return findAmenity(map.getMyApplication(), -1, Collections.singletonList(marker.mapObjectName), marker.point);
|
||||
String mapObjName = marker.mapObjectName.split("_")[0];
|
||||
return findAmenity(map.getMyApplication(), -1, Collections.singletonList(mapObjName), marker.point, 15);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -221,8 +221,8 @@ public abstract class OsmandMapLayer {
|
|||
return rf;
|
||||
}
|
||||
|
||||
public Amenity findAmenity(OsmandApplication app, long id, List<String> names, LatLon latLon) {
|
||||
QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 50);
|
||||
public Amenity findAmenity(OsmandApplication app, long id, List<String> names, LatLon latLon, int radius) {
|
||||
QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), radius);
|
||||
List<Amenity> amenities = app.getResourceManager().searchAmenities(
|
||||
new BinaryMapIndexReader.SearchPoiTypeFilter() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue