Class CMScaleBar extends CMItem
CMScaleBar
Class to render a scale bar into the scene. The scale bar will be automatically
repainted with the scale based on its position in the scene.
The algorithm is to find the two points at either end of the rectangle provided
for the scale bar and convert these points to geographic coordinates. Then,
a great arc calculation is performed to find the distance between the points.
The scale displayed is then found by reducing this distance to an even multiple
of 1, 2, or 5. If this distance does not fit in the area provided (including the
the labels), the next smaller distance is computed. This continues until a distance
is found that fits.
Note that the scale bar is placed into a DIV in the map container. Thus is uses a
CSS style (CM_ScaleBar) for the style of the containing box. The contents of the
DIV are drawn in a Canvas element.
Settings
TextStyle - used to write the text above the ticks on the scale bar
Enumerated Types
CMScaleBar.UNITS_ISO=0 - meters, kilometers
CMScaleBar.UNITS_ENGLISH=1 - feet, miles
Settings Group: ScaleBar
Setting |
Name |
Type |
Options |
Default |
Comments |
ClassName |
Class Name |
CMTYPE_STRING |
|
CM_ScaleBar |
|
Settings Group: UnitText
Setting |
Name |
Type |
Options |
Default |
Comments |
Text |
Text |
CMTYPE_STRING |
|
null |
|
font |
Font |
CMTYPE_FONT |
|
12px Arial |
|
strokeStyle |
Line Style |
CMTYPE_CSS_STYLE |
|
rgb(0,0,0) |
|
fillStyle |
Fill Style |
CMTYPE_CSS_STYLE |
|
rgb(255,255,255) |
|
lineWidth |
Width |
CMTYPE_INTEGER |
|
1 |
|
lineCap |
Line Cap |
CMTYPE_ENUMERATED |
butt, round, square |
round |
|
lineJoin |
Line Join |
CMTYPE_ENUMERATED |
bevel, round, miter |
round |
|
Settings Group: Factors
ScaleBarStyle |
Scale Bar Style |
CMTYPE_OBJECT |
|
|
style of the actual bar |
BoxStyle |
Box Style |
CMTYPE_OBJECT |
|
|
style of the actual bar |