makinacorpus/Leaflet.GeometryUtil — pull request #11 by AndrewIngram (2014-01-27 12:44:51+00:00)
Title: Fixes modification of polygon in `closest`

Calling the `closest` function was causing Polygons to gain extra vertices on every call because of `latlngs.push(latlngs[0]);` on line 135. As a consequence, the polygons grow enormously when using the Leaflet.Snap library.

This change makes the `closest` function instead clone the layer's array of latlngs so that there are no side effects.