From 19146b21eb3f11df2b98c8799e65c495b767dbb5 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 8 Apr 2016 19:07:12 +0300 Subject: [PATCH] Fix AND-451 3/4 --- .../osmand/plus/views/MapMarkersLayer.java | 49 +++++++++++-------- .../mapwidgets/MapMarkersWidgetsFactory.java | 4 ++ 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java index f7f7f21194..26b77d835c 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java @@ -21,6 +21,7 @@ import net.osmand.data.RotatedTileBox; import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndConstants; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.activities.MapActivity; @@ -263,26 +264,34 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi } } - boolean show = useFingerLocation && map.getMyApplication().getSettings().SHOW_DESTINATION_ARROW.get(); - if (show && fingerLocation != null) { - List sortedMapMarkers = markersHelper.getSortedMapMarkers(); - int i = 0; - for (MapMarker marker : sortedMapMarkers) { - if (!isLocationVisible(tb, marker)) { - canvas.save(); - net.osmand.Location.distanceBetween(fingerLocation.getLatitude(), fingerLocation.getLongitude(), - marker.getLatitude(), marker.getLongitude(), calculations); - float bearing = calculations[1] - 90; - float radiusBearing = DIST_TO_SHOW * tb.getDensity(); - final QuadPoint cp = tb.getCenterPixelPoint(); - canvas.rotate(bearing, cp.x, cp.y); - canvas.translate(-24 * tb.getDensity() + radiusBearing, -22 * tb.getDensity()); - canvas.drawBitmap(arrowToDestination, cp.x, cp.y, getMarkerDestPaint(marker.colorIndex)); - canvas.restore(); - } - i++; - if (i > 1) { - break; + boolean show = useFingerLocation || + (map.getMyApplication().getSettings().MAP_MARKERS_MODE.get() == OsmandSettings.MapMarkersMode.WIDGETS + && map.getMyApplication().getSettings().SHOW_DESTINATION_ARROW.get()); + if (show) { + LatLon loc = fingerLocation; + if (!useFingerLocation) { + loc = tb.getCenterLatLon(); + } + if (loc != null) { + List sortedMapMarkers = markersHelper.getSortedMapMarkers(); + int i = 0; + for (MapMarker marker : sortedMapMarkers) { + if (!isLocationVisible(tb, marker)) { + canvas.save(); + net.osmand.Location.distanceBetween(loc.getLatitude(), loc.getLongitude(), + marker.getLatitude(), marker.getLongitude(), calculations); + float bearing = calculations[1] - 90; + float radiusBearing = DIST_TO_SHOW * tb.getDensity(); + final QuadPoint cp = tb.getCenterPixelPoint(); + canvas.rotate(bearing, cp.x, cp.y); + canvas.translate(-24 * tb.getDensity() + radiusBearing, -22 * tb.getDensity()); + canvas.drawBitmap(arrowToDestination, cp.x, cp.y, getMarkerDestPaint(marker.colorIndex)); + canvas.restore(); + } + i++; + if (i > 1) { + break; + } } } } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java index 1e6ffc60a2..5f919cf716 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java @@ -234,6 +234,10 @@ public class MapMarkersWidgetsFactory { Location.distanceBetween(marker.getLatitude(), marker.getLongitude(), loc.getLatitude(), loc.getLongitude(), mes); } + if (customLocation) { + heading = 0f; + } + boolean newImage = false; DirectionDrawable dd; if (!(arrowImg.getDrawable() instanceof DirectionDrawable)) {