Add: prevent executing methods after the instance is removed
MODIFY
www/Circle.js
www/Circle.js
@@ -40,28 +40,28 @@ var Circle = function(map, circleId, circleOptions, _exec) {
// Sets event listeners
//-----------------------------------------------
self.on("center_changed", function(oldValue, center) {
- exec(null, self.errorHandler, self.getPluginName(), 'setCenter', [self.getId(), center.lat, center.lng]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setCenter', [self.getId(), center.lat, center.lng]);
});
self.on("fillColor_changed", function(oldValue, color) {
- exec(null, self.errorHandler, self.getPluginName(), 'setFillColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setFillColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
});
self.on("strokeColor_changed", function(oldValue, color) {
- exec(null, self.errorHandler, self.getPluginName(), 'setStrokeColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setStrokeColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
});
self.on("strokeWidth_changed", function(oldValue, width) {
- exec(null, self.errorHandler, self.getPluginName(), 'setStrokeWidth', [self.getId(), width]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setStrokeWidth', [self.getId(), width]);
});
self.on("clickable_changed", function(oldValue, clickable) {
- exec(null, self.errorHandler, self.getPluginName(), 'setClickable', [self.getId(), clickable]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setClickable', [self.getId(), clickable]);
});
self.on("radius_changed", function(oldValue, radius) {
- exec(null, self.errorHandler, self.getPluginName(), 'setRadius', [self.getId(), radius]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setRadius', [self.getId(), radius]);
});
self.on("zIndex_changed", function(oldValue, zIndex) {
- exec(null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
});
self.on("visible_changed", function(oldValue, visible) {
- exec(null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
});
};
@@ -140,7 +140,11 @@ Circle.prototype.setRadius = function(radius) {
Circle.prototype.remove = function() {
this.trigger(this.id + "_remove");
- exec(null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ exec.call(this, null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ Object.defineProperty(self, "_isRemoved", {
+ value: true,
+ writable: false
+ });
this.destroy();
};

MODIFY
www/GroundOverlay.js
www/GroundOverlay.js
@@ -41,25 +41,25 @@ var GroundOverlay = function(map, groundOverlayId, groundOverlayOptions, _exec)
// Sets event listeners
//-----------------------------------------------
self.on("visible_changed", function(oldValue, visible) {
- exec(null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
});
self.on("image_changed", function(oldValue, url) {
- exec(null, self.errorHandler, self.getPluginName(), 'setImage', [self.getId(), url]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setImage', [self.getId(), url]);
});
self.on("bounds_changed", function(oldValue, bounds) {
- exec(null, self.errorHandler, self.getPluginName(), 'setBounds', [self.getId(), bounds]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setBounds', [self.getId(), bounds]);
});
self.on("opacity_changed", function(oldValue, opacity) {
- exec(null, self.errorHandler, self.getPluginName(), 'setOpacity', [self.getId(), opacity]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setOpacity', [self.getId(), opacity]);
});
self.on("clickable_changed", function(oldValue, clickable) {
- exec(null, self.errorHandler, self.getPluginName(), 'setClickable', [self.getId(), clickable]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setClickable', [self.getId(), clickable]);
});
self.on("bearing_changed", function(oldValue, bearing) {
- exec(null, self.errorHandler, self.getPluginName(), 'setBearing', [self.getId(), bearing]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setBearing', [self.getId(), bearing]);
});
self.on("zIndex_changed", function(oldValue, zIndex) {
- exec(null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
});
};
@@ -143,7 +143,11 @@ GroundOverlay.prototype.getClickable = function() {
GroundOverlay.prototype.remove = function() {
this.trigger(this.id + "_remove");
- exec(null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ exec.call(this, null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ Object.defineProperty(self, "_isRemoved", {
+ value: true,
+ writable: false
+ });
this.destroy();
};

MODIFY
www/KmlOverlay.js
www/KmlOverlay.js
@@ -67,6 +67,10 @@ KmlOverlay.prototype.remove = function() {
setTimeout(function() {
self.trigger(self.id + "_remove");
}, 1000);
+ Object.defineProperty(self, "_isRemoved", {
+ value: true,
+ writable: false
+ });
};
module.exports = KmlOverlay;

MODIFY
www/Map.js
www/Map.js
@@ -53,7 +53,7 @@ var Map = function(id, _exec) {
if (prevId in self.MARKERS) {
self.MARKERS[prevId].trigger.call(self.MARKERS[prevId], event.INFO_CLOSE);
}
- exec(null, null, self.id, 'setActiveMarkerId', [newId]);
+ exec.call(self, null, null, self.id, 'setActiveMarkerId', [newId]);
});
};
@@ -67,7 +67,7 @@ Map.prototype.getId = function() {
* @desc Recalculate the position of HTML elements
*/
Map.prototype.refreshLayout = function(event) {
- exec(null, null, this.id, 'resizeMap', []);
+ exec.call(this, null, null, this.id, 'resizeMap', []);
};
Map.prototype.getMap = function(mapId, div, options) {
@@ -160,7 +160,7 @@ Map.prototype.getMap = function(mapId, div, options) {
cordova.fireDocumentEvent('plugin_touch', {});
- exec(function() {
+ exec.call(this, function() {
cordova.fireDocumentEvent('plugin_touch', {});
//------------------------------------------------------------------------
@@ -217,25 +217,25 @@ Map.prototype.setOptions = function(options) {
if (utils.isArray(options.styles)) {
options.styles = JSON.stringify(options.styles);
}
- exec(null, this.errorHandler, this.id, 'setOptions', [options]);
+ exec.call(this, null, this.errorHandler, this.id, 'setOptions', [options]);
return this;
};
Map.prototype.setCameraTarget = function(latLng) {
this.set('camera_target', latLng);
- exec(null, this.errorHandler, this.id, 'setCameraTarget', [latLng.lat, latLng.lng]);
+ exec.call(this, null, this.errorHandler, this.id, 'setCameraTarget', [latLng.lat, latLng.lng]);
return this;
};
Map.prototype.setCameraZoom = function(zoom) {
this.set('camera_zoom', zoom);
- exec(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(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;
};
@@ -273,7 +273,7 @@ Map.prototype.clear = function(callback) {
clearObj(self.MARKERS);
clearObj(self.KML_LAYERS);
- exec(function() {
+ exec.call(this, function() {
if (typeof callback === "function") {
callback.call(self);
}
@@ -294,7 +294,7 @@ Map.prototype.setMapTypeId = function(mapTypeId) {
return this.errorHandler("Invalid MapTypeId was specified.");
}
this.set('mapTypeId', mapTypeId);
- exec(null, this.errorHandler, this.id, 'setMapTypeId', [mapTypeId]);
+ exec.call(this, null, this.errorHandler, this.id, 'setMapTypeId', [mapTypeId]);
return this;
};
@@ -304,7 +304,7 @@ Map.prototype.setMapTypeId = function(mapTypeId) {
*/
Map.prototype.setCameraTilt = function(tilt) {
this.set('camera_tilt', tilt);
- exec(null, this.errorHandler, this.id, 'setCameraTilt', [tilt], {sync: true});
+ exec.call(this, null, this.errorHandler, this.id, 'setCameraTilt', [tilt], {sync: true});
return this;
};
@@ -314,7 +314,7 @@ Map.prototype.setCameraTilt = function(tilt) {
*/
Map.prototype.setCameraBearing = function(bearing) {
this.set('camera_bearing', bearing);
- exec(null, this.errorHandler, this.id, 'setCameraBearing', [bearing], {sync: true});
+ exec.call(this, null, this.errorHandler, this.id, 'setCameraBearing', [bearing], {sync: true});
return this;
};
@@ -324,7 +324,7 @@ Map.prototype.moveCameraZoomIn = function(callback) {
cameraPosition.zoom++;
cameraPosition.zoom = cameraPosition.zoom < 0 ? 0 : cameraPosition.zoom;
- exec(function() {
+ exec.call(this, function() {
if (typeof callback === "function") {
callback.call(self);
}
@@ -337,7 +337,7 @@ Map.prototype.moveCameraZoomOut = function(callback) {
cameraPosition.zoom--;
cameraPosition.zoom = cameraPosition.zoom < 0 ? 0 : cameraPosition.zoom;
- exec(function() {
+ exec.call(this, function() {
if (typeof callback === "function") {
callback.call(self);
}
@@ -351,7 +351,7 @@ Map.prototype.animateCameraZoomIn = function(callback) {
cameraPosition.zoom = cameraPosition.zoom < 0 ? 0 : cameraPosition.zoom;
cameraPosition.duration = 500;
- exec(function() {
+ exec.call(this, function() {
if (typeof callback === "function") {
callback.call(self);
}
@@ -365,7 +365,7 @@ Map.prototype.animateCameraZoomOut = function(callback) {
cameraPosition.zoom = cameraPosition.zoom < 0 ? 0 : cameraPosition.zoom;
cameraPosition.duration = 500;
- exec(function() {
+ exec.call(this, function() {
if (typeof callback === "function") {
callback.call(self);
}
@@ -392,7 +392,7 @@ Map.prototype.animateCamera = function(cameraPosition, callback) {
}
cameraPosition.target = target;
- exec(function() {
+ exec.call(this, function() {
if (typeof callback === "function") {
callback.call(self);
}
@@ -418,7 +418,7 @@ Map.prototype.moveCamera = function(cameraPosition, callback) {
target = common.convertToPositionArray(target);
}
cameraPosition.target = target;
- exec(function() {
+ exec.call(this, function() {
if (typeof callback === "function") {
callback.call(self);
}
@@ -428,23 +428,23 @@ Map.prototype.moveCamera = function(cameraPosition, callback) {
Map.prototype.setMyLocationEnabled = function(enabled) {
enabled = common.parseBoolean(enabled);
- exec(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) {
enabled = common.parseBoolean(enabled);
- exec(null, this.errorHandler, this.id, 'setIndoorEnabled', [enabled]);
+ exec.call(this, null, this.errorHandler, this.id, 'setIndoorEnabled', [enabled]);
return this;
};
Map.prototype.setTrafficEnabled = function(enabled) {
enabled = common.parseBoolean(enabled);
- exec(null, this.errorHandler, this.id, 'setTrafficEnabled', [enabled]);
+ exec.call(this, null, this.errorHandler, this.id, 'setTrafficEnabled', [enabled]);
return this;
};
Map.prototype.setCompassEnabled = function(enabled) {
var self = this;
enabled = common.parseBoolean(enabled);
- exec(null, self.errorHandler, this.id, 'setCompassEnabled', [enabled]);
+ exec.call(this, null, self.errorHandler, this.id, 'setCompassEnabled', [enabled]);
return this;
};
Map.prototype.getMyLocation = function(params, success_callback, error_callback) {
@@ -469,10 +469,10 @@ Map.prototype.getMyLocation = function(params, success_callback, error_callback)
error_callback.call(self, result);
}
};
- exec(successHandler, errorHandler, 'CordovaGoogleMaps', 'getMyLocation', [params], {sync: true});
+ exec.call(this, successHandler, errorHandler, 'CordovaGoogleMaps', 'getMyLocation', [params], {sync: true});
};
Map.prototype.getFocusedBuilding = function(callback) {
- exec(callback, this.errorHandler, this.id, 'getFocusedBuilding', []);
+ exec.call(this, callback, this.errorHandler, this.id, 'getFocusedBuilding', []);
};
Map.prototype.getVisible = function() {
return this.get("visible");
@@ -481,12 +481,12 @@ Map.prototype.setVisible = function(isVisible) {
var self = this;
isVisible = common.parseBoolean(isVisible);
self.set("visible", isVisible);
- exec(null, self.errorHandler, this.id, 'setVisible', [isVisible]);
+ exec.call(this, null, self.errorHandler, this.id, 'setVisible', [isVisible]);
return this;
};
Map.prototype.setClickable = function(isClickable) {
isClickable = common.parseBoolean(isClickable);
- exec(null, self.errorHandler, this.id, 'setClickable', [isClickable]);
+ exec.call(this, null, self.errorHandler, this.id, 'setClickable', [isClickable]);
return this;
};
@@ -496,7 +496,7 @@ Map.prototype.setClickable = function(isClickable) {
*/
Map.prototype.setAllGesturesEnabled = function(enabled) {
enabled = common.parseBoolean(enabled);
- exec(null, self.errorHandler, this.id, 'setAllGesturesEnabled', [enabled]);
+ exec.call(this, null, self.errorHandler, this.id, 'setAllGesturesEnabled', [enabled]);
return this;
};
@@ -560,11 +560,16 @@ Map.prototype.remove = function(callback) {
clearObj(self.MARKERS);
clearObj(self.KML_LAYERS);
- exec(function() {
+ exec.call(this, function() {
if (typeof callback === "function") {
callback.call(self);
}
}, self.errorHandler, 'CordovaGoogleMaps', 'removeMap', [self.id], {sync: true});
+
+ Object.defineProperty(self, "_isRemoved", {
+ value: true,
+ writable: false
+ });
};
@@ -579,7 +584,7 @@ Map.prototype.toDataURL = function(params, callback) {
params.uncompress = params.uncompress === true;
var self = this;
- exec(function(image) {
+ exec.call(this, function(image) {
if (typeof callback === "function") {
callback.call(self, image);
}
@@ -640,7 +645,7 @@ Map.prototype.setDiv = function(div) {
div = div.parentNode;
}
}
- exec(function() {
+ exec.call(this, function() {
cordova.fireDocumentEvent('plugin_touch', {});
self.refreshLayout();
}, self.errorHandler, self.id, 'setDiv', args, {sync: true});
@@ -679,7 +684,7 @@ Map.prototype.getVisibleRegion = function(callback) {
Map.prototype.fromLatLngToPoint = function(latLng, callback) {
var self = this;
if ("lat" in latLng && "lng" in latLng) {
- exec(function(result) {
+ exec.call(this, function(result) {
if (typeof callback === "function") {
callback.call(self, result);
}
@@ -697,7 +702,7 @@ Map.prototype.fromLatLngToPoint = function(latLng, callback) {
Map.prototype.fromPointToLatLng = function(pixel, callback) {
var self = this;
if (pixel.length == 2 && utils.isArray(pixel)) {
- exec(function(result) {
+ exec.call(this, function(result) {
if (typeof callback === "function") {
var latLng = new LatLng(result[0] || 0, result[1] || 0);
callback.call(self, latLng);
@@ -746,7 +751,7 @@ Map.prototype.setPadding = function(p1, p2, p3, p4) {
padding.left = padding.top;
break;
}
- exec(function(result) {
+ exec.call(this, function(result) {
if (typeof callback === "function") {
var latLng = new LatLng(result[0] || 0, result[1] || 0);
callback.call(self, result);
@@ -771,7 +776,7 @@ Map.prototype.addKmlOverlay = function(kmlOverlayOptions, callback) {
self.OVERLAYS[kmlId] = kmlOverlay;
self.KML_LAYERS[kmlId] = kmlOverlay;
- exec(function() {
+ exec.call(this, function() {
kmlOverlay.one(kmlId + "_remove", function() {
kmlOverlay.off();
delete self.KML_LAYERS[kmlId];
@@ -797,7 +802,7 @@ Map.prototype.addGroundOverlay = function(groundOverlayOptions, callback) {
groundOverlayOptions.zIndex = groundOverlayOptions.zIndex || 0;
groundOverlayOptions.bounds = common.convertToPositionArray(groundOverlayOptions.bounds);
- exec(function(result) {
+ exec.call(this, function(result) {
var groundOverlay = new GroundOverlay(self, result.id, groundOverlayOptions, exec);
self.OVERLAYS[result.id] = groundOverlay;
groundOverlay.one(result.id + "_remove", function() {
@@ -852,10 +857,10 @@ Map.prototype.addTileOverlay = function(tilelayerOptions, callback) {
if (!url || url === "(null)" || url === "undefined" || url === "null") {
url = "(null)";
}
- exec(null, self.errorHandler, self.id + "-tileoverlay", 'onGetTileUrlFromJS', [options._id, params.key, url]);
+ exec.call(this, null, self.errorHandler, self.id + "-tileoverlay", 'onGetTileUrlFromJS', [options._id, params.key, url]);
});
- exec(function(result) {
+ exec.call(this, function(result) {
var tileOverlay = new TileOverlay(self, result.id, tilelayerOptions, exec);
self.OVERLAYS[result.id] = tileOverlay;
tileOverlay.one(result.id + "_remove", function() {
@@ -901,7 +906,7 @@ Map.prototype.addPolygon = function(polygonOptions, callback) {
polygonOptions.zIndex = polygonOptions.zIndex || 0;
polygonOptions.geodesic = polygonOptions.geodesic === true;
- exec(function(result) {
+ exec.call(this, function(result) {
polygonOptions.points = _orgs;
var polygon = new Polygon(self, result.id, polygonOptions, exec);
self.OVERLAYS[result.id] = polygon;
@@ -930,7 +935,7 @@ Map.prototype.addPolyline = function(polylineOptions, callback) {
polylineOptions.clickable = polylineOptions.clickable === true;
polylineOptions.zIndex = polylineOptions.zIndex || 0;
polylineOptions.geodesic = polylineOptions.geodesic === true;
- exec(function(result) {
+ exec.call(this, function(result) {
polylineOptions.points = _orgs;
var polyline = new Polyline(self, result.id, polylineOptions, exec);
self.OVERLAYS[result.id] = polyline;
@@ -960,7 +965,7 @@ Map.prototype.addCircle = function(circleOptions, callback) {
circleOptions.zIndex = circleOptions.zIndex || 0;
circleOptions.radius = circleOptions.radius || 1;
- exec(function(result) {
+ exec.call(this, function(result) {
var circle = new Circle(self, result.id, circleOptions, exec);
self.OVERLAYS[result.id] = circle;
@@ -982,7 +987,7 @@ Map.prototype.addCircle = function(circleOptions, callback) {
Map.prototype.addMarker = function(markerOptions, callback) {
var self = this;
markerOptions = common.markerOptionsFilter(markerOptions);
- exec(function(result) {
+ exec.call(this, function(result) {
var marker = new Marker(self, result.id, markerOptions, "Marker", exec);
self.MARKERS[result.id] = marker;
@@ -1015,7 +1020,7 @@ Map.prototype.addMarkerCluster = function(markerClusterOptions, callback) {
return marker.position;
});
- exec(function(result) {
+ exec.call(this, function(result) {
var markerMap = {};
result.geocellList.forEach(function(geocell, idx) {

MODIFY
www/Marker.js
www/Marker.js
@@ -58,43 +58,43 @@ var Marker = function(map, id, markerOptions, className, _exec) {
});
self.on("position_changed", function(oldValue, position) {
- exec(null, self.errorHandler, self.getPluginName(), 'setPosition', [self.getId(), position.lat, position.lng]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setPosition', [self.getId(), position.lat, position.lng]);
});
self.on("rotation_changed", function(oldValue, rotation) {
- exec(null, self.errorHandler, self.getPluginName(), 'setRotation', [self.getId(), rotation]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setRotation', [self.getId(), rotation]);
});
self.on("snippet_changed", function(oldValue, snippet) {
- exec(null, self.errorHandler, self.getPluginName(), 'setSnippet', [self.getId(), snippet]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setSnippet', [self.getId(), snippet]);
});
self.on("visible_changed", function(oldValue, visible) {
- exec(null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
});
self.on("title_changed", function(oldValue, title) {
- exec(null, self.errorHandler, self.getPluginName(), 'setTitle', [self.getId(), title]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setTitle', [self.getId(), title]);
});
self.on("icon_changed", function(oldValue, url) {
- exec(null, self.errorHandler, self.getPluginName(), 'setIcon', [self.getId(), url]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setIcon', [self.getId(), url]);
});
self.on("flat_changed", function(oldValue, flat) {
- exec(null, self.errorHandler, self.getPluginName(), 'setFlat', [self.getId(), flat]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setFlat', [self.getId(), flat]);
});
self.on("draggable_changed", function(oldValue, draggable) {
- exec(null, self.errorHandler, self.getPluginName(), 'setDraggable', [self.getId(), draggable]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setDraggable', [self.getId(), draggable]);
});
self.on("anchor_changed", function(oldValue, anchor) {
- exec(null, self.errorHandler, self.getPluginName(), 'setIconAnchor', [self.getId(), anchor[0], anchor[1]]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setIconAnchor', [self.getId(), anchor[0], anchor[1]]);
});
self.on("infoWindowAnchor_changed", function(oldValue, anchor) {
- exec(null, self.errorHandler, self.getPluginName(), 'setInfoWindowAnchor', [self.getId(), anchor[0], anchor[1]]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setInfoWindowAnchor', [self.getId(), anchor[0], anchor[1]]);
});
self.on("zIndex_changed", function(oldValue, zIndex) {
- exec(null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
});
self.on("opacity_changed", function(oldValue, opacity) {
- exec(null, self.errorHandler, self.getPluginName(), 'setOpacity', [self.getId(), opacity]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setOpacity', [self.getId(), opacity]);
});
self.on("disableAutoPan_changed", function(oldValue, disableAutoPan) {
- exec(null, self.errorHandler, self.getPluginName(), 'setDisableAutoPan', [self.getId(), disableAutoPan]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setDisableAutoPan', [self.getId(), disableAutoPan]);
});
};
@@ -105,12 +105,18 @@ Marker.prototype.remove = function(callback) {
var self = this;
self.trigger(event.INFO_CLOSE); // close open infowindow, otherwise it will stay
self.trigger(self.id + "_remove");
- exec(function() {
+ exec.call(self, function() {
self.destroy();
if (typeof callback === "function") {
callback.call(self);
}
}, self.errorHandler, self.getPluginName(), 'remove', [this.getId()]);
+
+ Object.defineProperty(self, "_isRemoved", {
+ value: true,
+ writable: false
+ });
+ this.destroy();
};
Marker.prototype.getOptions = function() {
@@ -157,7 +163,7 @@ Marker.prototype.setAnimation = function(animation, callback) {
}
this.set("animation", animation);
- exec(function() {
+ exec.call(self, function() {
if (typeof callback === "function") {
callback.call(self);
}
@@ -261,13 +267,13 @@ Marker.prototype.showInfoWindow = function() {
}
this.set("isInfoWindowVisible", true);
this.map.set("active_marker_id", this.id);
- exec(null, this.errorHandler, this.getPluginName(), 'showInfoWindow', [this.getId()], {sync: true});
+ exec(this, null, this.errorHandler, this.getPluginName(), 'showInfoWindow', [this.getId()], {sync: true});
return this;
};
Marker.prototype.hideInfoWindow = function() {
if (this.get("isInfoWindowVisible")) {
this.set("isInfoWindowVisible", false);
- exec(null, this.errorHandler, this.getPluginName(), 'hideInfoWindow', [this.getId()], {sync: true});
+ exec(this, null, this.errorHandler, this.getPluginName(), 'hideInfoWindow', [this.getId()], {sync: true});
}
return this;
};

MODIFY
www/MarkerCluster.js
www/MarkerCluster.js
@@ -321,7 +321,11 @@ MarkerCluster.prototype.remove = function() {
cluster.remove();
});
}
- exec(null, self.errorHandler, self.getPluginName(), 'remove', [self.getId()], {sync: true});
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'remove', [self.getId()], {sync: true});
+ Object.defineProperty(self, "_isRemoved", {
+ value: true,
+ writable: false
+ });
keys = Object.keys(self._markerMap);
keys.forEach(function(markerId) {
@@ -369,7 +373,7 @@ MarkerCluster.prototype.removeMarkerById = function(markerId) {
markerOpts._cluster.marker = undefined;
delete self._markerMap[markerId];
if (isAdded) {
- exec(null, null, self.getPluginName(), 'redrawClusters', [self.getId(), {
+ exec.call(self, null, null, self.getPluginName(), 'redrawClusters', [self.getId(), {
"delete": [markerId]
}], {sync: true});
}
@@ -1039,7 +1043,7 @@ MarkerCluster.prototype._redraw = function(params) {
return;
}
- exec(function() {
+ exec(self, function() {
self.trigger("nextTask");
}, self.errorHandler, self.getPluginName(), 'redrawClusters', [self.getId(), {
"resolution": resolution,

MODIFY
www/Polygon.js
www/Polygon.js
@@ -32,14 +32,14 @@ var Polygon = function(map, polygonId, polygonOptions, _exec) {
var pointsProperty = common.createMvcArray(polygonOptions.points);
pointsProperty.on('set_at', function(index) {
var value = common.getLatLng(pointsProperty.getAt(index));
- exec(null, self.errorHandler, self.getPluginName(), 'setPointAt', [polygonId, index, value]);
+ exec(self, null, self.errorHandler, self.getPluginName(), 'setPointAt', [polygonId, index, value]);
});
pointsProperty.on('insert_at', function(index) {
var value = common.getLatLng(pointsProperty.getAt(index));
- exec(null, self.errorHandler, self.getPluginName(), 'insertPointAt', [polygonId, index, value]);
+ exec(self, null, self.errorHandler, self.getPluginName(), 'insertPointAt', [polygonId, index, value]);
});
pointsProperty.on('remove_at', function(index) {
- exec(null, self.errorHandler, self.getPluginName(), 'removePointAt', [polygonId, index]);
+ exec(self, null, self.errorHandler, self.getPluginName(), 'removePointAt', [polygonId, index]);
});
Object.defineProperty(self, "points", {
@@ -66,17 +66,17 @@ var Polygon = function(map, polygonId, polygonOptions, _exec) {
}
array.on('insert_at', function(idx) {
var value = common.getLatLng(array.getAt(idx));
- exec(null, self.errorHandler, self.getPluginName(), 'insertPointOfHoleAt', [polygonId, index, idx, value]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'insertPointOfHoleAt', [polygonId, index, idx, value]);
});
array.on('set_at', function(idx) {
var value = common.getLatLng(array.getAt(idx));
- exec(null, self.errorHandler, self.getPluginName(), 'setPointOfHoleAt', [polygonId, index, idx, value]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setPointOfHoleAt', [polygonId, index, idx, value]);
});
array.on('remove_at', function(idx) {
- exec(null, self.errorHandler, self.getPluginName(), 'removePointOfHoleAt', [polygonId, index, idx]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'removePointOfHoleAt', [polygonId, index, idx]);
});
- exec(null, self.errorHandler, self.getPluginName(), 'insertHoleAt', [polygonId, index, array.getArray()]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'insertHoleAt', [polygonId, index, array.getArray()]);
});
Object.defineProperty(self, "holes", {
@@ -97,25 +97,25 @@ var Polygon = function(map, polygonId, polygonOptions, _exec) {
// Sets event listeners
//-----------------------------------------------
self.on("clickable_changed", function(oldValue, clickable) {
- exec(null, self.errorHandler, self.getPluginName(), 'setClickable', [self.getId(), clickable]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setClickable', [self.getId(), clickable]);
});
self.on("geodesic_changed", function(oldValue, geodesic) {
- exec(null, self.errorHandler, self.getPluginName(), 'setGeodesic', [self.getId(), geodesic]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setGeodesic', [self.getId(), geodesic]);
});
self.on("zIndex_changed", function(oldValue, zIndex) {
- exec(null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
});
self.on("visible_changed", function(oldValue, visible) {
- exec(null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
});
self.on("strokeWidth_changed", function(oldValue, width) {
- exec(null, self.errorHandler, self.getPluginName(), 'setStrokeWidth', [self.getId(), width]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setStrokeWidth', [self.getId(), width]);
});
self.on("strokeColor_changed", function(oldValue, color) {
- exec(null, self.errorHandler, self.getPluginName(), 'setStrokeColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setStrokeColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
});
self.on("fillColor_changed", function(oldValue, color) {
- exec(null, self.errorHandler, self.getPluginName(), 'setFillColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setFillColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
});
};
@@ -124,7 +124,11 @@ utils.extend(Polygon, BaseClass);
Polygon.prototype.remove = function() {
this.trigger(this.id + "_remove");
- exec(null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ exec.call(this, null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ Object.defineProperty(self, "_isRemoved", {
+ value: true,
+ writable: false
+ });
this.destroy();
};
Polygon.prototype.getPluginName = function() {
@@ -152,7 +156,7 @@ Polygon.prototype.setPoints = function(points) {
for (i = 0; i < points.length; i++) {
mvcArray.push(common.getLatLng(points[i]), true);
}
- exec(null, self.errorHandler, self.getPluginName(), 'setPoints', [self.id, mvcArray.getArray()]);
+ exec.call(this, null, self.errorHandler, self.getPluginName(), 'setPoints', [self.id, mvcArray.getArray()]);
return self;
};
Polygon.prototype.getPoints = function() {
@@ -179,7 +183,7 @@ Polygon.prototype.setHoles = function(holes) {
mvcArray.push(newHole, true);
}
});
- exec(null, self.errorHandler, self.getPluginName(), 'setHoles', [self.id, mvcArray.getArray()]);
+ exec.call(this, null, self.errorHandler, self.getPluginName(), 'setHoles', [self.id, mvcArray.getArray()]);
return this;
};
Polygon.prototype.getHoles = function() {

MODIFY
www/Polyline.js
www/Polyline.js
@@ -29,14 +29,14 @@ var Polyline = function(map, polylineId, polylineOptions, _exec) {
var pointsProperty = common.createMvcArray(polylineOptions.points);
pointsProperty.on('set_at', function(index) {
var value = common.getLatLng(pointsProperty.getAt(index));
- exec(null, self.errorHandler, self.getPluginName(), 'setPointAt', [polylineId, index, value]);
+ exec(self, null, self.errorHandler, self.getPluginName(), 'setPointAt', [polylineId, index, value]);
});
pointsProperty.on('insert_at', function(index) {
var value = common.getLatLng(pointsProperty.getAt(index));
- exec(null, self.errorHandler, self.getPluginName(), 'insertPointAt', [polylineId, index, value]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'insertPointAt', [polylineId, index, value]);
});
pointsProperty.on('remove_at', function(index) {
- exec(null, self.errorHandler, self.getPluginName(), 'removePointAt', [polylineId, index]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'removePointAt', [polylineId, index]);
});
Object.defineProperty(self, "points", {
@@ -57,22 +57,22 @@ var Polyline = function(map, polylineId, polylineOptions, _exec) {
// Sets event listeners
//-----------------------------------------------
self.on("geodesic_changed", function(oldValue, geodesic) {
- exec(null, self.errorHandler, self.getPluginName(), 'setGeodesic', [self.getId(), geodesic]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setGeodesic', [self.getId(), geodesic]);
});
self.on("zIndex_changed", function(oldValue, zIndex) {
- exec(null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
});
self.on("clickable_changed", function(oldValue, clickable) {
- exec(null, self.errorHandler, self.getPluginName(), 'setClickable', [self.getId(), clickable]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setClickable', [self.getId(), clickable]);
});
self.on("visible_changed", function(oldValue, visible) {
- exec(null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
});
self.on("strokeWidth_changed", function(oldValue, width) {
- exec(null, self.errorHandler, self.getPluginName(), 'setStrokeWidth', [self.getId(), width]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setStrokeWidth', [self.getId(), width]);
});
self.on("strokeColor_changed", function(oldValue, color) {
- exec(null, self.errorHandler, self.getPluginName(), 'setStrokeColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setStrokeColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
});
};
@@ -105,7 +105,7 @@ Polyline.prototype.setPoints = function(points) {
"lng": points[i].lng
}, true);
}
- exec(null, self.errorHandler, self.getPluginName(), 'setPoints', [self.id, mvcArray.getArray()]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setPoints', [self.id, mvcArray.getArray()]);
return self;
};
Polyline.prototype.getPoints = function() {
@@ -162,12 +162,16 @@ Polyline.prototype.getMap = function() {
};
Polyline.prototype.remove = function() {
- exec(null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ exec.call(this, null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
this.trigger(this.id + "_remove");
var points = this.get("points");
if (points) {
points.clear();
}
+ Object.defineProperty(self, "_isRemoved", {
+ value: true,
+ writable: false
+ });
this.destroy();
};
module.exports = Polyline;

MODIFY
www/TileOverlay.js
www/TileOverlay.js
@@ -38,16 +38,16 @@ var TileOverlay = function(map, tileOverlayId, tileOverlayOptions, _exec) {
// Sets event listeners
//-----------------------------------------------
self.on("fadeIn_changed", function(oldValue, fadeIn) {
- exec(null, self.errorHandler, self.getPluginName(), 'setFadeIn', [self.getId(), fadeIn]);
+ exec(self, null, self.errorHandler, self.getPluginName(), 'setFadeIn', [self.getId(), fadeIn]);
});
self.on("opacity_changed", function(oldValue, opacity) {
- exec(null, self.errorHandler, self.getPluginName(), 'setOpacity', [self.getId(), opacity]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setOpacity', [self.getId(), opacity]);
});
self.on("zIndex_changed", function(oldValue, zIndex) {
- exec(null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
});
self.on("visible_changed", function(oldValue, visible) {
- exec(null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
});
};
@@ -104,7 +104,11 @@ TileOverlay.prototype.getVisible = function() {
TileOverlay.prototype.remove = function() {
this.trigger(this.id + "_remove");
- exec(null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ exec.call(this, null, this.errorHandler, this.getPluginName(), 'remove', [this.getId()]);
+ Object.defineProperty(self, "_isRemoved", {
+ value: true,
+ writable: false
+ });
this.destroy();
};

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -658,6 +658,10 @@ var _isResizeMapExecuting = false;
var _stopRequested = false;
function execCmd(success, error, pluginName, methodName, args, execOptions) {
+ if (this._isRemoved) {
+ // Ignore if the instance is already removed.
+ return true;
+ }
execOptions = execOptions || {};
var self = this;
commandQueue.push({

Add: prevent executing methods after the instance is removed