Global

Methods

accumulatedLengths(coords) → {Array.<Number>}

Returns a list of accumulated length along a line.

Source:
Parameters:
Name Type Description
coords L.Polyline | Array.<L.Point> | Array.<L.LatLng>

Set of coordinates

Returns:
Type:
Array.<Number>

Array of accumulated lengths (pixels for Point, meters for LatLng)

angle(map:, latlngA:, latlngB:) → {Float}

Returns the the angle of the given segment and the Equator in degrees, clockwise from 0 degrees north.

Source:
Parameters:
Name Type Description
map: L.Map

Leaflet map to be used for this method

latlngA: L.LatLng

geographical point A of the segment

latlngB: L.LatLng

geographical point B of the segment

Returns:
Type:
Float

the angle in degrees.

bearing(latlng1:, latlng2:) → {float}

Returns the bearing in degrees clockwise from north (0 degrees) from the first L.LatLng to the second, at the first LatLng

Source:
Parameters:
Name Type Description
latlng1: L.LatLng

origin point of the bearing

latlng2: L.LatLng

destination point of the bearing

Returns:
Type:
float

degrees clockwise from north.

belongsSegment(latlng, latlngA, latlngB, toleranceopt, nullable) → {boolean}

Returns true if the latlng belongs to segment A-B

Source:
Parameters:
Name Type Attributes Default Description
latlng L.LatLng

The position to search

latlngA L.LatLng

geographical point A of the segment

latlngB L.LatLng

geographical point B of the segment

tolerance Number <optional>
<nullable>
0.2

tolerance to accept if latlng belongs really

Returns:
Type:
boolean

closest(map, layer, latlng, verticesopt, nullable) → {L.LatLng}

Returns the closest latlng on layer.

    Accept nested arrays
Source:
Tutorials:
Parameters:
Name Type Attributes Default Description
map L.Map

Leaflet map to be used for this method

layer Array.<L.LatLng> | Array.<Array.<L.LatLng>> | L.PolyLine | L.Polygon

Layer that contains the result

latlng L.LatLng

The position to search

vertices boolean <optional>
<nullable>
false

Whether to restrict to path vertices.

Returns:
Type:
L.LatLng

Closest geographical point or null if layer param is incorrect

closestLayer(map, layers, latlng) → {object}

Returns the closest layer to latlng among a list of layers.

Source:
Tutorials:
Parameters:
Name Type Description
map L.Map

Leaflet map to be used for this method

layers Array.<L.ILayer>

Set of layers

latlng L.LatLng

The position to search

Returns:
Type:
object

{layer, latlng, distance} or null if list is empty;

closestLayerSnap(map, layers, latlng, toleranceopt, nullable, withVerticesopt, nullable) → {object}

Returns the closest position from specified {LatLng} among specified layers, with a maximum tolerance in pixels, providing snapping behaviour.

Source:
Tutorials:
Parameters:
Name Type Attributes Default Description
map L.Map

Leaflet map to be used for this method

layers Array.<ILayer>

A list of layers to snap on.

latlng L.LatLng

The position to snap

tolerance Number <optional>
<nullable>
Infinity

Maximum number of pixels.

withVertices boolean <optional>
<nullable>
true

Snap to layers vertices or segment points (not only vertex)

Returns:
Type:
object

with snapped {LatLng} and snapped {Layer} or null if tolerance exceeded.

closestOnSegment(map, latlng, latlngA, latlngB) → {L.LatLng}

Returns the closest point of a {L.LatLng} on the segment (A-B)

Source:
Tutorials:
Parameters:
Name Type Description
map L.Map

Leaflet map to be used for this method

latlng L.LatLng

The position to search

latlngA L.LatLng

geographical point A of the segment

latlngB L.LatLng

geographical point B of the segment

Returns:
Type:
L.LatLng

Closest geographical point

computeAngle(a, b) → {Number}

Returns horizontal angle in degres between two points.

Source:
Parameters:
Name Type Description
a L.Point

Coordinates of point A

b L.Point

Coordinates of point B

Returns:
Type:
Number

horizontal angle

computeSlope(a, b) → {Object}

Returns slope (Ax+B) between two points.

Source:
Parameters:
Name Type Description
a L.Point

Coordinates of point A

b L.Point

Coordinates of point B

Returns:
Type:
Object

with a and b properties.

destination(latlng:, heading:, distance:) → {L.latLng}

Returns the point that is a distance and heading away from the given origin point.

Source:
Parameters:
Name Type Description
latlng: L.LatLng

origin point

heading: float

heading in degrees, clockwise from 0 degrees north.

distance: float

distance in meters

Returns:
Type:
L.latLng

the destination point. Many thanks to Chris Veness at http://www.movable-type.co.uk/scripts/latlong.html for a great reference and examples.

destinationOnSegment(map:, latlngA:, latlngB:, distance:) → {L.latLng}

Returns a point snaps on the segment and heading away from the given origin point a distance.

Source:
Parameters:
Name Type Description
map: L.Map

Leaflet map to be used for this method

latlngA: L.LatLng

geographical point A of the segment

latlngB: L.LatLng

geographical point B of the segment

distance: float

distance in meters

Returns:
Type:
L.latLng

the destination point.

distance(map, latlngA, latlngB) → {Number}

Shortcut function for planar distance between two {L.LatLng} at current zoom.

Source:
Tutorials:
Parameters:
Name Type Description
map L.Map

Leaflet map to be used for this method

