From 42ad41096b29573ca0429b316d364195eac02e8e Mon Sep 17 00:00:00 2001 From: arno Date: Wed, 7 Oct 2009 00:18:15 +0200 Subject: [PATCH 1/1] when selecting a cluster, zoom until features are detached --- js/syp.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/js/syp.js b/js/syp.js index 9bccba6..0f77854 100644 --- a/js/syp.js +++ b/js/syp.js @@ -246,11 +246,36 @@ var SYP = { } }, + onZoomClusterEnd: function(arg) { + var map = arg.object; + var point = new OpenLayers.Geometry.Point(this.lonlat.lon, this.lonlat.lat); + var center = map.getCenter(); + for (var i = this.layer.features.length; i-->0;) { + var feature = this.layer.features[i]; + if (feature.geometry.equals(point) && + (feature.attributes.count == this.count)) { + var self = this; + window.setTimeout(function() { map.setCenter(self.lonlat, map.zoom + 1)}, 500); + return; + } + } + SYP.selectControl.activate(); + map.events.unregister("zoomend", this, SYP.onZoomClusterEnd); + }, + onFeatureSelect: function(feature) { var map = feature.layer.map; + if (feature.attributes.count > 1) { this.unselect(feature); var lonlat = new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y); + var args = { + lonlat: lonlat, + layer: feature.layer, + count: feature.attributes.count + } + map.events.register("zoomend", args, SYP.onZoomClusterEnd); + SYP.selectControl.deactivate(); map.setCenter(lonlat, map.zoom + 1); return; } -- 2.39.2