From 8a72be5100baa86b12e875d09a2385e5bb393d70 Mon Sep 17 00:00:00 2001 From: Chris Broadfoot Date: Thu, 21 Jan 2016 15:00:44 -0800 Subject: [PATCH] Revert "ignore hidden markers in cluster" --- src/markerclusterer.js | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/src/markerclusterer.js b/src/markerclusterer.js index ebf218c..a31e3a9 100755 --- a/src/markerclusterer.js +++ b/src/markerclusterer.js @@ -859,8 +859,7 @@ Cluster.prototype.addMarker = function(marker) { marker.isAdded = true; this.markers_.push(marker); - var visibleMarkers = this.getVisibleMarkers(); - var len = visibleMarkers.length; + var len = this.markers_.length; if (len < this.minClusterSize_ && marker.getMap() != this.map_) { // Min cluster size not reached so show the marker. marker.setMap(this.map_); @@ -869,7 +868,7 @@ Cluster.prototype.addMarker = function(marker) { if (len == this.minClusterSize_) { // Hide the markers that were showing. for (var i = 0; i < len; i++) { - visibleMarkers[i].setMap(null); + this.markers_[i].setMap(null); } } @@ -937,23 +936,6 @@ Cluster.prototype.getMarkers = function() { }; -/** - * Returns the array of markers in the cluster. - * - * @return {Array.} The markers. - */ -Cluster.prototype.getVisibleMarkers = function() { - var visibleMarkers = []; - for (var i in this.markers_) { - var marker = this.markers_[i]; - if (marker.visible) { - visibleMarkers.push(marker); - } - } - return visibleMarkers; -}; - - /** * Returns the center of the cluster. * @@ -1002,24 +984,23 @@ Cluster.prototype.getMap = function() { Cluster.prototype.updateIcon = function() { var zoom = this.map_.getZoom(); var mz = this.markerClusterer_.getMaxZoom(); - var markers = this.getVisibleMarkers(); if (mz && zoom > mz) { // The zoom is greater than our max zoom so show all the markers in cluster. - for (var i = 0, marker; marker = markers[i]; i++) { + for (var i = 0, marker; marker = this.markers_[i]; i++) { marker.setMap(this.map_); } return; } - if (markers_.length < this.minClusterSize_) { + if (this.markers_.length < this.minClusterSize_) { // Min cluster size not yet reached. this.clusterIcon_.hide(); return; } var numStyles = this.markerClusterer_.getStyles().length; - var sums = this.markerClusterer_.getCalculator()(markers, numStyles); + var sums = this.markerClusterer_.getCalculator()(this.markers_, numStyles); this.clusterIcon_.setCenter(this.center_); this.clusterIcon_.setSums(sums); this.clusterIcon_.show(); @@ -1317,7 +1298,6 @@ MarkerClusterer.prototype['draw'] = MarkerClusterer.prototype.draw; Cluster.prototype['getCenter'] = Cluster.prototype.getCenter; Cluster.prototype['getSize'] = Cluster.prototype.getSize; Cluster.prototype['getMarkers'] = Cluster.prototype.getMarkers; -Cluster.prototype['getVisibleMarkers'] = Cluster.prototype.getVisibleMarkers; ClusterIcon.prototype['onAdd'] = ClusterIcon.prototype.onAdd; ClusterIcon.prototype['draw'] = ClusterIcon.prototype.draw;