This commit is contained in:
Victor Shcherb 2016-08-17 11:20:13 +02:00
parent 1572accd18
commit 79fe50cd2f
2 changed files with 18 additions and 3 deletions

View file

@ -38,6 +38,11 @@ public class CurrentPositionHelper {
this.app = app; this.app = app;
} }
public Location getLastAskedLocation() {
return lastAskedLocation;
}
public boolean getRouteSegment(Location loc, ResultMatcher<RouteDataObject> result) { public boolean getRouteSegment(Location loc, ResultMatcher<RouteDataObject> result) {
return scheduleRouteSegmentFind(loc, false, null, result); return scheduleRouteSegmentFind(loc, false, null, result);
} }
@ -245,7 +250,7 @@ public class CurrentPositionHelper {
}); });
} }
private static double getOrthogonalDistance(RouteDataObject r, Location loc){ public static double getOrthogonalDistance(RouteDataObject r, Location loc){
double d = 1000; double d = 1000;
if (r.getPointsLength() > 0) { if (r.getPointsLength() > 0) {
double pLt = MapUtils.get31LatitudeY(r.getPoint31YTile(0)); double pLt = MapUtils.get31LatitudeY(r.getPoint31YTile(0));

View file

@ -15,6 +15,7 @@ import android.widget.TextView;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.ValueHolder; import net.osmand.ValueHolder;
import net.osmand.binary.RouteDataObject; import net.osmand.binary.RouteDataObject;
import net.osmand.plus.CurrentPositionHelper;
import net.osmand.plus.NavigationService; import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider;
@ -37,6 +38,7 @@ import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget.TurnDrawable; import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget.TurnDrawable;
import net.osmand.router.TurnType; import net.osmand.router.TurnType;
import net.osmand.util.Algorithms;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
@ -584,8 +586,16 @@ public class MapInfoWidgetsFactory {
if (text == null) { if (text == null) {
text = ""; text = "";
} else { } else {
type[0] = TurnType.valueOf(TurnType.C, false); if(!Algorithms.isEmpty(text) && locationProvider.getLastKnownLocation() != null) {
turnDrawable.setColor(R.color.color_myloc_distance); double dist =
CurrentPositionHelper.getOrthogonalDistance(rt, locationProvider.getLastKnownLocation());
if(dist < 50) {
type[0] = TurnType.valueOf(TurnType.C, false);
turnDrawable.setColor(R.color.color_myloc_distance);
} else {
text = map.getResources().getString(R.string.shared_string_near) + " " + text;
}
}
} }
} }
if (map.isTopToolbarActive()) { if (map.isTopToolbarActive()) {