Prevent crash when you create many polylines
This patch maybe helpful to prevent the crash.
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.1.2-beta-20171208-1415" 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.1.2-beta-20171218-1109" 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 />
@@ -269,6 +269,8 @@ The native map view is faster, use less network usage, display 3D views, and eve
</feature>
</config-file>
+ <header-file src="src/ios/GoogleMaps/PluginObjects.h" />
+ <source-file src="src/ios/GoogleMaps/PluginObjects.m" />
<header-file src="src/ios/GoogleMaps/PluginCircle.h" />
<source-file src="src/ios/GoogleMaps/PluginCircle.m" />
<header-file src="src/ios/GoogleMaps/PluginGeocoder.h" />

MODIFY
src/ios/GoogleMaps/GoogleMapsViewController.h
src/ios/GoogleMaps/GoogleMapsViewController.h
#import "PluginUtil.h"
#import "NSData+Base64.h"
#import "MyPlgunProtocol.h"
+#import "PluginObjects.h"
#import <GoogleMaps/GoogleMaps.h>
@interface GoogleMapsViewController : UIViewController<GMSMapViewDelegate, GMSIndoorDisplayDelegate>
@property (nonatomic) BOOL isRenderedAtOnce;
@property (nonatomic) GMSMarker* activeMarker;
@property (nonatomic, readwrite, strong) NSString *mapDivId;
-@property (nonatomic, strong) NSMutableDictionary* objects;
+@property (nonatomic, strong) PluginObjects *objects;
@property (atomic, strong) NSOperationQueue *executeQueue;

MODIFY
src/ios/GoogleMaps/GoogleMapsViewController.m
src/ios/GoogleMaps/GoogleMapsViewController.m
self.clickable = YES;
self.isRenderedAtOnce = NO;
self.mapDivId = nil;
- self.objects = [[NSMutableDictionary alloc] init];
+ self.objects = [PluginObjects sharedInstance];
self.executeQueue = [NSOperationQueue new];
self.executeQueue.maxConcurrentOperationCount = 10;

ADD
src/ios/GoogleMaps/PluginObjects.h
+//
+// PluginObjects
+// cordova-googlemaps-plugin v2
+//
+// Created by Masashi Katsumata.
+//
+//
+#ifndef PluginObjects_h
+#define PluginObjects_h
+
+#import <Foundation/Foundation.h>
+
+@interface PluginObjects : NSObject
+
++ (PluginObjects*)sharedInstance;
+@property (nonatomic, strong) NSMutableDictionary *objects;
+
+// set
+- (void)setObject:(id)objId forKey:(NSString*)key;
+
+// get
+- (UIImage*)objectForKey:(NSString*)key;
+
+// remove
+- (void)removeObjectForKey:(NSString*)key;
+
+// remove all
+- (void)removeAllObjects;
+
+// return all keys
+- (NSArray<NSString *>*)allKeys;
+
+@end
+
+
+#endif

ADD
src/ios/GoogleMaps/PluginObjects.m
+//
+// PluginObjects
+// cordova-googlemaps-plugin v2
+//
+// Created by Masashi Katsumata.
+//
+//
+#import "PluginObjects.h"
+
+static PluginObjects *sharedInstance;
+
+
+@implementation PluginObjects
+
++ (PluginObjects*)sharedInstance {
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ sharedInstance = [[PluginObjects alloc] init];
+ sharedInstance.objects = [NSMutableDictionary dictionary];
+ });
+ return sharedInstance;
+}
+- (instancetype)init {
+ self = [super init];
+ return self;
+}
+
+- (void)setObject:(id)objId forKey:(NSString*)key {
+ @synchronized(self) {
+ [self.objects setObject:objId forKey:key];
+ }
+}
+
+- (UIImage*)objectForKey:(NSString*)key {
+ return [self.objects objectForKey:key];
+}
+- (void)removeObjectForKey:(NSString*)key {
+ [self.objects removeObjectForKey:key];
+}
+
+- (void)removeAllObjects {
+ [self.objects removeAllObjects];
+}
+
+- (NSArray<NSString *>*)allKeys {
+ return [self.objects allKeys];
+}
+
+
+@end

Prevent crash when you create many polylines  #1953

This patch maybe helpful to prevent the crash.