Skip to content

Commit 5a86796

Browse files
committed
Bug fix: Cordova framework does not catch the back button when the code run showDialog() method. (issue #624, #887)
1 parent ed0de23 commit 5a86796

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

www/googlemaps-cdv-plugin.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -400,23 +400,23 @@ App.prototype.setWatchDogTimer = function(time) {
400400

401401
};
402402

403-
function onBackButton() {
404-
_mapInstance.closeDialog();
403+
function onBackbutton() {
404+
_mapInstance.closeDialog();
405405
}
406406

407407
/**
408408
* @desc Open the map dialog
409409
*/
410410
App.prototype.showDialog = function() {
411-
this.set("isDialogOpen", true);
411+
document.addEventListener("backbutton", onBackbutton, false);
412412
cordova.exec(null, this.errorHandler, PLUGIN_NAME, 'showDialog', []);
413413
};
414414

415415
/**
416416
* @desc Close the map dialog
417417
*/
418418
App.prototype.closeDialog = function() {
419-
this.set("isDialogOpen", false);
419+
document.removeEventListener("backbutton", onBackbutton, false);
420420
cordova.exec(null, this.errorHandler, PLUGIN_NAME, 'closeDialog', []);
421421
};
422422

@@ -2636,11 +2636,6 @@ function getAllChildren(root) {
26362636

26372637
document.addEventListener("deviceready", function() {
26382638
document.removeEventListener("deviceready", arguments.callee);
2639-
document.addEventListener("backbutton", function() {
2640-
if (_mapInstance.get("isDialogOpen")) {
2641-
_mapInstance.closeDialog();
2642-
}
2643-
}, false);
26442639
plugin.google.maps.Map.isAvailable();
26452640
});
26462641

0 commit comments

Comments
 (0)