Update: the methods of camera action execute as the sync mode
Update: markercluster code
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.0.0-beta3-20170904-2006" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="2.0.0-beta3-20170905-0026" 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
src/android/plugin/google/maps/PluginMarker.java
src/android/plugin/google/maps/PluginMarker.java
@@ -995,12 +995,17 @@ public class PluginMarker extends MyPlugin implements MyPluginInterface {
callback.onPostExecute(marker);
return;
}
+ if (marker == null) {
+ callback.onError("marker is removed");
+ return;
+ }
if (result.image.isRecycled()) {
//Maybe the task was canceled by map.clean()?
callback.onError("Can not get image for marker. Maybe the task was canceled by map.clean()?");
return;
}
+ synchronized (marker) {
String markerTag = marker.getTag() + "";
String markerIconTag = "marker_icon_" + markerTag;
String markerImgSizeTag = "marker_imageSize_" + markerTag;
@@ -1098,6 +1103,7 @@ public class PluginMarker extends MyPlugin implements MyPluginInterface {
callback.onPostExecute(marker);
}
+ }
};
AsyncLoadImage task = new AsyncLoadImage(cordova, webView, options, onComplete);

MODIFY
src/android/plugin/google/maps/PluginMarkerCluster.java
src/android/plugin/google/maps/PluginMarkerCluster.java
@@ -343,7 +343,7 @@ public class PluginMarkerCluster extends PluginMarker {
//Log.d(TAG, "---> deleteCnt : " + deleteCnt + ", newCnt : " + newCnt + ", updateCnt : " + updateCnt + ", reuseCnt : " + reuseCnt);
if (updateClusterIDs.size() == 0) {
- deleteProcess(params);
+ deleteProcess(clusterId, params);
callbackContext.success();
return;
}
@@ -448,7 +448,7 @@ public class PluginMarkerCluster extends PluginMarker {
marker = map.addMarker(new MarkerOptions()
.position(new LatLng(markerProperties.getDouble("lat"), markerProperties.getDouble("lng")))
.visible(false));
- marker.setTag(markerProperties.getString("id"));
+ marker.setTag(clusterId_markerId);
// Store the marker instance with markerId
synchronized (pluginMap.objects) {
@@ -526,7 +526,7 @@ public class PluginMarkerCluster extends PluginMarker {
synchronized (semaphore) {
try {
semaphore.wait();
- deleteProcess(params);
+ deleteProcess(clusterId, params);
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -534,7 +534,7 @@ public class PluginMarkerCluster extends PluginMarker {
callbackContext.success();
}
- private void deleteProcess(final JSONObject params) {
+ private void deleteProcess(final String clusterId, final JSONObject params) {
if (!params.has("delete")) {
return;
}
@@ -551,7 +551,7 @@ public class PluginMarkerCluster extends PluginMarker {
int deleteCnt = deleteClusters.length();
String clusterId_markerId;
for (int i = 0; i < deleteCnt; i++) {
- clusterId_markerId = deleteClusters.getString(i);
+ clusterId_markerId = clusterId + "-" + deleteClusters.getString(i);
deleteMarkers.add(clusterId_markerId);
}

MODIFY
src/ios/GoogleMaps/PluginMarkerCluster.m
src/ios/GoogleMaps/PluginMarkerCluster.m
@@ -265,7 +265,7 @@ const int GEOCELL_GRID_SIZE = 4;
if ([updateClusterIDs count] == 0) {
- [self deleteProcess:params];
+ [self deleteProcess:params clusterId:clusterId];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[(CDVCommandDelegateImpl *)self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
return;
@@ -413,7 +413,7 @@ const int GEOCELL_GRID_SIZE = 4;
} // for (int i = 0; i < [updateClusterIDs count]; i++) {..}
- [self deleteProcess:params];
+ [self deleteProcess:params clusterId:clusterId];
}]; // [[NSOperationQueue mainQueue] addOperationWithBlock: ^{..}
@@ -425,7 +425,7 @@ const int GEOCELL_GRID_SIZE = 4;
}]; // dispatch_async
}
-- (void) deleteProcess:(NSDictionary *) params{
+- (void) deleteProcess:(NSDictionary *) params clusterId:(NSString *)clusterId{
NSMutableArray *deleteClusters = nil;
if ([params objectForKey:@"delete"]) {
@@ -440,7 +440,8 @@ const int GEOCELL_GRID_SIZE = 4;
NSString *clusterId_markerId;
@synchronized (self.deleteMarkers) {
for (int i = 0; i < deleteCnt; i++) {
- clusterId_markerId = [deleteClusters objectAtIndex:i];
+ clusterId_markerId = [NSString stringWithFormat:@"%@-%@",
+ clusterId, [deleteClusters objectAtIndex:i]];
[self.deleteMarkers addObject:clusterId_markerId];
}
}

MODIFY
www/Map.js
www/Map.js
@@ -229,13 +229,13 @@ Map.prototype.setCameraTarget = function(latLng) {
Map.prototype.setCameraZoom = function(zoom) {
this.set('camera_zoom', zoom);
- exec(null, this.errorHandler, this.id, 'setCameraZoom', [zoom]);
+ exec(null, this.errorHandler, this.id, 'setCameraZoom', [zoom], {sync: true});
return this;
};
Map.prototype.panBy = function(x, y) {
x = parseInt(x, 10);
y = parseInt(y, 10);
- exec(null, this.errorHandler, this.id, 'panBy', [x, y]);
+ exec(null, this.errorHandler, this.id, 'panBy', [x, y], {sync: true});
return this;
};
@@ -304,7 +304,7 @@ Map.prototype.setMapTypeId = function(mapTypeId) {
*/
Map.prototype.setCameraTilt = function(tilt) {
this.set('camera_tilt', tilt);
- exec(null, this.errorHandler, this.id, 'setCameraTilt', [tilt]);
+ exec(null, this.errorHandler, this.id, 'setCameraTilt', [tilt], {sync: true});
return this;
};
@@ -314,7 +314,7 @@ Map.prototype.setCameraTilt = function(tilt) {
*/
Map.prototype.setCameraBearing = function(bearing) {
this.set('camera_bearing', bearing);
- exec(null, this.errorHandler, this.id, 'setCameraBearing', [bearing]);
+ exec(null, this.errorHandler, this.id, 'setCameraBearing', [bearing], {sync: true});
return this;
};
@@ -328,7 +328,7 @@ Map.prototype.moveCameraZoomIn = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'moveCamera', [cameraPosition]);
+ }, self.errorHandler, self.id, 'moveCamera', [cameraPosition], {sync: true});
};
Map.prototype.moveCameraZoomOut = function(callback) {
@@ -341,7 +341,7 @@ Map.prototype.moveCameraZoomOut = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'moveCamera', [cameraPosition]);
+ }, self.errorHandler, self.id, 'moveCamera', [cameraPosition], {sync: true});
};
Map.prototype.animateCameraZoomIn = function(callback) {
@@ -355,7 +355,7 @@ Map.prototype.animateCameraZoomIn = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'animateCamera', [cameraPosition]);
+ }, self.errorHandler, self.id, 'animateCamera', [cameraPosition], {sync: true});
};
Map.prototype.animateCameraZoomOut = function(callback) {
@@ -369,7 +369,7 @@ Map.prototype.animateCameraZoomOut = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'animateCamera', [cameraPosition]);
+ }, self.errorHandler, self.id, 'animateCamera', [cameraPosition], {sync: true});
};
/**
@@ -396,7 +396,7 @@ Map.prototype.animateCamera = function(cameraPosition, callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'animateCamera', [cameraPosition]);
+ }, self.errorHandler, self.id, 'animateCamera', [cameraPosition], {sync: true});
};
/**
@@ -422,7 +422,7 @@ Map.prototype.moveCamera = function(cameraPosition, callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'moveCamera', [cameraPosition]);
+ }, self.errorHandler, self.id, 'moveCamera', [cameraPosition], {sync: true});
};

MODIFY
www/MarkerCluster.js
www/MarkerCluster.js
@@ -273,6 +273,7 @@ MarkerCluster.prototype.remove = function() {
return;
}
+ var keys;
var resolution = self.get("resolution"),
activeMarkerId = self.map.get("active_marker_id"),
deleteClusters = [];
@@ -296,7 +297,7 @@ MarkerCluster.prototype.remove = function() {
}
}
} else if (self._clusters[resolution]) {
- var keys = Object.keys(self._clusters[resolution]);
+ keys = Object.keys(self._clusters[resolution]);
keys.forEach(function(geocell) {
var cluster = self._clusters[resolution][geocell];
var noClusterMode = cluster.getMode() === cluster.NO_CLUSTER_MODE;
@@ -315,14 +316,14 @@ MarkerCluster.prototype.remove = function() {
});
}
if (!noClusterMode) {
- deleteClusters.push(self.id + "-" + geocell);
+ deleteClusters.push(geocell);
}
cluster.remove();
});
}
exec(null, self.errorHandler, self.getPluginName(), 'remove', [self.getId()], {sync: true});
- var keys = Object.keys(self._markerMap);
+ keys = Object.keys(self._markerMap);
keys.forEach(function(markerId) {
delete self._markerMap[markerId]._cluster;
});
@@ -337,9 +338,9 @@ MarkerCluster.prototype.removeMarkerById = function(markerId) {
return null;
}
var self = this;
- if (markerId.indexOf(self.id + "-") === -1) {
- markerId = self.id + "-" + markerId;
- }
+ //if (markerId.indexOf(self.id + "-") === -1) {
+ // markerId = self.id + "-" + markerId;
+ //}
var markerOpts = self._markerMap[markerId];
if (!markerOpts) {
return;
@@ -405,8 +406,6 @@ MarkerCluster.prototype.getClusterByClusterId = function(clusterId) {
return null;
}
- var tmp = clusterId.split(";");
- clusterId = tmp[0];
var cluster = self._clusters[resolution][clusterId];
return cluster;
};
@@ -524,7 +523,7 @@ MarkerCluster.prototype._redraw = function(params) {
self._clusters[resolution] = self._clusters[resolution] || [];
}
var deleteClusters = {};
- var keys;
+ var keys, i, j;
var ignoreGeocells = [];
var allowGeocells = [swCell, neCell, nwCell, seCell];
@@ -536,8 +535,8 @@ MarkerCluster.prototype._redraw = function(params) {
{lat: expandedRegion.southwest.lat, lng: expandedRegion.northeast.lng},
expandedRegion.northeast
];
- for (var j = 0; j < 4; j++) {
- for (var i = 0.25; i < 1; i+= 0.25) {
+ for (j = 0; j < 4; j++) {
+ for (i = 0.25; i < 1; i+= 0.25) {
pos = plugin.google.maps.geometry.spherical.interpolate(coners[j], coners[j + 1], i);
cell = geomodel.getGeocell(pos.lat, pos.lng, cellLen);
@@ -668,7 +667,7 @@ MarkerCluster.prototype._redraw = function(params) {
}
});
} else {
- deleteClusters[self.id + "-" + geocell] = 1;
+ deleteClusters[geocell] = 1;
if (self.debug) {
console.log("---> (js:549)delete:" + geocell);
}
@@ -744,7 +743,7 @@ MarkerCluster.prototype._redraw = function(params) {
if (self.debug) {
console.log("---> (js:597)delete:" + geocell);
}
- deleteClusters[self.id + "-" + geocell] = 1;
+ deleteClusters[geocell] = 1;
}
cluster.remove();
});
@@ -780,9 +779,9 @@ MarkerCluster.prototype._redraw = function(params) {
self._markerMap[markerOpts.id] = markerOpts;
});
if (!noClusterMode) {
- deleteClusters[self.id + "-" + geocell] = 1;
+ deleteClusters[geocell] = 1;
if (self.debug) {
- console.log("---> (js:632)delete:" + self.id + "-" + geocell);
+ console.log("---> (js:632)delete:" + geocell);
}
}
cluster.remove();
@@ -923,7 +922,7 @@ MarkerCluster.prototype._redraw = function(params) {
while (i < sortedClusters.length) {
cluster = sortedClusters[i];
hit = false;
- for (var j = i + 1; j < sortedClusters.length; j++) {
+ for (j = i + 1; j < sortedClusters.length; j++) {
anotherCluster = sortedClusters[j];
distance = spherical.computeDistanceBetween(cluster._markerCenter, anotherCluster._markerCenter);
if (distance < params.clusterDistance) {
@@ -1086,7 +1085,7 @@ MarkerCluster.prototype.getClusterIcon = function(cluster) {
MarkerCluster.prototype._createMarker = function(markerOpts) {
var markerId = markerOpts.id;
var self = this;
- var marker = new Marker(self.getMap(), markerId, markerOpts, "MarkerCluster", exec);
+ var marker = new Marker(self.getMap(), self.id + "-" + markerId, markerOpts, "MarkerCluster", exec);
function updateProperty(prevValue, newValue, key) {
self._markerMap[markerId][key] = newValue;
}
@@ -1114,7 +1113,7 @@ MarkerCluster.prototype.getClusterByGeocellAndResolution = function(geocell, res
var cluster = self._clusters[resolution][geocell];
if (!cluster) {
- cluster = new Cluster(self.id + "-" +geocell, geocell);
+ cluster = new Cluster(geocell, geocell);
self._clusters[resolution][geocell] = cluster;
}
return cluster;

Update: the methods of camera action execute as the sync mode
Update: markercluster code