Skip to content

Commit 7e86e3a

Browse files
committed
rewrite
1 parent a512e2a commit 7e86e3a

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

src/datalayerclusterer.js

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,25 @@
5858
function DataLayerClusterer(optOptions) {
5959
DataLayerClusterer.extend(DataLayerClusterer, google.maps.OverlayView);
6060
var options = optOptions || {};
61-
62-
this.clusters_ = [];
63-
this.sizes = [53, 56, 66, 78, 90];
64-
this.styles_ = [];
65-
this.ready_ = false;
66-
this.map = options.map || null;
67-
this.gridSize_ = options.gridSize || 60;
68-
this.minClusterSize_ = options.minimumClusterSize || 2;
69-
this.maxZoom_ = options.maxZoom || null;
70-
this.className_ = options.className || 'cluster';
71-
this.styles_ = options.styles || [];
72-
this.imagePath_ = options.imagePath || DataLayerClusterer.MARKER_CLUSTER_IMAGE_PATH_;
73-
this.imageExtension_ = options.imageExtension || DataLayerClusterer.MARKER_CLUSTER_IMAGE_EXTENSION_;
74-
this.zoomOnClick_ = true;
75-
if (options.zoomOnClick !== undefined) {
76-
this.zoomOnClick_ = options.zoomOnClick;
77-
}
78-
this.averageCenter_ = true;
79-
if (options.averageCenter !== undefined) {
80-
this.averageCenter_ = options.averageCenter;
81-
}
82-
61+
DataLayerClusterer.extend(DataLayerClusterer, {
62+
clusters_: [],
63+
sizes: [53, 56, 66, 78, 90],
64+
styles_: [],
65+
ready_: false,
66+
map: options.map || null,
67+
gridSize_: options.gridSize || 60,
68+
minClusterSize_: options.minimumClusterSize || 2,
69+
maxZoom_: options.maxZoom || null,
70+
className_: options.className || 'cluster',
71+
styles_: options.styles || [],
72+
imagePath_: options.imagePath || DataLayerClusterer.MARKER_CLUSTER_IMAGE_PATH_,
73+
imageExtension_: options.imageExtension || DataLayerClusterer.MARKER_CLUSTER_IMAGE_EXTENSION_,
74+
zoomOnClick_: options.zoomOnClick !== undefined ? options.zoomOnClick : true,
75+
averageCenter_: options.averageCenter !== undefined ? options.averageCenter : true,
76+
_dataLayer: new google.maps.Data()
77+
});
8378
this.setupStyles_();
84-
this._dataLayer = new google.maps.Data();
8579
this._dataLayer.setStyle(DataLayerClusterer.HIDDEN_FEATURE);
86-
8780
if (this.map !== null) {
8881
this.setMap(this.map);
8982
}
@@ -99,11 +92,14 @@ DataLayerClusterer.HIDDEN_FEATURE = {
9992
visible: false
10093
};
10194

102-
103-
104-
10595
/* ---- Public methods ---- */
10696

97+
/**
98+
* Set the visibility of the entire data layer.
99+
*
100+
* @param {bool} v
101+
* @return {void}
102+
*/
107103
DataLayerClusterer.prototype.setVisible = function(v) {
108104
if (!v) {
109105
this.map__ = this.getMap();
@@ -1103,4 +1099,5 @@ DataLayerClusterer.prototype.calculator_ = function(features, numStyles) {
11031099
};
11041100
};
11051101

1102+
// Class exposure
11061103
window.DataLayerClusterer = DataLayerClusterer;

0 commit comments

Comments
 (0)