
public class ScaleBarOverlay extends Overlay implements GeoConstants
MapView map = new MapView(...);
ScaleBarOverlay scaleBar = new ScaleBarOverlay(map); // Thiw is an important change of calling!
map.getOverlays().add(scaleBar);
To Do List:
1. Allow for top, bottom, left or right placement. // done in this changement
2. Scale bar to precise displayed scale text after rounding.| Modifier and Type | Class and Description |
|---|---|
static class |
ScaleBarOverlay.UnitsOfMeasure |
Overlay.SnappableGeoConstants.UnitOfMeasure| Modifier and Type | Field and Description |
|---|---|
protected boolean |
alignBottom |
protected boolean |
alignRight |
protected Path |
barPath |
(package private) boolean |
latitudeBar |
protected Rect |
latitudeBarRect |
(package private) boolean |
longitudeBar |
protected Rect |
longitudeBarRect |
(package private) double |
minZoom |
int |
screenHeight |
int |
screenWidth |
(package private) ScaleBarOverlay.UnitsOfMeasure |
unitsOfMeasure |
float |
xdpi |
(package private) int |
xOffset |
float |
ydpi |
(package private) int |
yOffset |
mBounds, SHADOW_X_SKEW, SHADOW_Y_SCALEEQUATORCIRCUMFENCE, FEET_PER_METER, METERS_PER_NAUTICAL_MILE, METERS_PER_STATUTE_MILE, RADIUS_EARTH_METERSDEFAULT_ZOOMLEVEL_MINIMAP_DIFFERENCE, NOT_SET| Constructor and Description |
|---|
ScaleBarOverlay(Context pContext,
int pMapWidth,
int pMapHeight) |
ScaleBarOverlay(MapView mapView) |
| Modifier and Type | Method and Description |
|---|---|
void |
disableScaleBar() |
void |
draw(Canvas c,
Projection projection) |
void |
drawLatitudeScale(boolean latitude)
Latitudinal / horizontal scale bar flag
|
void |
drawLongitudeScale(boolean longitude)
Longitudinal / vertical scale bar flag
|
void |
enableScaleBar() |
Paint |
getBarPaint()
Return's the paint used to draw the bar
|
static String |
getScaleString(Context pContext,
String pValue,
GeoConstants.UnitOfMeasure pUnitOfMeasure) |
Paint |
getTextPaint()
Returns the paint used to draw the text
|
ScaleBarOverlay.UnitsOfMeasure |
getUnitsOfMeasure()
Gets the units of measure to be shown in the scale bar
|
void |
onDetach(MapView mapView)
Override to perform clean up of resources before shutdown.
|
protected void |
rebuildBarPath(Projection projection) |
protected String |
scaleBarLengthText(double meters) |
void |
setAlignBottom(boolean alignBottom) |
void |
setAlignRight(boolean alignRight) |
void |
setBackgroundPaint(Paint pBgPaint)
Sets the background paint.
|
void |
setBarPaint(Paint pBarPaint)
Sets the paint for drawing the bar
|
void |
setCentred(boolean centred)
Flag to draw the bar centered around the set offset coordinates or to the right/bottom of the
coordinates (default)
|
void |
setEnableAdjustLength(boolean adjustLength)
If enabled, the bar will automatically adjust the length to reflect a round number (starting
with 1, 2 or 5).
|
void |
setLineWidth(float width)
Sets the bar's line width.
|
void |
setMaxLength(float pMaxLengthInCm)
Sets the maximum bar length.
|
void |
setMinZoom(double zoom)
Sets the minimum zoom level for the scale bar to be drawn.
|
void |
setScaleBarOffset(int x,
int y)
Sets the scale bar screen offset for the bar.
|
void |
setTextPaint(Paint pTextPaint)
Sets the paint for drawing the text
|
void |
setTextSize(float size)
Sets the text size.
|
void |
setUnitsOfMeasure(ScaleBarOverlay.UnitsOfMeasure unitsOfMeasure)
Sets the units of measure to be shown in the scale bar
|
draw, drawAt, getBounds, getSafeMenuId, getSafeMenuIdSequence, isEnabled, onDoubleTap, onDoubleTapEvent, onDown, onFling, onKeyDown, onKeyUp, onLongPress, onPause, onResume, onScroll, onShowPress, onSingleTapConfirmed, onSingleTapUp, onTouchEvent, onTrackballEvent, setEnabledint xOffset
int yOffset
double minZoom
ScaleBarOverlay.UnitsOfMeasure unitsOfMeasure
boolean latitudeBar
boolean longitudeBar
protected boolean alignBottom
protected boolean alignRight
protected final Path barPath
protected final Rect latitudeBarRect
protected final Rect longitudeBarRect
public float xdpi
public float ydpi
public int screenWidth
public int screenHeight
public ScaleBarOverlay(MapView mapView)
public ScaleBarOverlay(Context pContext, int pMapWidth, int pMapHeight)
public void setMinZoom(double zoom)
zoom - minimum zoom levelpublic void setScaleBarOffset(int x,
int y)
x - x screen offsety - z screen offsetpublic void setLineWidth(float width)
width - the new line widthpublic void setTextSize(float size)
size - the new text sizepublic void setUnitsOfMeasure(ScaleBarOverlay.UnitsOfMeasure unitsOfMeasure)
public ScaleBarOverlay.UnitsOfMeasure getUnitsOfMeasure()
public void drawLatitudeScale(boolean latitude)
latitude - public void drawLongitudeScale(boolean longitude)
longitude - public void setCentred(boolean centred)
centred - set true to centre the bar around the given screen coordinatespublic void setAlignBottom(boolean alignBottom)
public void setAlignRight(boolean alignRight)
public Paint getBarPaint()
public void setBarPaint(Paint pBarPaint)
pBarPaint - bar drawing paintpublic Paint getTextPaint()
public void setTextPaint(Paint pTextPaint)
pTextPaint - text drawing paintpublic void setBackgroundPaint(Paint pBgPaint)
pBgPaint - the paint for colouring the bar backgroundpublic void setEnableAdjustLength(boolean adjustLength)
public void setMaxLength(float pMaxLengthInCm)
pMaxLengthInCm - maximum length of the bar in the screen in cm. Default is 2.54 (=1 inch)public void draw(Canvas c, Projection projection)
public void disableScaleBar()
public void enableScaleBar()
protected void rebuildBarPath(Projection projection)
protected String scaleBarLengthText(double meters)
public void onDetach(MapView mapView)
Overlaypublic static String getScaleString(Context pContext, String pValue, GeoConstants.UnitOfMeasure pUnitOfMeasure)