version: `cluster-20170727-0020`
MODIFY
CHANGE_LOGS.md
CHANGE_LOGS.md
**Note that all date times indicate the Pacific Time (California in US)**
+## Jul/27
+
+version: `cluster-20170727-0020`
+
+#1 is not fixed yet.
+
+Algorithm has been improved. Now Geocell + distance base. [#6](https://github.com/mapsplugin/cordova-plugin-googlemaps-cluster/issues/6)
+
+I will update the detail later.
+
## Jul/26
version: `cluster-20170726-1751`
- Markers images are loaded after few ms [#7](https://github.com/mapsplugin/cordova-plugin-googlemaps-cluster/issues/7)
version: `cluster-20170726-1253`
-- After zoom out the markers are still on the map, clusters are shown too. [#1](https://github.com/mapsplugin/cordova-plugin-googlemaps-cluster/issues/1)
+~~- After zoom out the markers are still on the map, clusters are shown too. [#1](https://github.com/mapsplugin/cordova-plugin-googlemaps-cluster/issues/1)~~
## Jul/25 (Pacific Time)
- markerCluster.on(plugin.google.maps.event.MARKER_CLICK); [#5](https://github.com/mapsplugin/cordova-plugin-googlemaps-cluster/issues/5)

MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="cluster-20170726-2303" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="cluster-20170727-0020" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-googlemaps</name>
<js-module name="BaseClass" src="www/BaseClass.js">
<runs />

MODIFY
www/Cluster.js
www/Cluster.js
@@ -51,14 +51,10 @@ Cluster.prototype.CLUSTER_MODE = 2;
Cluster.prototype.getPluginName = function() {
return this.map.getId() + "-cluster";
};
-Cluster.prototype.getMarkerBounds = function() {
- var markers = this.getMarkers();
- var bounds = new LatLngBounds(markers[0].position, markers[0].position);
- markers.forEach(function(marker) {
- bounds.extend(marker.getPosition());
- });
- return bounds;
+Cluster.prototype.getBounds = function() {
+ return this.get("bounds");
};
+/*
Cluster.prototype.getBounds = function() {
var bounds = this.get("bounds");
if (!bounds) {
@@ -67,6 +63,7 @@ Cluster.prototype.getBounds = function() {
}
return bounds;
};
+*/
Cluster.prototype.getCenter = function() {
return this.getBounds().getCenter();
};
@@ -77,12 +74,17 @@ Cluster.prototype.getMarkers = function() {
Cluster.prototype.addMarkers = function(markerRefs) {
var self = this;
+ var bounds = this.get("bounds") || new LatLngBounds(markerRefs[0].getPosition(), markerRefs[0].getPosition());
+
markerRefs.forEach(function(markerRef) {
if (self._markerRefs.indexOf(markerRef) === -1) {
markerRef.set("isAdded", true);
self._markerRefs.push(markerRef);
+ bounds.extend(markerRef.getPosition());
}
});
+
+ this.set("bounds", bounds);
};
Cluster.prototype.setMode = function(mode) {
this.set("mode", mode);

MODIFY
www/Map.js
www/Map.js
@@ -1027,7 +1027,11 @@ Map.prototype._onClusterEvent = function(eventName, markerClusterId, clusterId,
} else {
// clusterred marker
var cluster = markerCluster.getClusterByClusterId(clusterId);
+ if (cluster) {
markerCluster.trigger(eventName, cluster);
+ } else {
+ console.log("-----> This is remained cluster icon : " + clusterId);
+ }
}
}
};

MODIFY
www/MarkerCluster.js
www/MarkerCluster.js
@@ -415,7 +415,7 @@ MarkerCluster.prototype.redraw = function(clusterDistance, force) {
var cluster = self.getClusterByGeocellAndResolution(geocell, resolution);
cluster.addMarkers(prepareClusters[geocell]);
- cluster._markerCenter = cluster.getMarkerBounds().getCenter();
+ cluster._markerCenter = cluster.getBounds().getCenter();
cluster._distanceFrom0 = spherical.computeDistanceBetween({lat: 0, lng: 0}, cluster._markerCenter);
sortedClusters.push(cluster);
});
@@ -456,7 +456,7 @@ MarkerCluster.prototype.redraw = function(clusterDistance, force) {
var icon = self.getClusterIcon(cluster),
clusterOpts = {
"count": cluster.getItemLength(),
- "position": cluster.getMarkerBounds().getCenter(),
+ "position": cluster.getBounds().getCenter(),
"id": cluster.geocell
};
@@ -503,20 +503,6 @@ MarkerCluster.prototype.redraw = function(clusterDistance, force) {
if (new_or_update_clusters.length === 0 && delete_clusters === 0) {
return;
}
-/*
-
- var mvcArray = new BaseArrayClass(new_or_update_clusters);
- mvcArray.map(function(cluster, cb) {
- self.map.fromLatLngToPoint(cluster.position, function(point) {
- cluster._point = {x: point[0], y: point[1]};
- cluster._bounds = cluster.getMarkerBounds();
-
- cb(cluster);
- });
- }, function(clusters) {
-
- });
-*/
exec(null, self.errorHandler, self.getPluginName(), 'redrawClusters', [self.getId(), {
"resolution": resolution,

version: `cluster-20170727-0020`