[OpenLayers-Dev] Cluster strategy activation
strk
strk at keybit.net
Thu May 20 04:41:43 EDT 2010
On Thu, May 20, 2010 at 09:54:50AM +0200, strk wrote:
> Hi there,
>
> I noticed that the Cluster strategy activation does nothing
> clustering only happens when you add features _after_ the control is
> activated.
>
> Sound reasonable, but the strategy can't be activated until the layer
> is placed on the map, so this makes it impossible to have a workflow like
> this:
>
> 1. Create layer with cluster strategy
> 2. Add features to layer
> 3. Add layer to the map (triggers activation)
>
> Does it make sense for the Cluster.activate to instead perform
> the initial clustering when the layer already contains feature ?
Attached is a patch doing that, for review.
It's not on trac cause I dont not remember the account password
and can't find a "remind me" button on http://trac.openlayers.org/register.
--strk;
() Free GIS & Flash consultant/developer
/\ http://strk.keybit.net/services.html
-------------- next part --------------
Index: Cluster.js
===================================================================
--- Cluster.js (revision 10343)
+++ Cluster.js (working copy)
@@ -79,6 +79,10 @@
activate: function() {
var activated = OpenLayers.Strategy.prototype.activate.call(this);
if(activated) {
+ /* cache existing feature in the layer */
+ if ( this.layer.features && ! this.features ) {
+ this.features = this.layer.features.slice()
+ }
this.layer.events.on({
"beforefeaturesadded": this.cacheFeatures,
"moveend": this.cluster,
More information about the Dev
mailing list