Alexandre, Layers do not have the zoomend event type, so I don't think your patch is valid. Try with moveend and a check in the listener to handle zoom change only. Eric
2008/11/13, Alexandre Dube <[EMAIL PROTECTED]>: > Hi Eric, Ivan, > > The following is enough to resolve the bug ( I think ). > > ##### patch ? start ##### > > --- Cluster.js.original 2008-11-13 14:05:25.000000000 -0500 > +++ Cluster.js 2008-11-13 14:06:59.000000000 -0500 > @@ -72,7 +72,7 @@ > "beforefeaturesadded": this.cacheFeatures, > scope: this > }); > - this.layer.map.events.on({"zoomend": this.cluster, scope: > this}); > + this.layer.events.on({"zoomend": this.cluster, scope: this}); > } > return activated; > }, > @@ -93,7 +93,7 @@ > "beforefeaturesadded": this.cacheFeatures, > scope: this > }); > - this.layer.map.events.un({"zoomend": this.cluster, scope: > this}); > + this.layer.events.un({"zoomend": this.cluster, scope: this}); > } > return deactivated; > }, > ##### patch ? end ##### > > > > Trying that, I found an other bug which occurs with or without this fix. > > If I pan to some place while the layer is not visible, then set it > back to visible, features won't appear. I'm not sure if that's because > my vector layer is not in the layerSwitcher. I toggle the vector > layer's visibility with a dummy layer, like this : > > > > ### code start ### > olDummy.events.register("visibilitychanged", olDummy, toggleVisibility); > > function toggleVisibility() > { > var bVisible = this.getVisibility(); > olWMS.setVisibility(bVisible); > olWFS.setVisibility(bVisible); > } > ### code end ### > > Ivan, could you test the behavior in your application ? > > Best regards, > > Alexandre > > P.S. Being good at finding bugs is easy and not really rewarding... > Finding solutions, that's something ! You guys are doing great. Cheers ! > > Eric Lemoine wrote: >> You guys are good to find bugs :-) >> >> I think that, instead of listening to the map's zoomend events, the >> cluster strategy should listen to its layer's moveend events and check >> in the listener that this is actually a zoom change before doing >> anything. The moveend listener receives an object with a zoomChanged >> boolean property. Can one of you try modifying the cluster strategy >> with that and report back? (don't forget to change the unregistration >> as well). >> >> Thanks. >> >> Eric >> >> 2008/11/13, Ivan Grcic <[EMAIL PROTECTED]>: >> >>> Hi Alex, >>> >>> i made a little hack to it...inside Strategy.Cluster.js inside cluster >>> function I added one more check: >>> (OpenLayers.Util.indexOf(this.layer.resolutions, resolution) != -1) >>> >>> it doesnt do the clustering if current resolution is not contained >>> inside layers array of resolutions. >>> >>> Index: Cluster.js >>> =================================================================== >>> --- Cluster.js (revision 8317) >>> +++ Cluster.js (working copy) >>> @@ -141,7 +141,8 @@ >>> cluster: function() { >>> if(this.features) { >>> var resolution = this.layer.map.getResolution(); >>> - if(resolution != this.resolution || !this.clustersExist()) { >>> + if((OpenLayers.Util.indexOf(this.layer.resolutions, >>> resolution) != -1) && (resolution != this.resolution || >>> !this.clustersExist())) { >>> this.resolution = resolution; >>> var clusters = []; >>> var feature, clustered, cluster; >>> >>> Greetings, >>> Ivan >>> On Thu, Nov 13, 2008 at 3:02 PM, Alexandre Dube <[EMAIL PROTECTED]> >>> wrote: >>> >>>> I get the same behavior as Ivan's on my application which has very >>>> similar >>>> resolution settings on map an vector layer. >>>> >>>> Because a layer's features are not destroyed when it goes out of range >>>> (inRange) or becomes invisible (visibility), the cluster strategy still >>>> clusters those existing features. I don't have that many features to >>>> display >>>> when the layer becomes inRange, so I never noticed any slowing down. >>>> >>>> Alexandre >>>> >>>> Ivan Grcic wrote: >>>> >>>>> This post evolved from previous discussion named "bbox strategy and >>>>> zooming" >>>>> >>>>> Clustering features with cluster strategy takes some time. If there >>>>> are many features to cluster, it will take even more time :) >>>>> >>>>> So there are some scenarios where clustering shouldnt be recalculated. >>>>> >>>>> Example: >>>>> I want to see my cluster layer only after 5th zoom level. No >>>>> clustering should be made when i play on zoom level 0-4 with other >>>>> layers, >>>>> because it slows things down, and the cluster layer is still not >>>>> visible at all (its only clustering features in background) >>>>> >>>>> It should only cluster when layer is visible (and the current map >>>>> resolution is inside array resolution of clustered layer, if we define >>>>> seperate set of resolution) >>>>> >>>>> So if map has: >>>>> resolutions: [0,1,2,3,4,5,6,7,8,9] >>>>> >>>>> and vector layer: >>>>> resolutions: [5, 6, 7, 8, 9] >>>>> >>>>> clustering should occur only on vector layers resolution :5, 6, 7, 8 >>>>> and >>>>> 9. >>>>> >>>>> I hope you see where im pointing now, >>>>> >>>>> Best regards, >>>>> >>>>> >>>>> >>>>> >>>> -- >>>> Alexandre Dubé >>>> Mapgears >>>> www.mapgears.com >>>> >>>> >>>> >>> >>> -- >>> Ivan Grcic >>> _______________________________________________ >>> Dev mailing list >>> Dev@openlayers.org >>> http://openlayers.org/mailman/listinfo/dev >>> >>> > > > -- > Alexandre Dubé > Mapgears > www.mapgears.com > > _______________________________________________ Dev mailing list Dev@openlayers.org http://openlayers.org/mailman/listinfo/dev