update: prevent memory leak
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.0.9-beta-20170915-1020" 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-20170915-1925" 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/CordovaGoogleMaps.m
src/ios/GoogleMaps/CordovaGoogleMaps.m
return;
}
+
pluginMap.isRemoved = YES;
- [pluginMap clear:nil];
+ //[pluginMap clear:nil];
+ [pluginMap pluginUnload];
CDVViewController *cdvViewController = (CDVViewController*)self.viewController;
[cdvViewController.pluginObjects setObject:pluginMap forKey:mapId];
pluginMap.mapCtrl = nil;
[self.pluginMaps removeObjectForKey:mapId];
pluginMap = nil;
+
+ [cdvViewController.pluginObjects removeObjectForKey:mapId];
}
/**
* Remove the map

MODIFY
www/Map.js
www/Map.js
@@ -532,7 +532,33 @@ Map.prototype.remove = function(callback) {
self.set('div', undefined);
self.trigger("remove");
- self.clear();
+
+ // Close the active infoWindow
+ var active_marker_id = self.get("active_marker_id");
+ if (active_marker_id && active_marker_id in self.MARKERS) {
+ self.MARKERS[active_marker_id].trigger(event.INFO_CLOSE);
+ }
+
+ var clearObj = function(obj) {
+ var ids = Object.keys(obj);
+ var id, instance;
+ for (var i = 0; i < ids.length; i++) {
+ id = ids[i];
+ instance = obj[id];
+ if (instance) {
+ if (typeof instance.remove === "function") {
+ instance.remove();
+ }
+ instance.off();
+ delete obj[id];
+ }
+ }
+ obj = {};
+ };
+
+ clearObj(self.OVERLAYS);
+ clearObj(self.MARKERS);
+ clearObj(self.KML_LAYERS);
exec(function() {
if (typeof callback === "function") {

update: prevent memory leak