(JS) Bug fix: Error when leaving view using map.remove()
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.1.2-beta-20171102-2253" 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-20171106-1028" 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/Map.js
www/Map.js
@@ -620,6 +620,11 @@ Map.prototype.setDiv = function(div) {
}
self.set("div", null);
} else {
+ var currentDiv = this.get('div');
+ if (common.isDom(currentDiv)) {
+ currentDiv.removeAttribute('__pluginMapId');
+ currentDiv.removeAttribute('__pluginDomId');
+ }
div.setAttribute("__pluginMapId", self.id);
// Webkit redraw mandatory

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -690,6 +690,14 @@ if (!cordova) {
*/
map.one('remove', function() {
document.removeEventListener(mapId, nativeCallback);
+ var div = map.getDiv();
+ if (!div) {
+ div = document.querySelector("[__pluginMapId='" + mapId + "']");
+ }
+ if (div) {
+ div.removeAttribute('__pluginMapId');
+ div.removeAttribute('__pluginDomId');
+ }
MAPS[mapId].destroy();
delete MAPS[mapId];
map = undefined;

(JS) Bug fix: Error when leaving view using map.remove() #1862