Cluster strategy should register for moveend on the layer instead of zoomend on the map. p=elemoine,me r=me (closes #1834)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@8460 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2008-12-06 20:54:51 +00:00
parent f9c814a34a
commit 304b2cf3ea
2 changed files with 9 additions and 5 deletions

View File

@@ -70,9 +70,9 @@ OpenLayers.Strategy.Cluster = OpenLayers.Class(OpenLayers.Strategy, {
if(activated) {
this.layer.events.on({
"beforefeaturesadded": this.cacheFeatures,
"moveend": this.cluster,
scope: this
});
this.layer.map.events.on({"zoomend": this.cluster, scope: this});
}
return activated;
},
@@ -91,9 +91,9 @@ OpenLayers.Strategy.Cluster = OpenLayers.Class(OpenLayers.Strategy, {
this.clearCache();
this.layer.events.un({
"beforefeaturesadded": this.cacheFeatures,
"moveend": this.cluster,
scope: this
});
this.layer.map.events.un({"zoomend": this.cluster, scope: this});
}
return deactivated;
},
@@ -137,9 +137,13 @@ OpenLayers.Strategy.Cluster = OpenLayers.Class(OpenLayers.Strategy, {
/**
* Method: cluster
* Cluster features based on some threshold distance.
*
* Parameters:
* event - {Object} The event received when cluster is called as a
* result of a moveend event.
*/
cluster: function() {
if(this.features) {
cluster: function(event) {
if((!event || event.zoomChanged) && this.features) {
var resolution = this.layer.map.getResolution();
if(resolution != this.resolution || !this.clustersExist()) {
this.resolution = resolution;

View File

@@ -59,8 +59,8 @@
// add one additional feature, with no geometry - just to confirm it doesn't break things
features.push(new OpenLayers.Feature.Vector());
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
layer.addFeatures(features);
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
// resolution 4
// threshold: 4 * 20 = 80 units