From ae707c7f9b12bf27015802d217dae4821a8c4e40 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 7 Aug 2013 20:54:20 +0200 Subject: [PATCH] Add reroute function to plugin --- .../osmand/plus/osmodroid/OsMoDroidPlugin.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/osmodroid/OsMoDroidPlugin.java b/OsmAnd/src/net/osmand/plus/osmodroid/OsMoDroidPlugin.java index bf20abf665..fe66b522a9 100644 --- a/OsmAnd/src/net/osmand/plus/osmodroid/OsMoDroidPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmodroid/OsMoDroidPlugin.java @@ -3,12 +3,14 @@ package net.osmand.plus.osmodroid; import java.util.ArrayList; import net.osmand.PlatformUtil; +import net.osmand.data.LatLon; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.NavigationService; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; +import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.views.MonitoringInfoControl; import net.osmand.plus.views.MonitoringInfoControl.MonitoringInfoControlServices; @@ -56,6 +58,19 @@ public class OsMoDroidPlugin extends OsmandPlugin implements MonitoringInfoContr } } + + public void reRouteTo(LatLon loc) { + OsmandApplication app = activity.getMyApplication(); + TargetPointsHelper targets = app.getTargetPointsHelper(); + // If we are in following mode then just update target point + targets.navigateToPoint(loc, true, -1); + if(!app.getRoutingHelper().isFollowingMode()) { + // If we are not in following mode then request new route to calculate + // Use default application mode + activity.followRoute(app.getSettings().getApplicationMode(), targets.getPointToNavigate(), targets.getIntermediatePoints(), + app.getLastKnownLocation(), null); + } + } };