Skip to content

Commit be25cef

Browse files
maechlerdas-peter
authored andcommitted
googlearchive#68 Add option to ignore hidden markers
1 parent 6b9afb1 commit be25cef

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ Brendan Kenny <bckenny@google.com>
1414
Moisés Arcos <moiarcsan@gmail.com>
1515
Peter Grassberger <petertheone@gmail.com>
1616
Chris Fritz <us.chrisf@gmail.com>
17+
Markus Mächler <markus.maechler@bithost.ch>

src/markerclusterer.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
* 'minimumClusterSize': (number) The minimum number of markers to be in a
5252
* cluster before the markers are hidden and a count
5353
* is shown.
54+
* 'ignoreHiddenMarkers': (boolean) Whether to ignore markers that are not
55+
* visible or count and cluster them anyway
5456
* 'styles': (object) An object that has style properties:
5557
* 'url': (string) The image url.
5658
* 'height': (number) The image height.
@@ -109,6 +111,11 @@ function MarkerClusterer(map, opt_markers, opt_options) {
109111
*/
110112
this.minClusterSize_ = options['minimumClusterSize'] || 2;
111113

114+
/**
115+
* @type {boolean}
116+
* @private
117+
*/
118+
this.ignoreHiddenMarkers_ = options['ignoreHiddenMarkers'] || false;
112119

113120
/**
114121
* @type {?number}
@@ -785,7 +792,7 @@ MarkerClusterer.prototype.createClusters_ = function() {
785792
var bounds = this.getExtendedBounds(mapBounds);
786793

787794
for (var i = 0, marker; marker = this.markers_[i]; i++) {
788-
if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds)) {
795+
if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds) && (!this.ignoreHiddenMarkers_ || marker.getVisible())) {
789796
this.addToClosestCluster_(marker);
790797
}
791798
}

0 commit comments

Comments
 (0)