From 35a7372bf14e7fe52142d64ad95b8305883635bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4chler?= Date: Fri, 20 May 2016 15:38:26 +0200 Subject: [PATCH 1/2] Adds option to ignore hidden markers --- CONTRIBUTORS | 1 + src/markerclusterer.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index ef284e5..71f68bd 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -12,3 +12,4 @@ Luke Mahé Brendan Kenny Moisés Arcos +Markus Mächler diff --git a/src/markerclusterer.js b/src/markerclusterer.js index a31e3a9..05736ed 100755 --- a/src/markerclusterer.js +++ b/src/markerclusterer.js @@ -48,6 +48,8 @@ * 'minimumClusterSize': (number) The minimum number of markers to be in a * cluster before the markers are hidden and a count * is shown. + * 'ignoreHiddenMarkers': (boolean) Whether to ignore markers that are not + * visible or count and cluster them anyway * 'styles': (object) An object that has style properties: * 'url': (string) The image url. * 'height': (number) The image height. @@ -106,6 +108,11 @@ function MarkerClusterer(map, opt_markers, opt_options) { */ this.minClusterSize_ = options['minimumClusterSize'] || 2; + /** + * @type {boolean} + * @private + */ + this.ignoreHiddenMarkers = options['ignoreHiddenMarkers'] || false; /** * @type {?number} @@ -784,7 +791,7 @@ MarkerClusterer.prototype.createClusters_ = function() { var bounds = this.getExtendedBounds(mapBounds); for (var i = 0, marker; marker = this.markers_[i]; i++) { - if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds)) { + if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds) && (!this.ignoreHiddenMarkers || marker.getVisible())) { this.addToClosestCluster_(marker); } } From 12b0f41be12d1b464b459f4a12488f14aeff5986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4chler?= Date: Fri, 20 May 2016 15:45:12 +0200 Subject: [PATCH 2/2] Adds underscore to variable name --- src/markerclusterer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/markerclusterer.js b/src/markerclusterer.js index 05736ed..928dcc6 100755 --- a/src/markerclusterer.js +++ b/src/markerclusterer.js @@ -112,7 +112,7 @@ function MarkerClusterer(map, opt_markers, opt_options) { * @type {boolean} * @private */ - this.ignoreHiddenMarkers = options['ignoreHiddenMarkers'] || false; + this.ignoreHiddenMarkers_ = options['ignoreHiddenMarkers'] || false; /** * @type {?number} @@ -791,7 +791,7 @@ MarkerClusterer.prototype.createClusters_ = function() { var bounds = this.getExtendedBounds(mapBounds); for (var i = 0, marker; marker = this.markers_[i]; i++) { - if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds) && (!this.ignoreHiddenMarkers || marker.getVisible())) { + if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds) && (!this.ignoreHiddenMarkers_ || marker.getVisible())) { this.addToClosestCluster_(marker); } }