Fix: ERROR: Plugin 'map_0_408997062859' not found, or is not a CDVPlugin
MODIFY
www/Map.js
www/Map.js
@@ -160,7 +160,9 @@ Map.prototype.getMap = function(mapId, div, options) {
cordova.fireDocumentEvent('plugin_touch', {});
- exec.call(this, function() {
+ exec.call({
+ _isReady: true
+ }, function() {
cordova.fireDocumentEvent('plugin_touch', {});
//------------------------------------------------------------------------
@@ -185,8 +187,11 @@ Map.prototype.getMap = function(mapId, div, options) {
// In order to work map.getVisibleRegion() correctly, wait a little.
//------------------------------------------------------------------------
setTimeout(function() {
- self.refreshLayout();
- self._isReady = true;
+ self.refreshLayout('getMap');
+ Object.defineProperty(self, "_isReady", {
+ value: true,
+ writable: false
+ });
self.trigger(event.MAP_READY, self);
}, 250);
}, self.errorHandler, 'CordovaGoogleMaps', 'getMap', args, {sync: true});
@@ -783,6 +788,10 @@ Map.prototype.addKmlOverlay = function(kmlOverlayOptions, callback) {
delete self.OVERLAYS[kmlId];
kmlOverlay = undefined;
});
+ kmlOverlay.defineProperty(kmlOverlay, "_isReady", {
+ value: true,
+ writable: false
+ });
if (typeof callback === "function") {
callback.call(self, kmlOverlay);
}
@@ -810,6 +819,10 @@ Map.prototype.addGroundOverlay = function(groundOverlayOptions, callback) {
delete self.OVERLAYS[result.id];
groundOverlay = undefined;
});
+ groundOverlay.defineProperty(groundOverlay, "_isReady", {
+ value: true,
+ writable: false
+ });
if (typeof callback === "function") {
callback.call(self, groundOverlay);
}
@@ -868,6 +881,10 @@ Map.prototype.addTileOverlay = function(tilelayerOptions, callback) {
delete self.OVERLAYS[result.id];
tileOverlay = undefined;
});
+ tileOverlay.defineProperty(tileOverlay, "_isReady", {
+ value: true,
+ writable: false
+ });
if (typeof callback === "function") {
callback.call(self, tileOverlay);
}
@@ -915,6 +932,10 @@ Map.prototype.addPolygon = function(polygonOptions, callback) {
delete self.OVERLAYS[result.id];
polygon = undefined;
});
+ polygon.defineProperty(polygon, "_isReady", {
+ value: true,
+ writable: false
+ });
if (typeof callback === "function") {
callback.call(self, polygon);
}
@@ -944,6 +965,10 @@ Map.prototype.addPolyline = function(polylineOptions, callback) {
delete self.OVERLAYS[result.id];
polyline = undefined;
});
+ polyline.defineProperty(polyline, "_isReady", {
+ value: true,
+ writable: false
+ });
if (typeof callback === "function") {
callback.call(self, polyline);
}
@@ -974,6 +999,11 @@ Map.prototype.addCircle = function(circleOptions, callback) {
delete self.OVERLAYS[result.id];
circle = undefined;
});
+
+ circle.defineProperty(circle, "_isReady", {
+ value: true,
+ writable: false
+ });
if (typeof callback === "function") {
callback.call(self, circle);
}
@@ -999,6 +1029,11 @@ Map.prototype.addMarker = function(markerOptions, callback) {
delete self.OVERLAYS[result.id];
marker = undefined;
});
+
+ marker.defineProperty(marker, "_isReady", {
+ value: true,
+ writable: false
+ });
if (typeof callback === "function") {
callback.call(self, marker);
}
@@ -1077,6 +1112,10 @@ Map.prototype.addMarkerCluster = function(markerClusterOptions, callback) {
self.OVERLAYS[result.id] = markerCluster;
+ markerCluster.defineProperty(markerCluster, "_isReady", {
+ value: true,
+ writable: false
+ });
if (typeof callback === "function") {
callback.call(self, markerCluster);
}

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -658,8 +658,8 @@ var _isResizeMapExecuting = false;
var _stopRequested = false;
function execCmd(success, error, pluginName, methodName, args, execOptions) {
- if (this._isRemoved) {
- // Ignore if the instance is already removed.
+ if (this._isRemoved || !this._isReady) {
+ // Ignore if the instance is already removed, or the instance is not ready.
return true;
}
execOptions = execOptions || {};

Fix: ERROR: Plugin 'map_0_408997062859' not found, or is not a CDVPlugin (#1726)