latlngA L.LatLng

geographical point A

latlngB L.LatLng

geographical point B

Returns:
Type:
Number

planar distance

distanceSegment(map, latlng, latlngA, latlngB) → {Number}

Shortcut function for planar distance between a {L.LatLng} and a segment (A-B).

Source:
Parameters:
Name Type Description
map L.Map

Leaflet map to be used for this method

latlng L.LatLng

The position to search

latlngA L.LatLng

geographical point A of the segment

latlngB L.LatLng

geographical point B of the segment

Returns:
Type:
Number

planar distance

extract(map, polyline, start, end) → {Array.<L.LatLng>}

Returns a sub-part of the polyline, from start to end. If start is superior to end, returns extraction from inverted line.

Source:
Parameters:
Name Type Description
map L.Map

Leaflet map to be used for this method

polyline L.PolyLine

Polyline on which will be extracted the sub-part

start Number

ratio, expressed as a decimal between 0 and 1, inclusive

end Number

ratio, expressed as a decimal between 0 and 1, inclusive

Returns:
Type:
Array.<L.LatLng>

new polyline

interpolateOnLine(map, latlngs, ratio) → {Object}

Returns the coordinate of the point located on a line at the specified ratio of the line length.

Source:
Parameters:
Name Type Description
map L.Map

Leaflet map to be used for this method

latlngs Array.<L.LatLng> | L.PolyLine

Set of geographical points

ratio Number

the length ratio, expressed as a decimal between 0 and 1, inclusive

Returns:
Type:
Object

an object with latLng ({LatLng}) and predecessor ({Number}), the index of the preceding vertex in the Polyline (-1 if the interpolated point is the first vertex)

interpolateOnPointSegment(pA, pB, the) → {L.Point}

Returns the Point located on a segment at the specified ratio of the segment length.

Source:
Parameters:
Name Type Description
pA L.Point

coordinates of point A

pB L.Point

coordinates of point B

the Number

length ratio, expressed as a decimal between 0 and 1, inclusive.

Returns:
Type:
L.Point

the interpolated point.

isAfter(polyline, other) → {bool}

Returns true if first polyline starts where second ends.

Source:
Parameters:
Name Type Description
polyline L.PolyLine

First polyline

other L.PolyLine

Second polyline

Returns:
Type:
bool

isBefore(polyline, other) → {bool}

Returns true if first polyline ends where other second starts.

Source:
Parameters:
Name Type Description
polyline L.PolyLine

First polyline

other L.PolyLine

Second polyline

Returns:
Type:
bool

layersWithin(map, layers, latlng, radiusopt, nullable) → {Array.<object>}

Returns all layers within a radius of the given position, in an ascending order of distance.

Source:
Parameters:
Name Type Attributes Default Description
map L.Map

Leaflet map to be used for this method

layers Array.<ILayer>

A list of layers.

latlng L.LatLng

The position to search

radius Number <optional>
<nullable>
Infinity

Search radius in pixels

Returns:
Type:
Array.<object>

an array of objects including layer within the radius, closest latlng, and distance

length(coords) → {Number}

Returns total length of line

Source:
Tutorials:
Parameters:
Name Type Description
coords L.Polyline | Array.<L.Point> | Array.<L.LatLng>

Set of coordinates

Returns:
Type:
Number

Total length (pixels for Point, meters for LatLng)

locateOnLine(map, polyline, latlng) → {Number}

Returns a float between 0 and 1 representing the location of the closest point on polyline to the given latlng, as a fraction of total line length. (opposite of L.GeometryUtil.interpolateOnLine())

Source:
Parameters:
Name Type Description
map L.Map

Leaflet map to be used for this method

polyline L.PolyLine

Polyline on which the latlng will be search

latlng L.LatLng

The position to search

Returns:
Type:
Number

Float between 0 and 1

nClosestLayers(map, layers, latlng, nopt, nullable) → {Array.<object>}

Returns the n closest layers to latlng among a list of input layers.

Source:
Parameters:
Name Type Attributes Default Description
map L.Map

Leaflet map to be used for this method

layers Array.<L.ILayer>

Set of layers

latlng L.LatLng

The position to search

n Number <optional>
<nullable>
layers.length

the expected number of output layers.

Returns:
Type:
Array.<object>

an array of objects {layer, latlng, distance} or null if the input is invalid (empty list or negative n)

readableDistance(distance, unit) → {String}

Shortcut function for converting distance to readable distance.

Source:
Parameters:
Name Type Description
distance Number

distance to be converted

unit String

'metric' or 'imperial'

Returns:
Type:
String

in yard or miles

reverse(polyline) → {L.PolyLine}

Returns a clone with reversed coordinates.

Source:
Parameters:
Name Type Description
polyline L.PolyLine

polyline to reverse

Returns:
Type:
L.PolyLine

polyline reversed

rotatePoint(latlngPoint:, angleDeg:, latlngCenter:) → {L.LatLng}

Returns LatLng of rotated point around specified LatLng center.

Source:
Parameters:
Name Type Description
latlngPoint: L.LatLng

point to rotate

angleDeg: double

angle to rotate in degrees

latlngCenter: L.LatLng

center of rotation

Returns:
Type:
L.LatLng

rotated point

startsAtExtremity(polyline, other) → {bool}

Returns true if first polyline starts where second ends or start.

Source:
Parameters:
Name Type Description
polyline L.PolyLine

First polyline

other L.PolyLine

Second polyline

Returns:
Type:
bool