Constructor
new ScaleBarView()
- Since:
- Source:
Extends
Members
className :string
The HTML classes to use for this view's element
Type:
- Source:
classes :object
Classes that will be used to select elements from the template that will be
updated with new coordinates and scale.
Type:
Properties:
Name |
Type |
Description |
longitude |
string
|
The element that will contain the longitude
measurement |
latitude |
string
|
The element that will contain the latitude
measurement |
elevation |
string
|
The element that will contain the elevation
measurement |
bar |
string
|
The element that will be used as a scale bar |
distance |
string
|
The element that will contain the distance
measurement |
- Source:
distances :Array.<number>
Allowed values for the displayed distance measurement in the scale bar. The
length (in pixels) of the scale bar will be adjusted so that it is proportional
to one of the listed numbers in meters.
Type:
- Source:
events :object
The events this view will listen to and the associated function to call.
Type:
- Source:
maxBarWidth :number
The maximum width of the scale bar element, in pixels
Type:
- Source:
The model that holds the current position of the mouse on the map
Type:
- Since:
- Source:
The model that holds the current scale of the map in pixels:meters
Type:
- Since:
- Source:
template :Underscore.template
The primary HTML template for this view
Type:
- Source:
type :string
The type of View this is
Type:
- Source:
Methods
initialize(optionsopt)
Executed when a new ScaleBarView is created
Parameters:
Name |
Type |
Attributes |
Description |
options |
object
|
<optional>
|
A literal object with options to pass to the view |
- Source:
listenToPointModel()
Update the scale bar view when the lat and long change
- Since:
- Source:
listenToScaleModel()
Update the scale bar when the pixel:meters ratio changes
- Since:
- Source:
onClose()
Function to execute when this view is removed from the DOM
- Since:
- Source:
prettifyScaleValues(pixels, meters) → {object}
Takes a pixel:meters ratio and returns values ready to use in the scale bar.
Parameters:
Name |
Type |
Description |
pixels |
number
|
A length in pixels. Must be > 0. |
meters |
number
|
A distance, in meters, that is equivalent to the given
distance in pixels. Must be > 0. |
Properties:
Name |
Type |
Description |
pixels |
number
|
null
|
The updated pixel value that is less than the
maxBarWidth and equivalent to the distance given by the label. |
label |
string
|
null
|
A string that gives a rounded distance
measurement along with a unit, either meters or kilometers (when > 1000m). |
- Source:
Returns:
Returns the prettified values. Returns null for both values
if a matching distance was not found (see
ScaleBarView#distances)
-
Type
-
object
Renders this view
- Source:
Returns:
Returns the rendered view element
-
Type
-
ScaleBarView
stopListeningToPointModel()
Stop listening to the point model
- Source:
stopListeningToScaleModel()
Stop listening to the scale model
- Since:
- Source:
updateCoordinates(latitude, longitude, elevation)
Updates the displayed coordinates on the scale bar view. Numbers are rounded so
that long and lat have 5 digits after the decimal point.
Parameters:
Name |
Type |
Description |
latitude |
number
|
The north-south position of the point to show
coordinates for |
longitude |
number
|
The east-west position of the point to show
coordinates for |
elevation |
number
|
The distance from sea-level of the point to show
coordinates for |
- Source:
updateScale(pixels, meters)
Change the width of the scale bar and the displayed measurement value based on
a new pixel:meters ratio. This function ensures that the resulting values are
'pretty' - the pixel and meter measurements passed to this function do not need
to be within any range or rounded, though both values must be > 0.
Parameters:
Name |
Type |
Description |
pixels |
number
|
A length in pixels |
meters |
number
|
A distance, in meters, that is equivalent to the given
distance in pixels |
- Source: