Merge pull request #4854 from osmandapp/markers_with_map_objects
Markers with map objects
This commit is contained in:
commit
b2eb71ec9a
15 changed files with 265 additions and 114 deletions
|
@ -1,10 +1,13 @@
|
||||||
package net.osmand.plus;
|
package net.osmand.plus;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
|
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
|
||||||
|
@ -451,6 +454,16 @@ public class FavouritesDbHelper {
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public FavouritePoint getVisibleFavByLatLon(@NonNull LatLon latLon) {
|
||||||
|
for (FavouritePoint fav : cachedFavoritePoints) {
|
||||||
|
if (fav.isVisible() && latLon.equals(new LatLon(fav.getLatitude(), fav.getLongitude()))) {
|
||||||
|
return fav;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<FavoriteGroup> getFavoriteGroups() {
|
public List<FavoriteGroup> getFavoriteGroups() {
|
||||||
return favoriteGroups;
|
return favoriteGroups;
|
||||||
|
|
|
@ -3,10 +3,12 @@ package net.osmand.plus;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.IProgress;
|
import net.osmand.IProgress;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||||
|
@ -389,6 +391,21 @@ public class GpxSelectionHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public WptPt getVisibleWayPointByLatLon(@NonNull LatLon latLon) {
|
||||||
|
for (SelectedGpxFile selectedGpx : selectedGPXFiles) {
|
||||||
|
GPXFile gpx;
|
||||||
|
if (selectedGpx != null && (gpx = selectedGpx.getGpxFile()) != null) {
|
||||||
|
for (WptPt pt : gpx.getPoints()) {
|
||||||
|
if (latLon.equals(new LatLon(pt.getLatitude(), pt.getLongitude()))) {
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void setGpxFileToDisplay(GPXFile... gpxs) {
|
public void setGpxFileToDisplay(GPXFile... gpxs) {
|
||||||
// special case for gpx current route
|
// special case for gpx current route
|
||||||
for (GPXFile gpx : gpxs) {
|
for (GPXFile gpx : gpxs) {
|
||||||
|
|
|
@ -76,6 +76,7 @@ public class MapMarkersHelper {
|
||||||
public String groupName;
|
public String groupName;
|
||||||
public WptPt wptPt;
|
public WptPt wptPt;
|
||||||
public FavouritePoint favouritePoint;
|
public FavouritePoint favouritePoint;
|
||||||
|
public String mapObjectName;
|
||||||
|
|
||||||
public MapMarker(LatLon point, PointDescription name, int colorIndex,
|
public MapMarker(LatLon point, PointDescription name, int colorIndex,
|
||||||
boolean selected, int index) {
|
boolean selected, int index) {
|
||||||
|
@ -597,6 +598,26 @@ public class MapMarkersHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public MapMarker getMapMarker(@NonNull LatLon latLon) {
|
||||||
|
for (MapMarker marker : mapMarkers) {
|
||||||
|
if (marker.point != null && marker.point.equals(latLon)) {
|
||||||
|
return marker;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public MapMarker getMapMarker(@NonNull String mapObjectName) {
|
||||||
|
for (MapMarker marker : mapMarkers) {
|
||||||
|
if (marker.mapObjectName != null && marker.mapObjectName.equals(mapObjectName)) {
|
||||||
|
return marker;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void addNewMarkerIfNeeded(@NonNull MarkersSyncGroup group,
|
private void addNewMarkerIfNeeded(@NonNull MarkersSyncGroup group,
|
||||||
@NonNull List<MapMarker> markers,
|
@NonNull List<MapMarker> markers,
|
||||||
@NonNull LatLon latLon,
|
@NonNull LatLon latLon,
|
||||||
|
@ -628,7 +649,7 @@ public class MapMarkersHelper {
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
addMarkers(Collections.singletonList(latLon),
|
addMarkers(Collections.singletonList(latLon),
|
||||||
Collections.singletonList(new PointDescription(POINT_TYPE_MAP_MARKER, name)),
|
Collections.singletonList(new PointDescription(POINT_TYPE_MAP_MARKER, name)),
|
||||||
group, enabled, Collections.singletonList(favouritePoint), Collections.singletonList(wptPt));
|
group, enabled, Collections.singletonList(favouritePoint), Collections.singletonList(wptPt), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -936,16 +957,21 @@ public class MapMarkersHelper {
|
||||||
addMarkers(Collections.singletonList(point), Collections.singletonList(historyName), null, true);
|
addMarkers(Collections.singletonList(point), Collections.singletonList(historyName), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addMapMarker(@NonNull LatLon point, @Nullable PointDescription historyName, @Nullable String mapObjectName) {
|
||||||
|
addMarkers(Collections.singletonList(point), Collections.singletonList(historyName), null,
|
||||||
|
true, null, null, Collections.singletonList(mapObjectName));
|
||||||
|
}
|
||||||
|
|
||||||
public void addMapMarkers(@NonNull List<LatLon> points, @NonNull List<PointDescription> historyNames, @Nullable MarkersSyncGroup group) {
|
public void addMapMarkers(@NonNull List<LatLon> points, @NonNull List<PointDescription> historyNames, @Nullable MarkersSyncGroup group) {
|
||||||
addMarkers(points, historyNames, group, true);
|
addMarkers(points, historyNames, group, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMarkers(@NonNull List<LatLon> points, @NonNull List<PointDescription> historyNames, @Nullable MarkersSyncGroup group, boolean enabled) {
|
private void addMarkers(@NonNull List<LatLon> points, @NonNull List<PointDescription> historyNames, @Nullable MarkersSyncGroup group, boolean enabled) {
|
||||||
addMarkers(points, historyNames, group, enabled, null, null);
|
addMarkers(points, historyNames, group, enabled, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMarkers(@NonNull List<LatLon> points, @NonNull List<PointDescription> historyNames, @Nullable MarkersSyncGroup group,
|
private void addMarkers(@NonNull List<LatLon> points, @NonNull List<PointDescription> historyNames, @Nullable MarkersSyncGroup group,
|
||||||
boolean enabled, @Nullable List<FavouritePoint> favouritePoints, @Nullable List<WptPt> wptPts) {
|
boolean enabled, @Nullable List<FavouritePoint> favouritePoints, @Nullable List<WptPt> wptPts, @Nullable List<String> mapObjNames) {
|
||||||
if (points.size() > 0) {
|
if (points.size() > 0) {
|
||||||
int colorIndex = -1;
|
int colorIndex = -1;
|
||||||
List<MapMarker> addedMarkers = new ArrayList<>();
|
List<MapMarker> addedMarkers = new ArrayList<>();
|
||||||
|
@ -954,6 +980,7 @@ public class MapMarkersHelper {
|
||||||
PointDescription historyName = historyNames.get(i);
|
PointDescription historyName = historyNames.get(i);
|
||||||
FavouritePoint favouritePoint = favouritePoints == null ? null : favouritePoints.get(i);
|
FavouritePoint favouritePoint = favouritePoints == null ? null : favouritePoints.get(i);
|
||||||
WptPt wptPt = wptPts == null ? null : wptPts.get(i);
|
WptPt wptPt = wptPts == null ? null : wptPts.get(i);
|
||||||
|
String mapObjName = mapObjNames == null ? null : mapObjNames.get(i);
|
||||||
final PointDescription pointDescription;
|
final PointDescription pointDescription;
|
||||||
if (historyName == null) {
|
if (historyName == null) {
|
||||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
|
pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
|
||||||
|
@ -986,6 +1013,7 @@ public class MapMarkersHelper {
|
||||||
marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE;
|
marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE;
|
||||||
marker.favouritePoint = favouritePoint;
|
marker.favouritePoint = favouritePoint;
|
||||||
marker.wptPt = wptPt;
|
marker.wptPt = wptPt;
|
||||||
|
marker.mapObjectName = mapObjName;
|
||||||
markersDbHelper.addMarker(marker);
|
markersDbHelper.addMarker(marker);
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
addToMapMarkersList(0, marker);
|
addToMapMarkersList(0, marker);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -104,9 +105,9 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addMapMarker(double latitude, double longitude, PointDescription pd) {
|
public void addMapMarker(double latitude, double longitude, PointDescription pd, @Nullable String mapObjectName) {
|
||||||
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
|
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
|
||||||
markersHelper.addMapMarker(new LatLon(latitude, longitude), pd);
|
markersHelper.addMapMarker(new LatLon(latitude, longitude), pd, mapObjectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editWaypoints() {
|
public void editWaypoints() {
|
||||||
|
|
|
@ -789,7 +789,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
MapMarkersDialogFragment.showInstance(mapActivity);
|
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||||
} else {
|
} else {
|
||||||
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
|
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
|
||||||
getPointDescriptionForMarker());
|
getPointDescriptionForMarker(), object instanceof Amenity ? ((Amenity) object).getName() : null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(),
|
mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(),
|
||||||
|
|
|
@ -11,6 +11,7 @@ import net.osmand.data.TransportStop;
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiFilter;
|
import net.osmand.osm.PoiFilter;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
|
@ -35,6 +36,8 @@ public class AmenityMenuController extends MenuController {
|
||||||
private Amenity amenity;
|
private Amenity amenity;
|
||||||
private List<TransportStopRoute> routes = new ArrayList<>();
|
private List<TransportStopRoute> routes = new ArrayList<>();
|
||||||
|
|
||||||
|
private MapMarker marker;
|
||||||
|
|
||||||
public AmenityMenuController(MapActivity mapActivity, PointDescription pointDescription, Amenity amenity) {
|
public AmenityMenuController(MapActivity mapActivity, PointDescription pointDescription, Amenity amenity) {
|
||||||
super(new AmenityMenuBuilder(mapActivity, amenity), pointDescription, mapActivity);
|
super(new AmenityMenuBuilder(mapActivity, amenity), pointDescription, mapActivity);
|
||||||
this.amenity = amenity;
|
this.amenity = amenity;
|
||||||
|
@ -53,6 +56,14 @@ public class AmenityMenuController extends MenuController {
|
||||||
processTransportStop();
|
processTransportStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
marker = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarker(amenity.getName());
|
||||||
|
if (marker != null) {
|
||||||
|
MapMarkerMenuController markerMenuController =
|
||||||
|
new MapMarkerMenuController(mapActivity, marker.getPointDescription(mapActivity), marker);
|
||||||
|
leftTitleButtonController = markerMenuController.getLeftTitleButtonController();
|
||||||
|
leftSubtitleButtonController = markerMenuController.getLeftSubtitleButtonController();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -67,6 +78,11 @@ public class AmenityMenuController extends MenuController {
|
||||||
return amenity;
|
return amenity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWaypointButtonEnabled() {
|
||||||
|
return marker == null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean needStreetName() {
|
public boolean needStreetName() {
|
||||||
if (amenity.getSubType() != null && amenity.getType() != null) {
|
if (amenity.getSubType() != null && amenity.getType() != null) {
|
||||||
|
|
|
@ -22,13 +22,17 @@ import net.osmand.util.Algorithms;
|
||||||
public class FavouritePointMenuController extends MenuController {
|
public class FavouritePointMenuController extends MenuController {
|
||||||
|
|
||||||
private FavouritePoint fav;
|
private FavouritePoint fav;
|
||||||
|
private MapMarker mapMarker;
|
||||||
|
|
||||||
public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
|
public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
|
||||||
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
|
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
|
||||||
this.fav = fav;
|
this.fav = fav;
|
||||||
|
|
||||||
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||||
final MapMarker mapMarker = markersHelper.getMapMarker(fav);
|
mapMarker = markersHelper.getMapMarker(fav);
|
||||||
|
if (mapMarker == null) {
|
||||||
|
mapMarker = markersHelper.getMapMarker(new LatLon(fav.getLatitude(), fav.getLongitude()));
|
||||||
|
}
|
||||||
if (mapMarker != null) {
|
if (mapMarker != null) {
|
||||||
MapMarkerMenuController markerMenuController =
|
MapMarkerMenuController markerMenuController =
|
||||||
new MapMarkerMenuController(mapActivity, mapMarker.getPointDescription(mapActivity), mapMarker);
|
new MapMarkerMenuController(mapActivity, mapMarker.getPointDescription(mapActivity), mapMarker);
|
||||||
|
@ -81,7 +85,7 @@ public class FavouritePointMenuController extends MenuController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWaypointButtonEnabled() {
|
public boolean isWaypointButtonEnabled() {
|
||||||
return getMapActivity().getMyApplication().getMapMarkersHelper().getMapMarker(fav) == null;
|
return mapMarker == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.MapMarkersHelper;
|
import net.osmand.plus.MapMarkersHelper;
|
||||||
|
@ -17,14 +18,17 @@ import net.osmand.util.Algorithms;
|
||||||
public class WptPtMenuController extends MenuController {
|
public class WptPtMenuController extends MenuController {
|
||||||
|
|
||||||
private WptPt wpt;
|
private WptPt wpt;
|
||||||
|
private MapMarker mapMarker;
|
||||||
|
|
||||||
public WptPtMenuController(MapActivity mapActivity, PointDescription pointDescription, WptPt wpt) {
|
public WptPtMenuController(MapActivity mapActivity, PointDescription pointDescription, WptPt wpt) {
|
||||||
super(new WptPtMenuBuilder(mapActivity, wpt), pointDescription, mapActivity);
|
super(new WptPtMenuBuilder(mapActivity, wpt), pointDescription, mapActivity);
|
||||||
this.wpt = wpt;
|
this.wpt = wpt;
|
||||||
|
|
||||||
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||||
final MapMarker mapMarker = markersHelper.getMapMarker(wpt);
|
mapMarker = markersHelper.getMapMarker(wpt);
|
||||||
|
if (mapMarker == null) {
|
||||||
|
mapMarker = markersHelper.getMapMarker(new LatLon(wpt.lat, wpt.lon));
|
||||||
|
}
|
||||||
if (mapMarker != null) {
|
if (mapMarker != null) {
|
||||||
MapMarkerMenuController markerMenuController =
|
MapMarkerMenuController markerMenuController =
|
||||||
new MapMarkerMenuController(mapActivity, mapMarker.getPointDescription(mapActivity), mapMarker);
|
new MapMarkerMenuController(mapActivity, mapMarker.getPointDescription(mapActivity), mapMarker);
|
||||||
|
@ -84,7 +88,7 @@ public class WptPtMenuController extends MenuController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWaypointButtonEnabled() {
|
public boolean isWaypointButtonEnabled() {
|
||||||
return getMapActivity().getMyApplication().getMapMarkersHelper().getMapMarker(wpt) == null;
|
return mapMarker == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,6 +13,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
|
@ -62,32 +63,44 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
|
||||||
if (pos == RecyclerView.NO_POSITION) {
|
if (pos == RecyclerView.NO_POSITION) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapMarker marker = adapter.getItem(pos);
|
MapMarker marker = adapter.getItem(pos);
|
||||||
if (mapActivity.getMyApplication().getSettings().SELECT_MARKER_ON_SINGLE_TAP.get()) {
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
mapActivity.getMyApplication().getMapMarkersHelper().moveMarkerToTop(marker);
|
if (app.getSettings().SELECT_MARKER_ON_SINGLE_TAP.get()) {
|
||||||
|
app.getMapMarkersHelper().moveMarkerToTop(marker);
|
||||||
updateAdapter();
|
updateAdapter();
|
||||||
} else {
|
} else {
|
||||||
WptPt wptPt = marker.wptPt;
|
FavouritePoint fav = marker.favouritePoint == null
|
||||||
FavouritePoint favouritePoint = marker.favouritePoint;
|
? app.getFavorites().getVisibleFavByLatLon(marker.point)
|
||||||
Object objectToShow;
|
: marker.favouritePoint;
|
||||||
PointDescription pointDescription;
|
if (fav != null) {
|
||||||
if (wptPt != null) {
|
showMap(marker.point, fav.getPointDescription(), fav);
|
||||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, wptPt.name);
|
return;
|
||||||
objectToShow = wptPt;
|
|
||||||
} else if (favouritePoint != null) {
|
|
||||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, favouritePoint.getName());
|
|
||||||
objectToShow = favouritePoint;
|
|
||||||
} else {
|
|
||||||
pointDescription = marker.getPointDescription(mapActivity);
|
|
||||||
objectToShow = marker;
|
|
||||||
}
|
}
|
||||||
mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
|
|
||||||
15, pointDescription, true, objectToShow);
|
WptPt pt = marker.wptPt == null
|
||||||
MapActivity.launchMapActivityMoveToTop(mapActivity);
|
? app.getSelectedGpxHelper().getVisibleWayPointByLatLon(marker.point)
|
||||||
((DialogFragment) getParentFragment()).dismiss();
|
: marker.wptPt;
|
||||||
|
if (pt != null) {
|
||||||
|
showMap(marker.point, pt.getPointDescription(mapActivity), pt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Amenity mapObj = mapActivity.getMapLayers().getMapMarkersLayer().getMapObjectByMarker(marker);
|
||||||
|
PointDescription desc = mapObj == null
|
||||||
|
? marker.getPointDescription(mapActivity)
|
||||||
|
: mapActivity.getMapLayers().getPoiMapLayer().getObjectName(mapObj);
|
||||||
|
showMap(marker.point, desc, mapObj == null ? marker : mapObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showMap(LatLon latLon, PointDescription desc, Object objToShow) {
|
||||||
|
mapActivity.getMyApplication().getSettings().setMapLocationToShow(latLon.getLatitude(),
|
||||||
|
latLon.getLongitude(), 15, desc, true, objToShow);
|
||||||
|
MapActivity.launchMapActivityMoveToTop(mapActivity);
|
||||||
|
((DialogFragment) getParentFragment()).dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDragStarted(RecyclerView.ViewHolder holder) {
|
public void onDragStarted(RecyclerView.ViewHolder holder) {
|
||||||
compassUpdateAllowed = false;
|
compassUpdateAllowed = false;
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Set;
|
||||||
|
|
||||||
public class MapMarkersDbHelper {
|
public class MapMarkersDbHelper {
|
||||||
|
|
||||||
private static final int DB_VERSION = 11;
|
private static final int DB_VERSION = 12;
|
||||||
public static final String DB_NAME = "map_markers_db";
|
public static final String DB_NAME = "map_markers_db";
|
||||||
|
|
||||||
private static final String MARKERS_TABLE_NAME = "map_markers";
|
private static final String MARKERS_TABLE_NAME = "map_markers";
|
||||||
|
@ -42,6 +42,7 @@ public class MapMarkersDbHelper {
|
||||||
private static final String MARKERS_COL_NEXT_KEY = "marker_next_key";
|
private static final String MARKERS_COL_NEXT_KEY = "marker_next_key";
|
||||||
private static final String MARKERS_COL_DISABLED = "marker_disabled";
|
private static final String MARKERS_COL_DISABLED = "marker_disabled";
|
||||||
private static final String MARKERS_COL_SELECTED = "marker_selected";
|
private static final String MARKERS_COL_SELECTED = "marker_selected";
|
||||||
|
private static final String MARKERS_COL_MAP_OBJECT_NAME = "marker_map_object_name";
|
||||||
|
|
||||||
private static final String MARKERS_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " +
|
private static final String MARKERS_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " +
|
||||||
MARKERS_TABLE_NAME + " (" +
|
MARKERS_TABLE_NAME + " (" +
|
||||||
|
@ -57,7 +58,8 @@ public class MapMarkersDbHelper {
|
||||||
MARKERS_COL_COLOR + " int, " +
|
MARKERS_COL_COLOR + " int, " +
|
||||||
MARKERS_COL_NEXT_KEY + " TEXT, " +
|
MARKERS_COL_NEXT_KEY + " TEXT, " +
|
||||||
MARKERS_COL_DISABLED + " int, " + // 1 = true, 0 = false
|
MARKERS_COL_DISABLED + " int, " + // 1 = true, 0 = false
|
||||||
MARKERS_COL_SELECTED + " int);"; // 1 = true, 0 = false
|
MARKERS_COL_SELECTED + " int, " + // 1 = true, 0 = false
|
||||||
|
MARKERS_COL_MAP_OBJECT_NAME + " TEXT);";
|
||||||
|
|
||||||
private static final String MARKERS_TABLE_SELECT = "SELECT " +
|
private static final String MARKERS_TABLE_SELECT = "SELECT " +
|
||||||
MARKERS_COL_ID + ", " +
|
MARKERS_COL_ID + ", " +
|
||||||
|
@ -72,7 +74,8 @@ public class MapMarkersDbHelper {
|
||||||
MARKERS_COL_COLOR + ", " +
|
MARKERS_COL_COLOR + ", " +
|
||||||
MARKERS_COL_NEXT_KEY + ", " +
|
MARKERS_COL_NEXT_KEY + ", " +
|
||||||
MARKERS_COL_DISABLED + ", " +
|
MARKERS_COL_DISABLED + ", " +
|
||||||
MARKERS_COL_SELECTED +
|
MARKERS_COL_SELECTED + ", " +
|
||||||
|
MARKERS_COL_MAP_OBJECT_NAME +
|
||||||
" FROM " + MARKERS_TABLE_NAME;
|
" FROM " + MARKERS_TABLE_NAME;
|
||||||
|
|
||||||
private static final String GROUPS_TABLE_NAME = "map_markers_groups";
|
private static final String GROUPS_TABLE_NAME = "map_markers_groups";
|
||||||
|
@ -150,6 +153,9 @@ public class MapMarkersDbHelper {
|
||||||
" SET " + MARKERS_COL_SELECTED + " = ? " +
|
" SET " + MARKERS_COL_SELECTED + " = ? " +
|
||||||
"WHERE " + MARKERS_COL_SELECTED + " IS NULL", new Object[]{0});
|
"WHERE " + MARKERS_COL_SELECTED + " IS NULL", new Object[]{0});
|
||||||
}
|
}
|
||||||
|
if (oldVersion < 12) {
|
||||||
|
db.execSQL("ALTER TABLE " + MARKERS_TABLE_NAME + " ADD " + MARKERS_COL_MAP_OBJECT_NAME + " TEXT");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveExistingMarkersToDb() {
|
private void saveExistingMarkersToDb() {
|
||||||
|
@ -378,11 +384,12 @@ public class MapMarkersDbHelper {
|
||||||
MARKERS_COL_COLOR + ", " +
|
MARKERS_COL_COLOR + ", " +
|
||||||
MARKERS_COL_NEXT_KEY + ", " +
|
MARKERS_COL_NEXT_KEY + ", " +
|
||||||
MARKERS_COL_DISABLED + ", " +
|
MARKERS_COL_DISABLED + ", " +
|
||||||
MARKERS_COL_SELECTED + ") " +
|
MARKERS_COL_SELECTED + ", " +
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
MARKERS_COL_MAP_OBJECT_NAME + ") " +
|
||||||
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
new Object[]{marker.id, marker.getLatitude(), marker.getLongitude(), descr, active,
|
new Object[]{marker.id, marker.getLatitude(), marker.getLongitude(), descr, active,
|
||||||
currentTime, visited, marker.groupName, marker.groupKey, marker.colorIndex,
|
currentTime, visited, marker.groupName, marker.groupKey, marker.colorIndex,
|
||||||
marker.history ? HISTORY_NEXT_VALUE : TAIL_NEXT_VALUE, 0, 0});
|
marker.history ? HISTORY_NEXT_VALUE : TAIL_NEXT_VALUE, 0, 0, marker.mapObjectName});
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MapMarker> getMarkersFromGroup(MarkersSyncGroup group) {
|
public List<MapMarker> getMarkersFromGroup(MarkersSyncGroup group) {
|
||||||
|
@ -459,6 +466,7 @@ public class MapMarkersDbHelper {
|
||||||
int colorIndex = query.getInt(9);
|
int colorIndex = query.getInt(9);
|
||||||
String nextKey = query.getString(10);
|
String nextKey = query.getString(10);
|
||||||
boolean selected = query.getInt(12) == 1;
|
boolean selected = query.getInt(12) == 1;
|
||||||
|
String mapObjectName = query.getString(13);
|
||||||
|
|
||||||
LatLon latLon = new LatLon(lat, lon);
|
LatLon latLon = new LatLon(lat, lon);
|
||||||
MapMarker marker = new MapMarker(latLon, PointDescription.deserializeFromString(desc, latLon),
|
MapMarker marker = new MapMarker(latLon, PointDescription.deserializeFromString(desc, latLon),
|
||||||
|
@ -471,6 +479,7 @@ public class MapMarkersDbHelper {
|
||||||
marker.groupKey = groupKey;
|
marker.groupKey = groupKey;
|
||||||
marker.nextKey = nextKey;
|
marker.nextKey = nextKey;
|
||||||
marker.selected = selected;
|
marker.selected = selected;
|
||||||
|
marker.mapObjectName = mapObjectName;
|
||||||
|
|
||||||
return marker;
|
return marker;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
|
@ -35,9 +36,9 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||||
|
import net.osmand.plus.mapmarkers.SelectionMarkersGroupBottomSheetDialogFragment.AddMarkersGroupFragmentListener;
|
||||||
import net.osmand.plus.mapmarkers.adapters.MapMarkerItemViewHolder;
|
import net.osmand.plus.mapmarkers.adapters.MapMarkerItemViewHolder;
|
||||||
import net.osmand.plus.mapmarkers.adapters.MapMarkersGroupsAdapter;
|
import net.osmand.plus.mapmarkers.adapters.MapMarkersGroupsAdapter;
|
||||||
import net.osmand.plus.mapmarkers.SelectionMarkersGroupBottomSheetDialogFragment.AddMarkersGroupFragmentListener;
|
|
||||||
import net.osmand.plus.widgets.EmptyStateRecyclerView;
|
import net.osmand.plus.widgets.EmptyStateRecyclerView;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
@ -230,44 +231,59 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
|
||||||
Object item = adapter.getItem(pos);
|
Object item = adapter.getItem(pos);
|
||||||
if (item instanceof MapMarker) {
|
if (item instanceof MapMarker) {
|
||||||
MapMarker marker = (MapMarker) item;
|
MapMarker marker = (MapMarker) item;
|
||||||
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
if (!marker.history) {
|
if (!marker.history) {
|
||||||
if (mapActivity.getMyApplication().getSettings().SELECT_MARKER_ON_SINGLE_TAP.get()) {
|
if (app.getSettings().SELECT_MARKER_ON_SINGLE_TAP.get()) {
|
||||||
mapActivity.getMyApplication().getMapMarkersHelper().moveMarkerToTop(marker);
|
app.getMapMarkersHelper().moveMarkerToTop(marker);
|
||||||
updateAdapter();
|
updateAdapter();
|
||||||
} else {
|
} else {
|
||||||
WptPt wptPt = marker.wptPt;
|
FavouritePoint fav = marker.favouritePoint == null
|
||||||
FavouritePoint favouritePoint = marker.favouritePoint;
|
? app.getFavorites().getVisibleFavByLatLon(marker.point)
|
||||||
Object objectToShow;
|
: marker.favouritePoint;
|
||||||
PointDescription pointDescription;
|
if (fav != null) {
|
||||||
if (wptPt != null) {
|
showMap(marker.point, fav.getPointDescription(), fav);
|
||||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, wptPt.name);
|
return;
|
||||||
objectToShow = wptPt;
|
|
||||||
} else if (favouritePoint != null) {
|
|
||||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, favouritePoint.getName());
|
|
||||||
objectToShow = favouritePoint;
|
|
||||||
} else {
|
|
||||||
pointDescription = marker.getPointDescription(mapActivity);
|
|
||||||
objectToShow = marker;
|
|
||||||
}
|
}
|
||||||
mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
|
|
||||||
15, pointDescription, true, objectToShow);
|
WptPt pt = marker.wptPt == null
|
||||||
MapActivity.launchMapActivityMoveToTop(mapActivity);
|
? app.getSelectedGpxHelper().getVisibleWayPointByLatLon(marker.point)
|
||||||
((DialogFragment) getParentFragment()).dismiss();
|
: marker.wptPt;
|
||||||
|
if (pt != null) {
|
||||||
|
showMap(marker.point, pt.getPointDescription(mapActivity), pt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Amenity mapObj = mapActivity.getMapLayers().getMapMarkersLayer().getMapObjectByMarker(marker);
|
||||||
|
PointDescription desc = mapObj == null
|
||||||
|
? marker.getPointDescription(mapActivity)
|
||||||
|
: mapActivity.getMapLayers().getPoiMapLayer().getObjectName(mapObj);
|
||||||
|
showMap(marker.point, desc, mapObj == null ? marker : mapObj);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
HistoryMarkerMenuBottomSheetDialogFragment fragment = new HistoryMarkerMenuBottomSheetDialogFragment();
|
showHistoryMenuFragment(pos, marker);
|
||||||
fragment.setUsedOnMap(false);
|
|
||||||
Bundle arguments = new Bundle();
|
|
||||||
arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_POSITION, pos);
|
|
||||||
arguments.putString(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_NAME, marker.getName(mapActivity));
|
|
||||||
arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_COLOR_INDEX, marker.colorIndex);
|
|
||||||
arguments.putLong(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_VISITED_DATE, marker.visitedDate);
|
|
||||||
fragment.setArguments(arguments);
|
|
||||||
fragment.setListener(createHistoryMarkerMenuListener());
|
|
||||||
fragment.show(getChildFragmentManager(), HistoryMarkerMenuBottomSheetDialogFragment.TAG);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showMap(LatLon latLon, PointDescription desc, Object objToShow) {
|
||||||
|
mapActivity.getMyApplication().getSettings().setMapLocationToShow(latLon.getLatitude(),
|
||||||
|
latLon.getLongitude(), 15, desc, true, objToShow);
|
||||||
|
MapActivity.launchMapActivityMoveToTop(mapActivity);
|
||||||
|
((DialogFragment) getParentFragment()).dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showHistoryMenuFragment(int pos, MapMarker marker) {
|
||||||
|
HistoryMarkerMenuBottomSheetDialogFragment fragment = new HistoryMarkerMenuBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(false);
|
||||||
|
Bundle arguments = new Bundle();
|
||||||
|
arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_POSITION, pos);
|
||||||
|
arguments.putString(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_NAME, marker.getName(mapActivity));
|
||||||
|
arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_COLOR_INDEX, marker.colorIndex);
|
||||||
|
arguments.putLong(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_VISITED_DATE, marker.visitedDate);
|
||||||
|
fragment.setArguments(arguments);
|
||||||
|
fragment.setListener(createHistoryMarkerMenuListener());
|
||||||
|
fragment.show(getChildFragmentManager(), HistoryMarkerMenuBottomSheetDialogFragment.TAG);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,7 +40,8 @@ public class MarkerAction extends QuickAction {
|
||||||
activity.getMapActions().addMapMarker(
|
activity.getMapActions().addMapMarker(
|
||||||
latLon.getLatitude(),
|
latLon.getLatitude(),
|
||||||
latLon.getLongitude(),
|
latLon.getLongitude(),
|
||||||
pointDescription);
|
pointDescription,
|
||||||
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,13 +24,10 @@ import net.osmand.AndroidUtils;
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.NativeLibrary.RenderedObject;
|
import net.osmand.NativeLibrary.RenderedObject;
|
||||||
import net.osmand.RenderingContext;
|
import net.osmand.RenderingContext;
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadRect;
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.osm.PoiCategory;
|
|
||||||
import net.osmand.osm.PoiFilter;
|
import net.osmand.osm.PoiFilter;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
|
@ -627,7 +624,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
if (searchLatLon == null) {
|
if (searchLatLon == null) {
|
||||||
searchLatLon = tileBox.getLatLonFromPixel(point.x, point.y);
|
searchLatLon = tileBox.getLatLonFromPixel(point.x, point.y);
|
||||||
}
|
}
|
||||||
Amenity amenity = findAmenity(renderedObject.getId() >> 7, names, searchLatLon);
|
Amenity amenity = findAmenity(activity.getMyApplication(), renderedObject.getId() >> 7, names, searchLatLon);
|
||||||
if (amenity != null) {
|
if (amenity != null) {
|
||||||
if (renderedObject.getX() != null && renderedObject.getX().size() > 1
|
if (renderedObject.getX() != null && renderedObject.getX().size() > 1
|
||||||
&& renderedObject.getY() != null && renderedObject.getY().size() > 1) {
|
&& renderedObject.getY() != null && renderedObject.getY().size() > 1) {
|
||||||
|
@ -824,46 +821,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Amenity findAmenity(long id, List<String> names, LatLon latLon) {
|
|
||||||
QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 50);
|
|
||||||
List<Amenity> amenities = activity.getMyApplication().getResourceManager().searchAmenities(
|
|
||||||
new BinaryMapIndexReader.SearchPoiTypeFilter() {
|
|
||||||
@Override
|
|
||||||
public boolean accept(PoiCategory type, String subcategory) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}, rect.top, rect.left, rect.bottom, rect.right, -1, null);
|
|
||||||
|
|
||||||
Amenity res = null;
|
|
||||||
for (Amenity amenity : amenities) {
|
|
||||||
Long amenityId = amenity.getId() >> 1;
|
|
||||||
if (amenityId == id) {
|
|
||||||
res = amenity;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (res == null && names != null && names.size() > 0) {
|
|
||||||
for (Amenity amenity : amenities) {
|
|
||||||
for (String name : names) {
|
|
||||||
if (name.equals(amenity.getName())) {
|
|
||||||
res = amenity;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (res != null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hideVisibleMenues() {
|
private boolean hideVisibleMenues() {
|
||||||
if (multiSelectionMenu.isVisible()) {
|
if (multiSelectionMenu.isVisible()) {
|
||||||
multiSelectionMenu.hide();
|
multiSelectionMenu.hide();
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadPoint;
|
import net.osmand.data.QuadPoint;
|
||||||
|
@ -43,6 +44,7 @@ import net.osmand.plus.views.mapwidgets.MapMarkersWidgetsFactory;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
@ -518,20 +520,47 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
||||||
|
|
||||||
OsmandApplication app = map.getMyApplication();
|
OsmandApplication app = map.getMyApplication();
|
||||||
int r = getRadiusPoi(tileBox);
|
int r = getRadiusPoi(tileBox);
|
||||||
|
boolean selectMarkerOnSingleTap = app.getSettings().SELECT_MARKER_ON_SINGLE_TAP.get();
|
||||||
|
|
||||||
for (MapMarker marker : app.getMapMarkersHelper().getMapMarkers()) {
|
for (MapMarker marker : app.getMapMarkersHelper().getMapMarkers()) {
|
||||||
if ((!unknownLocation && app.getSettings().SELECT_MARKER_ON_SINGLE_TAP.get()) || !isSynced(marker)) {
|
if ((!unknownLocation && selectMarkerOnSingleTap) || !isSynced(marker)) {
|
||||||
LatLon latLon = marker.point;
|
LatLon latLon = marker.point;
|
||||||
if (latLon != null) {
|
if (latLon != null) {
|
||||||
int x = (int) tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
int x = (int) tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||||
int y = (int) tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
int y = (int) tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||||
|
|
||||||
if (calculateBelongs((int) point.x, (int) point.y, x, y, r)) {
|
if (calculateBelongs((int) point.x, (int) point.y, x, y, r)) {
|
||||||
o.add(marker);
|
if (!unknownLocation && selectMarkerOnSingleTap) {
|
||||||
|
o.add(marker);
|
||||||
|
} else {
|
||||||
|
if (isMarkerOnFavorite(marker) || isMarkerOnWaypoint(marker)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Amenity mapObj = getMapObjectByMarker(marker);
|
||||||
|
o.add(mapObj == null ? marker : mapObj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isMarkerOnWaypoint(@NonNull MapMarker marker) {
|
||||||
|
return marker.point != null && map.getMyApplication().getSelectedGpxHelper().getVisibleWayPointByLatLon(marker.point) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isMarkerOnFavorite(@NonNull MapMarker marker) {
|
||||||
|
return marker.point != null && map.getMyApplication().getFavorites().getVisibleFavByLatLon(marker.point) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
|
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
|
||||||
return Math.abs(objx - ex) <= radius && (ey - objy) <= radius && (objy - ey) <= 2.5 * radius;
|
return Math.abs(objx - ex) <= radius && (ey - objy) <= radius && (objy - ey) <= 2.5 * radius;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,16 @@ import android.graphics.PointF;
|
||||||
import android.graphics.PorterDuff.Mode;
|
import android.graphics.PorterDuff.Mode;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.QuadTree;
|
import net.osmand.data.QuadTree;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -28,6 +30,7 @@ import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||||
import net.osmand.render.RenderingRuleSearchRequest;
|
import net.osmand.render.RenderingRuleSearchRequest;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
import net.osmand.util.MapAlgorithms;
|
import net.osmand.util.MapAlgorithms;
|
||||||
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -218,6 +221,46 @@ public abstract class OsmandMapLayer {
|
||||||
return rf;
|
return rf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Amenity findAmenity(OsmandApplication app, long id, List<String> names, LatLon latLon) {
|
||||||
|
QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 50);
|
||||||
|
List<Amenity> amenities = app.getResourceManager().searchAmenities(
|
||||||
|
new BinaryMapIndexReader.SearchPoiTypeFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(PoiCategory type, String subcategory) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}, rect.top, rect.left, rect.bottom, rect.right, -1, null);
|
||||||
|
|
||||||
|
Amenity res = null;
|
||||||
|
for (Amenity amenity : amenities) {
|
||||||
|
Long amenityId = amenity.getId() >> 1;
|
||||||
|
if (amenityId == id) {
|
||||||
|
res = amenity;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res == null && names != null && names.size() > 0) {
|
||||||
|
for (Amenity amenity : amenities) {
|
||||||
|
for (String name : names) {
|
||||||
|
if (name.equals(amenity.getName())) {
|
||||||
|
res = amenity;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res != null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract class MapLayerData<T> {
|
public abstract class MapLayerData<T> {
|
||||||
public int ZOOM_THRESHOLD = 1;
|
public int ZOOM_THRESHOLD = 1;
|
||||||
public RotatedTileBox queriedBox;
|
public RotatedTileBox queriedBox;
|
||||||
|
|
Loading…
Reference in a new issue