Various utility functions for polyine points processing, used by Leaflet internally to make polylines lightning-fast.


Function Returns Description
simplify(<Point[]> points, <Number> tolerance) Point[] Dramatically reduces the number of points in a polyline while retaining its shape and returns a new array of simplified points, using the Douglas-Peucker algorithm. 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(<Point> p, <Point> p1, <Point> p2) Number Returns the distance between point p and segment p1 to p2.
closestPointOnSegment(<Point> p, <Point> p1, <Point> p2) Number Returns the closest point from a point p on a segment p1 to p2.
clipSegment(<Point> a, <Point> b, <Bounds> bounds, <Boolean> useLastCode?, <Boolean> round?) Point[]|Boolean Clips the segment a to b by rectangular bounds with the Cohen-Sutherland algorithm (modifying the segment points directly!). Used by Leaflet to only show polyline points that are on the screen or near, increasing performance.
Props Wrld.Prop
Themes Wrld.themes
Heatmaps Wrld.Heatmap
Events Event objects
Services (Optional) WrldPoiApi