From fab344a1ac98774616705b1413ee93da08fffc2f Mon Sep 17 00:00:00 2001 From: Silvio Date: Mon, 24 Nov 2014 15:47:00 -0200 Subject: Trying to add cluster support on toggleMarkers() --- gmap_arcgis.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/gmap_arcgis.js b/gmap_arcgis.js index 3449a8e..edc0ea1 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -381,7 +381,9 @@ function gmapArcgis(config) { } if (cluster == true) { - self.config['markers'][element].cluster = new MarkerClusterer(self.map, self.config['markers'][element].overlay); + self.config['markers'][element].cluster = new MarkerClusterer(self.map, + self.config['markers'][element].overlay, + { ignoreHidden: true }); } self.unblockUI('markers_' + element); @@ -432,23 +434,29 @@ function gmapArcgis(config) { }, // Toggle marker visibility - toggleMarkers: function(element, raw) { - var markers = (raw == true) ? element : this.config['markers'][element].overlay; - var closeInfoWindow = false; + toggleMarkers: function(element, raw, cluster) { + var markers = (raw == true) ? element : this.config['markers'][element].overlay; + var isVisible = false; + // Hide/show each marker for (i=0; i < markers.length; i++) { if (markers[i].getVisible()) { - closeInfoWindow = true; + isVisible = true; markers[i].setVisible(false); } else { markers[i].setVisible(true); } } + // Process clusters + if (cluster == true) { + this.config['markers'][element].cluster.repaint(); + } + // Close the infoWindow - if (closeInfoWindow == true && this.config['markers'] != undefined - && this.config['markers'][element] != undefined - && this.config['markers'][element].infowindow != undefined) { + if (isVisible == true && this.config['markers'] != undefined + && this.config['markers'][element] != undefined + && this.config['markers'][element].infowindow != undefined) { this.config['markers'][element].infowindow.close(); } }, -- cgit v1.2.3