Show whole route after calculation
This commit is contained in:
parent
36c684d443
commit
c5515dd5ff
4 changed files with 41 additions and 2 deletions
|
@ -460,6 +460,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
// save application mode controls
|
// save application mode controls
|
||||||
settings.FOLLOW_THE_ROUTE.set(false);
|
settings.FOLLOW_THE_ROUTE.set(false);
|
||||||
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
||||||
|
app.getRoutingHelper().setGpxParams(null);
|
||||||
app.getRoutingHelper().setFollowingMode(false);
|
app.getRoutingHelper().setFollowingMode(false);
|
||||||
app.getRoutingHelper().setRoutePlanningMode(true);
|
app.getRoutingHelper().setRoutePlanningMode(true);
|
||||||
targets.setStartPoint(from, false, fromName);
|
targets.setStartPoint(from, false, fromName);
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package net.osmand.plus.base;
|
package net.osmand.plus.base;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.map.IMapLocationListener;
|
import net.osmand.map.IMapLocationListener;
|
||||||
import net.osmand.plus.OsmAndConstants;
|
import net.osmand.plus.OsmAndConstants;
|
||||||
|
@ -13,13 +16,14 @@ import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
|
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, OsmAndCompassListener {
|
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, OsmAndCompassListener, IRouteInformationListener {
|
||||||
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
|
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
|
||||||
|
|
||||||
private long lastTimeAutoZooming = 0;
|
private long lastTimeAutoZooming = 0;
|
||||||
|
@ -39,6 +43,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
app.getLocationProvider().addLocationListener(this);
|
app.getLocationProvider().addLocationListener(this);
|
||||||
app.getLocationProvider().addCompassListener(this);
|
app.getLocationProvider().addCompassListener(this);
|
||||||
addTargetPointListener(app);
|
addTargetPointListener(app);
|
||||||
|
app.getRoutingHelper().addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTargetPointListener(OsmandApplication app) {
|
private void addTargetPointListener(OsmandApplication app) {
|
||||||
|
@ -274,4 +279,36 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void newRouteIsCalculated(boolean newRoute) {
|
||||||
|
RoutingHelper rh = app.getRoutingHelper();
|
||||||
|
if(newRoute && rh.isRoutePlanningMode()) {
|
||||||
|
RotatedTileBox rt = mapView.getCurrentRotatedTileBox();
|
||||||
|
Location lt = rh.getLastProjection();
|
||||||
|
if(lt != null) {
|
||||||
|
double left = lt.getLongitude(), right = lt.getLongitude();
|
||||||
|
double top = lt.getLatitude(), bottom = lt.getLatitude();
|
||||||
|
List<LatLon> list = app.getTargetPointsHelper().getIntermediatePointsWithTarget();
|
||||||
|
for(LatLon l : list) {
|
||||||
|
left = Math.min(left, l.getLongitude());
|
||||||
|
right = Math.max(left, l.getLongitude());
|
||||||
|
top = Math.max(top, l.getLatitude());
|
||||||
|
bottom = Math.min(bottom, l.getLatitude());
|
||||||
|
}
|
||||||
|
RotatedTileBox tb = new RotatedTileBox(rt);
|
||||||
|
tb.setPixelDimensions(2 * tb.getPixWidth() / 3, 2 * tb.getPixHeight() / 3);
|
||||||
|
tb.setLatLonCenter(bottom / 2 + top / 2, left / 2 + right / 2);
|
||||||
|
while(tb.getZoom() >= 7 && (!tb.containsLatLon(top, left) || !tb.containsLatLon(bottom, right))) {
|
||||||
|
tb.setZoom(tb.getZoom() - 1);
|
||||||
|
}
|
||||||
|
mapView.getAnimatedDraggingThread().startMoving(tb.getLatitude(), tb.getLongitude(), tb.getZoom(),
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void routeWasCancelled() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
|
import net.osmand.data.RotatedTileBox.RotatedTileBoxBuilder;
|
||||||
import net.osmand.plus.OsmAndLocationProvider;
|
import net.osmand.plus.OsmAndLocationProvider;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -16,7 +17,6 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.ShowRouteInfoActivity;
|
import net.osmand.plus.activities.ShowRouteInfoActivity;
|
||||||
import net.osmand.plus.routing.RouteDirectionInfo;
|
import net.osmand.plus.routing.RouteDirectionInfo;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
|
||||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||||
import net.osmand.plus.views.ContextMenuLayer;
|
import net.osmand.plus.views.ContextMenuLayer;
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||||
|
|
|
@ -318,6 +318,7 @@ public class MapRoutePreferencesControl extends MapControls {
|
||||||
loc = ps.get(0);
|
loc = ps.get(0);
|
||||||
tg.setStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()), false, null);
|
tg.setStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()), false, null);
|
||||||
}
|
}
|
||||||
|
tg.updateRoutingHelper();
|
||||||
}
|
}
|
||||||
mapActivity.getRoutingHelper().setGpxParams(params);
|
mapActivity.getRoutingHelper().setGpxParams(params);
|
||||||
settings.FOLLOW_THE_GPX_ROUTE.set(result.path);
|
settings.FOLLOW_THE_GPX_ROUTE.set(result.path);
|
||||||
|
|
Loading…
Reference in a new issue