also update on scale changes
This commit is contained in:
parent
18fdbd07d7
commit
c682ae518c
@ -71,6 +71,7 @@ public class MapScaleBar extends Layer {
|
|||||||
private final Canvas mMapScaleCanvas;
|
private final Canvas mMapScaleCanvas;
|
||||||
private boolean mRedrawNeeded;
|
private boolean mRedrawNeeded;
|
||||||
private double mPrevLatitude = -1;
|
private double mPrevLatitude = -1;
|
||||||
|
private final double mPrevScale = -1;
|
||||||
private final Map<TextField, String> mTextFields;
|
private final Map<TextField, String> mTextFields;
|
||||||
|
|
||||||
/* private */final Bitmap mMapScaleBitmap;
|
/* private */final Bitmap mMapScaleBitmap;
|
||||||
@ -125,16 +126,18 @@ public class MapScaleBar extends Layer {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(MapPosition mapPosition, boolean changed) {
|
public void onUpdate(MapPosition mapPosition, boolean changed) {
|
||||||
double latitude = MercatorProjection.toLatitude(mapPosition.y);
|
double latitude = MercatorProjection.toLatitude(mapPosition.y);
|
||||||
|
|
||||||
if (!mRedrawNeeded) {
|
if (!mRedrawNeeded) {
|
||||||
|
double scaleDiff = mPrevScale / mapPosition.scale;
|
||||||
|
if (scaleDiff < 1.1 && scaleDiff > 0.9) {
|
||||||
double latitudeDiff = Math.abs(mPrevLatitude - latitude);
|
double latitudeDiff = Math.abs(mPrevLatitude - latitude);
|
||||||
if (latitudeDiff < LATITUDE_REDRAW_THRESHOLD)
|
if (latitudeDiff < LATITUDE_REDRAW_THRESHOLD)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mPrevLatitude = latitude;
|
mPrevLatitude = latitude;
|
||||||
|
|
||||||
double groundResolution = MercatorProjection.calculateGroundResolution(
|
double groundResolution = MercatorProjection.calculateGroundResolution(
|
||||||
@ -166,7 +169,6 @@ public class MapScaleBar extends Layer {
|
|||||||
mRedrawNeeded = false;
|
mRedrawNeeded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if imperial units are used, false otherwise.
|
* @return true if imperial units are used, false otherwise.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user