From: Jordan Augé Date: Mon, 7 Jul 2014 09:19:48 +0000 (+0200) Subject: fixed googlemaps filtering X-Git-Tag: myslice-1.1~55 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f27615841cf448ee4fc3136726ef59913ed98d4b;p=unfold.git fixed googlemaps filtering --- diff --git a/plugins/googlemap/static/js/googlemap.js b/plugins/googlemap/static/js/googlemap.js index 5f640b93..f6248ab1 100644 --- a/plugins/googlemap/static/js/googlemap.js +++ b/plugins/googlemap/static/js/googlemap.js @@ -275,6 +275,29 @@ GOOGLEMAP_BGCOLOR_REMOVED = 2; }); marker.setVisible(visible); }); + + this.do_clustering(); + }, + + do_clustering: function() + { + this.markerCluster = new MarkerClusterer(this.map, this.markers, {zoomOnClick: false}); + this.markerCluster.setIgnoreHidden(true); + google.maps.event.addListener(this.markerCluster, "clusterclick", function (cluster) { + var cluster_markers = cluster.getMarkers(); + var bounds = new google.maps.LatLngBounds(); + $.each(cluster_markers, function(i, marker){ + bounds.extend(marker.getPosition()); + }); + //map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); + this.map.fitBounds(bounds); + }); + //now fit the map to the bounds + this.map.fitBounds(this.bounds); + // Fix the zoom of fitBounds function, it's too close when there is only 1 marker + if (this.markers.length==1) { + this.map.setZoom(this.map.getZoom()-4); + } }, redraw_map: function() @@ -296,22 +319,8 @@ GOOGLEMAP_BGCOLOR_REMOVED = 2; self.markers.push(s.marker); }); - this.markerCluster = new MarkerClusterer(this.map, this.markers, {zoomOnClick: false}); - google.maps.event.addListener(this.markerCluster, "clusterclick", function (cluster) { - var cluster_markers = cluster.getMarkers(); - var bounds = new google.maps.LatLngBounds(); - $.each(cluster_markers, function(i, marker){ - bounds.extend(marker.getPosition()); - }); - //map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); - this.map.fitBounds(bounds); - }); - //now fit the map to the bounds - this.map.fitBounds(this.bounds); - // Fix the zoom of fitBounds function, it's too close when there is only 1 marker - if (this.markers.length==1) { - this.map.setZoom(this.map.getZoom()-4); - } + this.do_clustering(); + /* Set checkbox and background color */ $.each(record_keys, function(i, record_key) {