CloudMade/Leaflet — pull request #1109 by basos9 (2012-10-31 19:17:56+00:00)
Title: Add async LayerGroup & GeoJSON add/rm, add yield to various methods

This is implement the third of the three optimization that I referred to the first comment on [this blog post](http://leafletjs.com/2012/10/25/leaflet-0-4-5-bugfix-release-and-plans-for-0.5.html). These aim at optimizing the handling of geoJSON layers with thousands of sublayers.

This adds the ability for yielded LayerGroup, GeoJSON layer addition and removal.
Moreover it adds yielded ability to LayerGroup.eachLayer, GeoJSON.setStyle.

This is not, strictly speaking an optimization as it adds delay to a long proccess. But this is a well known JS technique to make long lasting operation more user friendly by giving time to the browser to render the UI or perform other JS tasks.

A modification to the internals of map (addLayer, removeLayer) had to be made in order to recognize when to fire layeradd, layerremove events. Also a modification to the Path API was made (onAdd, onRemove) in order to support async adding. An internal private property was added to layers that support async add/rm (currently only LayerGroup and subclasses) in order to indicate to the map which API to use.

An example that demonstrates all these optimization was added. It renders the municipalities of Span (~8080) and performs various tests. A note on browser performance, Chrome seems currently to be the fastest one in terms of SVG rendering and JS engine performance (sorry firefox), in both windows and Linux.