Legacy
Mapbox.js is no longer in active development. To learn more about our newer mapping tools see Mapbox GL JS.
You are viewing an older version of Mapbox.js. Check out v3.3.1 for the latest.
LineUtil
Various utility functions for polyine points processing, used by Leaflet internally to make polylines lightning-fast.
Methods
Method | Returns | Description |
---|---|---|
simplify(
|
Point[] |
Dramatically reduces the number of points in a polyline while retaining its shape and returns a new array of simplified points. Used for a huge performance boost when processing/displaying Leaflet polylines for each zoom level and also reducing visual noise. tolerance affects the amount of simplification (lesser value means higher quality but slower and with more points). Also released as a separated micro-library Simplify.js. |
pointToSegmentDistance(
|
Number |
Returns the distance between point p and segment p1 to p2 . |
closestPointOnSegment(
|
Point |
Returns the closest point from a point p on a segment p1 to p2 . |
clipSegment(
|
- |
Clips the segment a to b by rectangular bounds (modifying the segment points directly!). Used by Leaflet to only show polyline points that are on the screen or near, increasing performance. |