diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java index 3fb0ef7c7e..2a2a869ff6 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java @@ -249,23 +249,6 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL tx.reset(); ty.reset(); - int leftPointPos = -1; - for (int i = 0; i < measurementPoints.size(); i++) { - WptPt pt = measurementPoints.get(i); - if (tb.containsLatLon(pt.lat, pt.lon)) { - leftPointPos = i; - break; - } - } - int rightPointPos = -1; - for (int i = measurementPoints.size() - 1; i >= leftPointPos; i--) { - WptPt pt = measurementPoints.get(i); - if (tb.containsLatLon(pt.lat, pt.lon)) { - rightPointPos = i; - break; - } - } - for (int i = 0; i < measurementPoints.size(); i++) { WptPt pt = measurementPoints.get(i); int locX; @@ -321,6 +304,23 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL calculatePath(tb, tx, ty, path); canvas.drawPath(path, lineAttrs.paint); + int leftPointPos = -1; + for (int i = 0; i < measurementPoints.size(); i++) { + WptPt pt = measurementPoints.get(i); + if (tb.containsLatLon(pt.lat, pt.lon)) { + leftPointPos = i; + break; + } + } + int rightPointPos = -1; + for (int i = measurementPoints.size() - 1; i >= leftPointPos; i--) { + WptPt pt = measurementPoints.get(i); + if (tb.containsLatLon(pt.lat, pt.lon)) { + rightPointPos = i; + break; + } + } + if (leftPointPos != -1 && rightPointPos != -1) { int pointToDraw = rightPointPos - leftPointPos; int step = 1;