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

Commit

Permalink
Revert "ignore hidden markers in cluster"
Browse files Browse the repository at this point in the history
  • Loading branch information
broady committed Jan 21, 2016
1 parent 1edfec3 commit 8a72be5
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions src/markerclusterer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -937,23 +936,6 @@ Cluster.prototype.getMarkers = function() {
};


/**
* Returns the array of markers in the cluster.
*
* @return {Array.<google.maps.Marker>} 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.
*
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8a72be5

Please sign in to comment.