CloudMade/Leaflet — pull request #1141 by jfgirard (2012-11-12 16:19:51+00:00)
Title: Speed up removeLayer with thousands of layer

Its slow to remove a layer when there are thousands of layer in the map. One of the reason is because the removeEventListener method have to loop the whole list of layers for each event to clean.

This PR stores the event listeners into a hash using the context's leaflet_id when available. The removal become almost instant having the leaflet_id.

While doing tests, I found that Path.Canvas did not clear the "click" event on remove, causing a memory leak. I fixed that too.