Esri/esri-leaflet — pull request #112 by patrickarlt (2013-08-05 18:00:45+00:00)
Title: Feature grids and clustering!

Sorry for such a large PR but this is accomplishing quite a bit.

I'm going to leave this up for a bit while I do testing in IE 8 but I wanted everyone to be able to take a look. I'll probably merge this in later this week.

#### What Changed

* Start making more compatible w/ Leaflet Plugin guidelines https://github.com/Esri/esri-leaflet/issues/73. This mostly involved renaming output of the `grunt build` and adding all the demos back into an `example` folder.
* `FeatureLayer` now makes its requests on a grid as per https://github.com/Esri/esri-leaflet/issues/12. I'm ok with the grid implementation for now. If you are interested in just seeing the grid you can checkout http://patrickarlt.github.io/leaflet-virtual-grid/
* First pass at `ClusteredFeatureLayer`! It was pretty easy since the feature grid can simply be mixed into any other class https://github.com/Esri/esri-leaflet/issues/4
* Various optimizations throughout There is a new function to process URLs, there are other utility functions like `debounce`. `L.esri.get` now uses CORS if available or falls back to JSONP.

#### Demos
I also have a companion PR ready for GitHub pages but you can take a look on my Github Pages. There are a couple new demos...

* [Basic Clustering](http://patrickarlt.github.io/esri-leaflet/basicclustering.html)
* [Advanced Clustering](http://patrickarlt.github.io/esri-leaflet/symbolizeclusters.html)

#### Performance
The new grid combined with the switch to CORS where possible means that requests to FeatureLayers get cached which is great. But by splitting the requests up we make loads of request to the same domain (services.arcgis.com) which means that all the requests block each other and might impact performance if some of the requests are slow.

This is really noticeable in the clustering demos where TONS of processing has to happen when the request for each grid cell comes back. This is pretty noticeable in the [clustering demo](http://patrickarlt.github.io/esri-leaflet/symbolizeclusters.html) where the map seems to stutter in a bit. This could probably be optimized by waiting to process results until ALL the requests are finished and then do one big processing step. As opposed mixing tile requests/loading/drawing, feature requests/loading/processing/drawing all at once.

On the flip side the new grid loads new features on move (with a slight delay) which makes features feel really continuous and snappy.