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

Styling clusters #123 #124

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions src/markerclusterer.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ function MarkerClusterer(map, opt_markers, opt_options) {
*/
this.gridSize_ = options['gridSize'] || 60;

/**
* @type {string}
* @private
*/
this.clusterClass_ = options['clusterClass'] || 'cluster';

/**
* @private
*/
Expand Down Expand Up @@ -778,6 +784,8 @@ MarkerClusterer.prototype.createClusters_ = function() {
return;
}

google.maps.event.trigger(this, "clusteringbegin");

// Get our current map view bounds.
// Create a new bounds object so we don't affect the map.
var mapBounds = new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),
Expand All @@ -789,6 +797,18 @@ MarkerClusterer.prototype.createClusters_ = function() {
this.addToClosestCluster_(marker);
}
}

google.maps.event.trigger(this, 'clusteringend');
};


/**
* Returns the value of the <code>clusterClass</code> property.
*
* @return {string} the value of the clusterClass property.
*/
MarkerClusterer.prototype.getClusterClass = function () {
return this.clusterClass_;
};


Expand Down Expand Up @@ -1028,6 +1048,7 @@ Cluster.prototype.updateIcon = function() {
function ClusterIcon(cluster, styles, opt_padding) {
cluster.getMarkerClusterer().extend(ClusterIcon, google.maps.OverlayView);

this.className_ = cluster.getMarkerClusterer().getClusterClass();
this.styles_ = styles;
this.padding_ = opt_padding || 0;
this.cluster_ = cluster;
Expand Down Expand Up @@ -1065,6 +1086,7 @@ ClusterIcon.prototype.triggerClusterClick = function(event) {
*/
ClusterIcon.prototype.onAdd = function() {
this.div_ = document.createElement('DIV');
this.div_.className = this.className_;
if (this.visible_) {
var pos = this.getPosFromLatLng_(this.center_);
this.div_.style.cssText = this.createCss(pos);
Expand Down