From fee84d47a74a1b50513bb7d33d1048afc99386c2 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 22 Sep 2017 19:13:18 +0300 Subject: [PATCH] Fix drawing distance between two fingers after map rotation --- .../net/osmand/plus/views/RulerControlLayer.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/RulerControlLayer.java b/OsmAnd/src/net/osmand/plus/views/RulerControlLayer.java index 4e215663ef..fd1b9db487 100644 --- a/OsmAnd/src/net/osmand/plus/views/RulerControlLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/RulerControlLayer.java @@ -246,21 +246,23 @@ public class RulerControlLayer extends OsmandMapLayer { } private void drawTwoFingersDistance(Canvas canvas, RotatedTileBox tb, LatLon firstTouch, LatLon secondTouch, boolean nightMode) { - float x1 = tb.getPixXFromLonNoRot(firstTouch.getLongitude()); - float y1 = tb.getPixYFromLatNoRot(firstTouch.getLatitude()); - float x2 = tb.getPixXFromLonNoRot(secondTouch.getLongitude()); - float y2 = tb.getPixYFromLatNoRot(secondTouch.getLatitude()); + float x1 = tb.getPixXFromLatLon(firstTouch.getLatitude(), firstTouch.getLongitude()); + float y1 = tb.getPixYFromLatLon(firstTouch.getLatitude(), firstTouch.getLongitude()); + float x2 = tb.getPixXFromLatLon(secondTouch.getLatitude(), secondTouch.getLongitude()); + float y2 = tb.getPixYFromLatLon(secondTouch.getLatitude(), secondTouch.getLongitude()); Path path = new Path(); path.moveTo(x1, y1); path.lineTo(x2, y2); + String text = OsmAndFormatter.getFormattedDistance((float) MapUtils.getDistance(firstTouch, secondTouch), app); + + canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); canvas.drawPath(path, lineAttrs.paint); drawFingerTouchIcon(canvas, x1, y1, nightMode); drawFingerTouchIcon(canvas, x2, y2, nightMode); - - String text = OsmAndFormatter.getFormattedDistance((float) MapUtils.getDistance(firstTouch, secondTouch), app); drawTextOnCenterOfPath(canvas, x1, x2, path, text); + canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); } private void drawTextOnCenterOfPath(Canvas canvas, float x1, float x2, Path path, String text) {