Bug fix: _gmaps_cdv_ Class Present After Calling Remove Method
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.2.0-beta-20180120-0115" 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.2.0-beta-20180120-2051" 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
@@ -69,6 +69,7 @@ Map.prototype.refreshLayout = function(event) {
};
Map.prototype.getMap = function(mapId, div, options) {
+
var self = this,
args = [mapId];
options = options || {};
@@ -135,7 +136,7 @@ Map.prototype.getMap = function(mapId, div, options) {
div.style.overflow = "hidden";
self.set("div", div);
- if (div.offsetWidth < 100 || div.offsetHeight < 100) {
+ if (div.offsetWidth < 200 || div.offsetHeight < 200) {
// If the map Div is too small, wait a little.
var callee = arguments.callee;
setTimeout(function() {
@@ -186,7 +187,9 @@ Map.prototype.getMap = function(mapId, div, options) {
div = div.parentNode;
}
}
- cordova.fireDocumentEvent("plugin_touch", {force: true});
+ cordova.fireDocumentEvent("plugin_touch", {
+ force: true
+ });
//------------------------------------------------------------------------
// In order to work map.getVisibleRegion() correctly, wait a little.
@@ -199,9 +202,9 @@ Map.prototype.getMap = function(mapId, div, options) {
self.refreshLayout();
self.trigger(event.MAP_READY, self);
}, 250);
- }, self.errorHandler, 'CordovaGoogleMaps', 'getMap', args, {sync: true});
-
-
+ }, self.errorHandler, 'CordovaGoogleMaps', 'getMap', args, {
+ sync: true
+ });
};
Map.prototype.setOptions = function(options) {
@@ -245,13 +248,17 @@ Map.prototype.setCameraTarget = function(latLng) {
Map.prototype.setCameraZoom = function(zoom) {
this.set('camera_zoom', zoom);
- exec.call(this, null, this.errorHandler, this.id, 'setCameraZoom', [zoom], {sync: true});
+ exec.call(this, 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.call(this, null, this.errorHandler, this.id, 'panBy', [x, y], {sync: true});
+ exec.call(this, null, this.errorHandler, this.id, 'panBy', [x, y], {
+ sync: true
+ });
return this;
};
@@ -296,7 +303,9 @@ Map.prototype.clear = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, this.id, 'clear', [], {sync: true});
+ }, self.errorHandler, this.id, 'clear', [], {
+ sync: true
+ });
};
/**
@@ -323,7 +332,9 @@ Map.prototype.setMapTypeId = function(mapTypeId) {
*/
Map.prototype.setCameraTilt = function(tilt) {
this.set('camera_tilt', tilt);
- exec.call(this, null, this.errorHandler, this.id, 'setCameraTilt', [tilt], {sync: true});
+ exec.call(this, null, this.errorHandler, this.id, 'setCameraTilt', [tilt], {
+ sync: true
+ });
return this;
};
@@ -333,7 +344,9 @@ Map.prototype.setCameraTilt = function(tilt) {
*/
Map.prototype.setCameraBearing = function(bearing) {
this.set('camera_bearing', bearing);
- exec.call(this, null, this.errorHandler, this.id, 'setCameraBearing', [bearing], {sync: true});
+ exec.call(this, null, this.errorHandler, this.id, 'setCameraBearing', [bearing], {
+ sync: true
+ });
return this;
};
@@ -347,7 +360,9 @@ Map.prototype.moveCameraZoomIn = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'moveCamera', [cameraPosition], {sync: true});
+ }, self.errorHandler, self.id, 'moveCamera', [cameraPosition], {
+ sync: true
+ });
};
Map.prototype.moveCameraZoomOut = function(callback) {
@@ -360,7 +375,9 @@ Map.prototype.moveCameraZoomOut = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'moveCamera', [cameraPosition], {sync: true});
+ }, self.errorHandler, self.id, 'moveCamera', [cameraPosition], {
+ sync: true
+ });
};
Map.prototype.animateCameraZoomIn = function(callback) {
@@ -374,7 +391,9 @@ Map.prototype.animateCameraZoomIn = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'animateCamera', [cameraPosition], {sync: true});
+ }, self.errorHandler, self.id, 'animateCamera', [cameraPosition], {
+ sync: true
+ });
};
Map.prototype.animateCameraZoomOut = function(callback) {
@@ -388,7 +407,9 @@ Map.prototype.animateCameraZoomOut = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'animateCamera', [cameraPosition], {sync: true});
+ }, self.errorHandler, self.id, 'animateCamera', [cameraPosition], {
+ sync: true
+ });
};
/**
@@ -425,7 +446,9 @@ Map.prototype.animateCamera = function(cameraPosition, callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'animateCamera', [cameraPosition], {sync: true});
+ }, self.errorHandler, self.id, 'animateCamera', [cameraPosition], {
+ sync: true
+ });
};
/**
@@ -461,13 +484,17 @@ Map.prototype.moveCamera = function(cameraPosition, callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'moveCamera', [cameraPosition], {sync: true});
+ }, self.errorHandler, self.id, 'moveCamera', [cameraPosition], {
+ sync: true
+ });
};
Map.prototype.setMyLocationEnabled = function(enabled) {
enabled = common.parseBoolean(enabled);
- exec.call(this, null, this.errorHandler, this.id, 'setMyLocationEnabled', [enabled], {sync: true});
+ exec.call(this, null, this.errorHandler, this.id, 'setMyLocationEnabled', [enabled], {
+ sync: true
+ });
return this;
};
Map.prototype.setIndoorEnabled = function(enabled) {
@@ -539,12 +566,11 @@ Map.prototype.remove = function(callback) {
if (self._isRemoved) {
return;
}
- self.trigger("remove");
Object.defineProperty(self, "_isRemoved", {
value: true,
writable: false
});
- var div = this.get('div');
+ var div = self.get('div');
if (div) {
while (div) {
if (div.style) {
@@ -560,6 +586,7 @@ Map.prototype.remove = function(callback) {
}
}
self.set('div', undefined);
+ self.trigger("remove");
// Close the active infoWindow
@@ -592,7 +619,10 @@ Map.prototype.remove = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, 'CordovaGoogleMaps', 'removeMap', [self.id], {sync: true, remove: true});
+ }, self.errorHandler, 'CordovaGoogleMaps', 'removeMap', [self.id], {
+ sync: true,
+ remove: true
+ });
};
@@ -679,9 +709,13 @@ Map.prototype.setDiv = function(div) {
}
}
exec.call(this, function() {
- cordova.fireDocumentEvent('plugin_touch', {force: true});
+ cordova.fireDocumentEvent('plugin_touch', {
+ force: true
+ });
self.refreshLayout();
- }, self.errorHandler, self.id, 'setDiv', args, {sync: true});
+ }, self.errorHandler, self.id, 'setDiv', args, {
+ sync: true
+ });
return self;
};
@@ -808,7 +842,10 @@ Map.prototype.addKmlOverlay = function(kmlOverlayOptions, callback) {
if (!invisible_dot || invisible_dot._isRemoved) {
// Create an invisible marker for kmlOverlay
self.addMarker({
- position: {lat: 0, lng: 0},
+ position: {
+ lat: 0,
+ lng: 0
+ },
icon: "skyblue",
visible: false
}, function(marker) {
@@ -934,7 +971,10 @@ Map.prototype.addPolygon = function(polygonOptions, callback) {
return [];
}
return hole.map(function(position) {
- return {"lat": position.lat, "lng": position.lng};
+ return {
+ "lat": position.lat,
+ "lng": position.lng
+ };
});
});
polygonOptions.strokeColor = common.HTMLColor2RGBA(polygonOptions.strokeColor || "#FF000080", 0.75);

Bug fix: _gmaps_cdv_ Class Present After Calling Remove Method #2011