Skip to content
This repository has been archived by the owner on Jun 16, 2019. It is now read-only.

Add option to ignore hidden markers #68

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
Luke Mahé <lukem@google.com>
Brendan Kenny <bckenny@google.com>
Moisés Arcos <moiarcsan@gmail.com>
Markus Mächler <markus.maechler@bithost.ch>
9 changes: 8 additions & 1 deletion src/markerclusterer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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);
}
}
Expand Down