Set first Map marker as destination. Fix marker deletion

This commit is contained in:
Alexey Kulish 2016-02-17 22:25:51 +03:00
parent 58b198c34b
commit 874ae6955e
3 changed files with 28 additions and 2 deletions

View file

@ -1721,8 +1721,12 @@ public class OsmandSettings {
List<Integer> ns = getPositions(ps.size());
ps.remove(index);
ds.remove(index);
if (cs.size() > index) {
cs.remove(index);
}
if (ns.size() > index) {
ns.remove(index);
}
return savePoints(ps, ds, cs, ns);
}

View file

@ -598,6 +598,9 @@ public class MapActivityActions implements DialogProvider {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
if (settings.USE_MAP_MARKERS.get()) {
setFirstMapMarkerAsTarget();
}
enterRoutePlanningMode(null, null);
} else {
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
@ -853,4 +856,17 @@ public class MapActivityActions implements DialogProvider {
});
}
public void setFirstMapMarkerAsTarget() {
if (getMyApplication().getMapMarkersHelper().getMapMarkersPositions().size() > 0) {
MapMarkersHelper.MapMarker marker = getMyApplication().getMapMarkersHelper().getMapMarkersPositions().get(0);
PointDescription pointDescription = marker.getOriginalPointDescription();
if (pointDescription.isLocation()
&& pointDescription.getName().equals(PointDescription.getAddressNotFoundStr(mapActivity))) {
pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
}
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
targets.navigateToPoint(new LatLon(marker.getLatitude(), marker.getLongitude()),
true, targets.getIntermediatePoints().size() + 1, pointDescription);
}
}
}

View file

@ -28,8 +28,11 @@ import net.londatiga.android.QuickAction;
import net.osmand.AndroidUtils;
import net.osmand.core.android.MapRendererContext;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@ -386,6 +389,9 @@ public class MapControlsLayer extends OsmandMapLayer {
MapActivity.clearPrevActivityIntent();
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
if (settings.USE_MAP_MARKERS.get()) {
mapActivity.getMapActions().setFirstMapMarkerAsTarget();
}
mapActivity.getMapActions().enterRoutePlanningMode(null, null);
} else {
showRouteInfoControlDialog();