Skip to content

Commit 7e8a5f1

Browse files
committed
Fix clear function to clear MARKERS and KML_LAYERS too
1 parent 23aac64 commit 7e8a5f1

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

www/googlemaps-cdv-plugin.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -670,14 +670,22 @@ App.prototype.getBearing = function(callback) {
670670
*/
671671
App.prototype.clear = function(callback) {
672672
var self = this;
673-
var overlayIDs = Object.keys(OVERLAYS);
674-
var overlayId;
675-
for (var i = 0; i < overlayIDs.length; i++) {
676-
overlayId = overlayIDs[i];
677-
OVERLAYS[overlayId].off();
678-
delete OVERLAYS[overlayId];
679-
}
680-
OVERLAYS = {};
673+
674+
var clearObj = function (obj) {
675+
var ids = Object.keys(obj);
676+
var id;
677+
for (var i = 0; i < ids.length; i++) {
678+
id = ids[i];
679+
obj[id].off();
680+
delete obj[id];
681+
}
682+
obj = {};
683+
};
684+
685+
clearObj(OVERLAYS);
686+
clearObj(MARKERS);
687+
clearObj(KML_LAYERS);
688+
681689
cordova.exec(function() {
682690
if (typeof callback === "function") {
683691
callback.call(self);

0 commit comments

Comments
 (0)