DG.Ruler
Example of usage
Create and display a ruler on the map:
var latLngs = [
[51.7314, 36.1938],
[51.7307, 36.1894],
[51.7297, 36.1926],
[51.7299, 36.1968],
[51.7307, 36.1968],
];
const ruler = DG.ruler().addTo(map);
ruler.setLatLngs(latLngs);
Creation
Factory |
Usage |
Description |
DG.Ruler(
<LatLng[]> latlngs,
<Ruler options> options? )
|
DG.ruler(…) |
Creates the ruler object by the given array of geographical points and optional object of options. |
Options
Option |
Type |
Default |
Description |
editable |
Boolean |
'true' |
Is it possible to change the intermediate points of the ruler. |
Methods
Method |
Returns |
Description |
addTo(
<Map> map )
|
this |
Adds a ruler to the map. |
getTotalDistance() |
Number |
Returns the distance (in meters) between the start and end points. |
addLatLng(
<LatLng> latlng )
|
this |
Adds a point to the ruler. |
setLatLngs(
<LatLng[]> latlngs )
|
this |
Replaces all the pixels of the ruler with an array of the transferred geographical locations. |
getLatLngs() |
LatLng[] |
Returns an array of points of the ruler. |
spliceLatLngs(
<Number> index,
<Number> pointsToRemove,
<LatLng> latlng?, … )
|
LatLng[] |
Allows you to add, remove or replace the points in the ruler. The syntax is similar
Array#splice.
Returns an array of remote points. |