Select to view content in your preferred language

Dynamic Clustering

1024
2
04-25-2013 11:44 AM
LangdonOliver
Emerging Contributor
In looking at the ClusterLayer example and reading the forums, I gather that it was strictly written to handle a single chunk of static data.

However, in playing around with it, it seems that it is partially capable of handling dynamic data:
1. Preview this: http://plnkr.co/edit/NnWEBtpzllEZmwngSkX9?p=preview
2. Zoom out a few levels when you can and see how the existing clusters change
3. Also see the console ("didn't find exactly one LABEL:  []")

So it seems that:
1. If there's an existing cluster available, the point will be added to it
2. If no suitable cluster exists, and no interfering point has been created, one will be created
3. If an interfering point exists (and there's no existing cluster) it throws that error about ("didn't find exactly one LABEL:  []");

I made some super simple modifications to get dynamic adding/removing/clearing of points here:
- http://plnkr.co/edit/a2nKNFWQM0R7U8BOvJnl?p=preview (overwritten with new changes)

But having to redraw the points each time an add/remove/clear action occurs isn't optimal.

Has anyone spent some time tweaking ClusterLayers to get this kind of functionality without the redraw effect?  I'm going to attempt to do it, but I'd rather save myself the pain if someone else has already done so.

TIA!
0 Kudos
2 Replies
LangdonOliver
Emerging Contributor
I've dug into this a little deeper, and I'm still having to remove/re-add cluster layers that are affected by points being added/removed from them.

I assume this is by design and that TextSymbol::setText() is just setting the text on the object, and not updating the map?

And same for Point::update()?
0 Kudos
LangdonOliver
Emerging Contributor
http://plnkr.co/edit/a2nKNFWQM0R7U8BOvJnl?p=preview

I've got it only updating the cluster points that are relevant now, but the lag when the marker is redrawn really stinks.  Hopefully someone can answer my questions above re:TextSymbol.setText/Point.update and point me in the right direction.

I had tot get rid of the ClassBreaksRenderer, because I wasn't sure how to get it to update when a marker moved.  It looks like the original code was trying to get it to update, but it didn't work post-render (referring to _updateClusterGeometry()).

Also, the graphic is being requested from the server each time the layer is rendered.  Is there a way to cache this?  I tried storing the instance of PictureMarkerSymbol locally, but that didn't work.

PS: The code is really nasty (lots of copy/paste).  I plan on cleaning it up before actually using it, so at some point I'll reply with a cleaned up ClusterLayer.js.
0 Kudos