Maps SDK for Web
Class L.MeasurementRuler
Layer that show a ruler with distance labels over the map.
Constructor
L.MeasurementRuler([options])
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
options | No | Object | None | |
options.markerColor | Color to use for the ruler's stops | No | String | "#000" |
options.lineColor | Color of the rule's line | No | String | "#000" |
options.rulerClassname | Class name that should be apply to the ruler | No | String | "leaflet-distance-measurement__ruler" |
options.labelClassname | Class name that should be apply to the distance label container | No | String | "leaflet-distance-measurement__ruler__label" |
options.dashArray | A string that defines the stroke dash pattern of the leaflet polyline used to draw the ruler. For more details read | No | String | "5 5" |
options.distanceOffset | Distance (in meters) that needs to be added to the distance calculation of the ruler | No | Number | 0 |
options.unitScheme | Unit scheme to use for the distance calculations | No | "metric" | "imperial" | "metric" |
options.useArc | Uses a great arc instead of a rect line | No | Boolean | false |
Properties
distance: Number
Total distance (in meters) of the ruler.
This property will be updated each time a coordinate is added to the ruler.
latLngs: L.LatLng[]
All the coordinates that conform the ruler path.
Methods
addLatLng(latLng)
Add new coordinates to the ruler path and redraw the ruler.
This method extends the size of the ruler.
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
latLng | Yes | L.LatLng | None |
getLast( ): L.LatLng
Returns the last coordinates added to the ruler.
Returns
If the ruler doesn't have coordinates it will return NULL
setLatLngs(latLngs)
Set all the ruler's path at once.
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
latLngs | Yes | L.LatLng[] | None |