Skip to main content

dg-ruler

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

FactoryUsageDescription
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

OptionTypeDefaultDescription
editableBoolean'true'Is it possible to change the intermediate points of the ruler.

Methods

MethodReturnsDescription
addTo( <Map> map ) thisAdds a ruler to the map.
getTotalDistance()NumberReturns the distance (in meters) between the start and end points.
addLatLng( <LatLng> latlng ) thisAdds a point to the ruler.
setLatLngs( <LatLng[]> latlngs ) thisReplaces 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.