Bug fix: Can not remove all markers on iOS
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.0.9-beta-20170917-1642" 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.9-beta-20170917-1825" 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/ios/GoogleMaps/PluginCircle.m
src/ios/GoogleMaps/PluginCircle.m
circle.tappable = NO;
// Store the circle instance into self.objects
- NSString *circleId = [NSString stringWithFormat:@"circle_%lu", (unsigned long)circle.hash];
+ NSString *circleId = [NSString stringWithFormat:@"circle_%lu%d", command.hash, arc4random() % 100000];
circle.title = circleId;
[self.mapCtrl.objects setObject:circle forKey: circleId];

MODIFY
src/ios/GoogleMaps/PluginGroundOverlay.m
src/ios/GoogleMaps/PluginGroundOverlay.m
dispatch_async(dispatch_get_main_queue(), ^{
GMSGroundOverlay *groundOverlay = [GMSGroundOverlay groundOverlayWithBounds:bounds icon:nil];
- NSString *groundOverlayId = [NSString stringWithFormat:@"groundoverlay_%lu", (unsigned long)groundOverlay.hash];
+ NSString *groundOverlayId = [NSString stringWithFormat:@"groundoverlay_%lu%d", command.hash, arc4random() % 100000];
[self.mapCtrl.objects setObject:groundOverlay forKey: groundOverlayId];
groundOverlay.title = groundOverlayId;

MODIFY
src/ios/GoogleMaps/PluginMarker.m
src/ios/GoogleMaps/PluginMarker.m
NSDictionary *json = [command.arguments objectAtIndex:1];
__block NSMutableDictionary *createResult = [[NSMutableDictionary alloc] init];
- NSString *markerId = [NSString stringWithFormat:@"marker_%lu", command.hash];
+ NSString *markerId = [NSString stringWithFormat:@"marker_%lu%d", command.hash, arc4random() % 100000];
[createResult setObject:markerId forKey:@"id"];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
NSString *markerId = [command.arguments objectAtIndex:0];
GMSMarker *marker = [self.mapCtrl.objects objectForKey:markerId];
+ [self.mapCtrl.objects removeObjectForKey:markerId];
[self _removeMarker:marker];
+ marker = nil;
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[(CDVCommandDelegateImpl *)self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
marker.map = nil;
marker = nil;
+ [self.mapCtrl.executeQueue addOperationWithBlock:^{
if ([self.mapCtrl.objects objectForKey:iconCacheKey]) {
NSString *cacheKey = [self.mapCtrl.objects objectForKey:iconCacheKey];
-
if ([[UIImageCache sharedInstance].iconCacheKeys objectForKey:cacheKey]) {
int count = [[[UIImageCache sharedInstance].iconCacheKeys objectForKey:cacheKey] intValue];
count--;
[self.mapCtrl.objects removeObjectForKey:iconCacheKey];
}
}
+ }];
}
}

MODIFY
src/ios/GoogleMaps/PluginMarkerCluster.m
src/ios/GoogleMaps/PluginMarkerCluster.m
@@ -145,7 +145,7 @@ const int GEOCELL_GRID_SIZE = 4;
[geocellList addObject:[self getGeocell:lat lng:lng resolution:12]];
}
- NSString *clusterId = [NSString stringWithFormat:@"markercluster_%lu", command.hash];
+ NSString *clusterId = [NSString stringWithFormat:@"markercluster_%lu%d", command.hash, arc4random() % 100000];
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
[result setObject:geocellList forKey:@"geocellList"];
[result setObject:clusterId forKey:@"id"];

MODIFY
src/ios/GoogleMaps/PluginPolygon.m
src/ios/GoogleMaps/PluginPolygon.m
polygon.tappable = NO;
// Register polygon to the overlayManager.
- NSString *id = [NSString stringWithFormat:@"polygon_%lu", (unsigned long)polygon.hash];
+ NSString *id = [NSString stringWithFormat:@"polygon_%lu%d", command.hash, arc4random() % 100000];
[self.mapCtrl.objects setObject:polygon forKey: id];
polygon.title = id;

MODIFY
src/ios/GoogleMaps/PluginPolyline.m
src/ios/GoogleMaps/PluginPolyline.m
// disable default clickable feature.
polyline.tappable = NO;
- NSString *id = [NSString stringWithFormat:@"polyline_%lu", (unsigned long)polyline.hash];
+ NSString *id = [NSString stringWithFormat:@"polyline_%lu%d", command.hash, arc4random() % 100000];
[self.mapCtrl.objects setObject:polyline forKey: id];
polyline.title = id;

Bug fix: Can not remove all markers on iOS #1739