Fix inaccuracy in the display of circles after zoom; fix the calculation of the distance if the map is tied to the location
This commit is contained in:
parent
52c395b90e
commit
24d4109dc1
2 changed files with 22 additions and 10 deletions
|
@ -208,7 +208,7 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
boolean move = tb.getZoom() != cacheIntZoom || Math.abs(tb.getCenterTileX() - cacheTileX) > 1 ||
|
||||
Math.abs(tb.getCenterTileY() - cacheTileY) > 1;
|
||||
|
||||
if (!mapActivity.getMapView().isZooming() && move) {
|
||||
if (!tb.isZoomAnimated() && move) {
|
||||
cacheIntZoom = tb.getZoom();
|
||||
cacheTileX = tb.getCenterTileX();
|
||||
cacheTileY = tb.getCenterTileY();
|
||||
|
|
|
@ -207,8 +207,12 @@ public class MapInfoWidgetsFactory {
|
|||
LatLon centerLoc = map.getMapLocation();
|
||||
|
||||
if (currentLoc != null && centerLoc != null) {
|
||||
setDistanceText(currentLoc.getLatitude(), currentLoc.getLongitude(),
|
||||
centerLoc.getLatitude(), centerLoc.getLongitude());
|
||||
if (map.getMapViewTrackingUtilities().isMapLinkedToLocation()) {
|
||||
setDistanceText(0);
|
||||
} else {
|
||||
setDistanceText(currentLoc.getLatitude(), currentLoc.getLongitude(),
|
||||
centerLoc.getLatitude(), centerLoc.getLongitude());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setText(title, null);
|
||||
|
@ -216,13 +220,21 @@ public class MapInfoWidgetsFactory {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void setDistanceText(double firstLat, double firstLon, double secondLat, double secondLon) {
|
||||
float dist = (float) MapUtils.getDistance(firstLat, firstLon, secondLat, secondLon);
|
||||
String distance = OsmAndFormatter.getFormattedDistance(dist, map.getMyApplication());
|
||||
int ls = distance.lastIndexOf(' ');
|
||||
setText(distance.substring(0, ls), distance.substring(ls + 1));
|
||||
}
|
||||
};
|
||||
private void setDistanceText(float dist) {
|
||||
calculateAndSetText(dist);
|
||||
}
|
||||
|
||||
private void setDistanceText(double firstLat, double firstLon, double secondLat, double secondLon) {
|
||||
float dist = (float) MapUtils.getDistance(firstLat, firstLon, secondLat, secondLon);
|
||||
calculateAndSetText(dist);
|
||||
}
|
||||
|
||||
private void calculateAndSetText(float dist) {
|
||||
String distance = OsmAndFormatter.getFormattedDistance(dist, map.getMyApplication());
|
||||
int ls = distance.lastIndexOf(' ');
|
||||
setText(distance.substring(0, ls), distance.substring(ls + 1));
|
||||
}
|
||||
};
|
||||
|
||||
rulerControl.setText(title, null);
|
||||
setRulerControlIcon(rulerControl, map.getMyApplication().getSettings().RULER_MODE.get());
|
||||
|
|
Loading…
Reference in a new issue