Cancel snap to road after selecting default app mode

This commit is contained in:
Alex 2017-10-11 15:34:49 +03:00
parent bb34542043
commit 833aebd171

View file

@ -408,9 +408,13 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
@Override @Override
public void onApplicationModeItemClick(ApplicationMode mode) { public void onApplicationModeItemClick(ApplicationMode mode) {
if (planRouteContext.getSnappedMode() != mode) { if (planRouteContext.getSnappedMode() != mode) {
boolean defaultMode = mode == ApplicationMode.DEFAULT;
MapMarkersLayer layer = getMapMarkersLayer(); MapMarkersLayer layer = getMapMarkersLayer();
if (layer != null) { if (layer != null) {
layer.setDefaultAppMode(mode == ApplicationMode.DEFAULT); layer.setDefaultAppMode(defaultMode);
}
if (defaultMode) {
planRouteContext.cancelSnapToRoad();
} }
planRouteContext.getSnappedToRoadPoints().clear(); planRouteContext.getSnappedToRoadPoints().clear();
planRouteContext.setSnappedMode(mode); planRouteContext.setSnappedMode(mode);
@ -731,6 +735,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
mapActivity.getMapLayers().getMapMarkersLayer().setRoute(planRouteContext.getSnapTrkSegment()); mapActivity.getMapLayers().getMapMarkersLayer().setRoute(planRouteContext.getSnapTrkSegment());
mapActivity.refreshMap();
if (adjustMap) { if (adjustMap) {
showRouteOnMap(planRouteContext.getSnapTrkSegment().points); showRouteOnMap(planRouteContext.getSnapTrkSegment().points);
} }