Too many damn points
No love for the JS API
Make it work
This left me with a little dilemma. I have a couple of existing ArcGIS JS API projects that could really benefit from this. That ClusterLayer example does most of the work (thanks Esri!), but it would be really cool if I could just feed it a URL to a FeatureService or MapService of points and have it work. So… I tweaked it to make a ClusterFeatureLayer that works similar to a FeatureLayer.
There are a couple of things lacking in this ClusterFeatureLayer.
- No Vector Tiling, although with points, I don’t think it matters. A better route is probably to send the requests for objectIds in chunks and when all requests done, display clusters.
- No manual cache. I was thinking maybe performance could be improved with a local cache, but lookup might negate that benefit. Could warrant some testing. I have added a cache for clustered features.
I recently updated this ClusterFeatureLayer to use dojo/promise/all to send multiple requests if more than 1000 objectIds are in view. I also added an optional where clause to refine the queries. I’ve also added a cache to limit the number of requests and included a clearCache() method.
But it works and that’s what counts.
You can view a demo of the ClusterFeatureLayer here. How to use it is similar to the original shown here. Again, big thanks to the Esri JS devs for the original ClusterLayer example this is built on.
If you can make some performance improvements, please fork and pull as usual.
For more ArcGIS Web Dev goodness, check out a book I am working on with Manning Publications.