Methods
accumulatedLengths(coords) → {Array.<Number>}
Returns a list of accumulated length along a line.
Parameters:
Name | Type | Description |
---|---|---|
coords |
L.Polyline | Array.<L.Point> | Array.<L.LatLng> | Set of coordinates |
- Source:
Returns:
Array of accumulated lengths (pixels for Point, meters for LatLng)
- Type
- Array.<Number>
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
Parameters:
Name | Type | Description |
---|---|---|
latlng1: |
L.LatLng | origin point of the bearing |
latlng2: |
L.LatLng | destination point of the bearing |
- Source:
Returns:
degrees clockwise from north.
- Type
- float
belongsSegment(latlng, latlngA, latlngB, toleranceopt, nullable) → {boolean}
Returns true if the latlng belongs to segment A-B
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 |
- Source:
Returns:
- Type
- boolean
closest(map, layer, latlng, verticesopt, nullable) → {L.LatLng}
Returns the closest latlng on layer.
Accept nested arrays
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. |
- Source:
- Tutorials:
Returns:
Closest geographical point or null if layer param is incorrect
- Type
- L.LatLng
closestLayer(map, layers, latlng) → {object}
Returns the closest layer to latlng among a list of layers.
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 |
- Source:
- Tutorials:
Returns:
{layer, latlng, distance}
or null
if list is empty;
- Type
- object
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.
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) |
- Source:
- Tutorials:
Returns:
with snapped {LatLng} and snapped {Layer} or null if tolerance exceeded.
- Type
- object
closestOnSegment(map, latlng, latlngA, latlngB) → {L.LatLng}
Returns the closest point of a {L.LatLng} on the segment (A-B)
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 |
- Source:
- Tutorials:
Returns:
Closest geographical point
- Type
- L.LatLng
computeAngle(a, b) → {Number}
Returns horizontal angle in degres between two points.
Parameters:
Name | Type | Description |
---|---|---|
a |
L.Point | Coordinates of point A |
b |
L.Point | Coordinates of point B |
- Source:
Returns:
horizontal angle
- Type
- Number
computeSlope(a, b) → {Object}
Returns slope (Ax+B) between two points.
Parameters:
Name | Type | Description |
---|---|---|
a |
L.Point | Coordinates of point A |
b |
L.Point | Coordinates of point B |
- Source:
Returns:
with a
and b
properties.
- Type
- Object
destination(latlng:, :, :) → {L.latLng}
Returns the point that is a distance and heading away from the given origin point.
Parameters:
Name | Type | Description |
---|---|---|
latlng: |
L.LatLng | origin point |
: |
float | heading in degrees, clockwise from 0 degrees north. |
: |
float | distance in meters |
- Source:
Returns:
the destination point. Many thanks to Chris Veness at http://www.movable-type.co.uk/scripts/latlong.html for a great reference and examples.
- Type
- L.latLng
distance(map, latlngA, latlngB) → {Number}
Shortcut function for planar distance between two {L.LatLng} at current zoom.
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 |
- Source:
- Tutorials:
Returns:
planar distance
- Type
- Number
distanceSegment(map, latlng, latlngA, latlngB) → {Number}
Shortcut function for planar distance between a {L.LatLng} and a segment (A-B).
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 |
- Source:
Returns:
planar distance
- Type
- Number
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.
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 |
- Source:
Returns:
new polyline
- Type
- Array.<L.LatLng>
interpolateOnLine(map, latlngs, ratio) → {Object}
Returns the coordinate of the point located on a line at the specified ratio of the line length.
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 |
- Source:
Returns:
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)
- Type
- Object
interpolateOnPointSegment(pA, pB, the) → {L.Point}
Returns the Point located on a segment at the specified ratio of the segment length.
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. |
- Source:
Returns:
the interpolated point.
- Type
- L.Point
isAfter(polyline, other) → {bool}
Returns true if first polyline starts where second ends.
Parameters:
Name | Type | Description |
---|---|---|
polyline |
L.PolyLine | First polyline |
other |
L.PolyLine | Second polyline |
- Source:
Returns:
- Type
- bool
isBefore(polyline, other) → {bool}
Returns true if first polyline ends where other second starts.
Parameters:
Name | Type | Description |
---|---|---|
polyline |
L.PolyLine | First polyline |
other |
L.PolyLine | Second polyline |
- Source:
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.
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 |
- Source:
Returns:
an array of objects including layer within the radius, closest latlng, and distance
- Type
- Array.<object>
length(coords) → {Number}
Returns total length of line
Parameters:
Name | Type | Description |
---|---|---|
coords |
L.Polyline | Array.<L.Point> | Array.<L.LatLng> | Set of coordinates |
- Source:
- Tutorials:
Returns:
Total length (pixels for Point, meters for LatLng)
- Type
- Number
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())
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 |
- Source:
Returns:
Float between 0 and 1
- Type
- Number
nClosestLayers(map, layers, latlng, nopt, nullable) → {Array.<object>}
Returns the n closest layers to latlng among a list of input layers.
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. |
- Source:
Returns:
an array of objects {layer, latlng, distance}
or null
if the input is invalid (empty list or negative n)
- Type
- Array.<object>
readableDistance(distance, unit) → {String}
Shortcut function for converting distance to readable distance.
Parameters:
Name | Type | Description |
---|---|---|
distance |
Number | distance to be converted |
unit |
String | 'metric' or 'imperial' |
- Source:
Returns:
in yard or miles
- Type
- String
reverse(polyline) → {L.PolyLine}
Returns a clone with reversed coordinates.
Parameters:
Name | Type | Description |
---|---|---|
polyline |
L.PolyLine | polyline to reverse |
- Source:
Returns:
polyline reversed
- Type
- L.PolyLine
rotatePoint(latlngPoint:, angleDeg:, latlngCenter:) → {L.LatLng}
Returns LatLng of rotated point around specified LatLng center.
Parameters:
Name | Type | Description |
---|---|---|
latlngPoint: |
L.LatLng | point to rotate |
angleDeg: |
double | angle to rotate in degrees |
latlngCenter: |
L.LatLng | center of rotation |
- Source:
Returns:
rotated point
- Type
- L.LatLng
startsAtExtremity(polyline, other) → {bool}
Returns true if first polyline starts where second ends or start.
Parameters:
Name | Type | Description |
---|---|---|
polyline |
L.PolyLine | First polyline |
other |
L.PolyLine | Second polyline |
- Source:
Returns:
- Type
- bool