Skip to content

Commit

Permalink
googlearchive#68 Add option to ignore hidden markers
Browse files Browse the repository at this point in the history
  • Loading branch information
maechler authored and das-peter committed Jul 29, 2016
1 parent 6b9afb1 commit be25cef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Brendan Kenny <[email protected]>
Moisés Arcos <[email protected]>
Peter Grassberger <[email protected]>
Chris Fritz <[email protected]>
Markus Mächler <[email protected]>
9 changes: 8 additions & 1 deletion src/markerclusterer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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 @@ -109,6 +111,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 @@ -785,7 +792,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

0 comments on commit be25cef

Please sign in to comment.