Add: trigger the plugin_touch event when you tap on marker (in order to detect the dialog something)
Update: Allow the backbutton event to another code
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.0.0-beta3-20170820-2025" 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.0.0-beta3-20170823-1850" 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
src/android/plugin/google/maps/PluginMap.java
src/android/plugin/google/maps/PluginMap.java
@@ -2019,6 +2019,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
}
this.onClusterEvent("cluster_click", marker);
} else {
+ webView.loadUrl("javascript:if(window.cordova){cordova.fireDocumentEvent('plugin_touch', {});}");
this.onMarkerEvent("marker_click", marker);
activeMarker = marker;
}

MODIFY
src/ios/GoogleMaps/GoogleMapsViewController.m
src/ios/GoogleMaps/GoogleMapsViewController.m
}
[self triggerClusterEvent:@"cluster_click" marker:marker];
} else {
+ [self execJS:@"javascript:if(window.cordova){cordova.fireDocumentEvent('plugin_touch', {});}"];
[self triggerMarkerEvent:@"marker_click" marker:marker];
//NSLog(@"--->activeMarker = %@", marker.userData);
self.map.selectedMarker = marker;

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -416,7 +416,11 @@ if (!cordova) {
document.addEventListener("plugin_touch", resetTimer);
window.addEventListener("orientationchange", resetTimer);
- function onBackButton() {
+
+ //----------------------------------------------------
+ // Stop all executions if the page will be closed.
+ //----------------------------------------------------
+ window.addEventListener("unload", function() {
// Request stop all tasks.
_stopRequested = true;
if (_isWaitMethod && _executingCnt > 0) {
@@ -424,17 +428,40 @@ if (!cordova) {
setTimeout(arguments.callee, 100);
return;
}
- // Executes the browser back history action
- // Since the cordova can not exit from app sometimes, handle the backbutton action in CordovaGoogleMaps
- cordova_exec(null, null, 'CordovaGoogleMaps', "backHistory", []);
+ });
- if (cordova) {
- resetTimer();
- // For other plugins, fire the `plugin_buckbutton` event instead of the `backbutton` evnet.
- cordova.fireDocumentEvent('plugin_backbutton', {});
+ //--------------------------------------------
+ // Hook the backbutton of Android action
+ //--------------------------------------------
+ var anotherBackbuttonHandler = null;
+ function onBackButton() {
+ cordova.fireDocumentEvent('plugin_touch', {});
+ if (anotherBackbuttonHandler) {
+ anotherBackbuttonHandler();
+ }
+ }
+ var _org_addEventListener = document.addEventListener;
+ var _org_removeEventListener = document.removeEventListener;
+ document.addEventListener = function(eventName, callback) {
+ var args = Array.prototype.slice.call(arguments, 0);
+ if (eventName.toLowerCase() !== "backbutton") {
+ _org_addEventListener.apply(this, args);
+ return;
+ }
+ if (!anotherBackbuttonHandler) {
+ anotherBackbuttonHandler = callback;
+ }
+ };
+ document.removeEventListener = function(eventName, callback) {
+ var args = Array.prototype.slice.call(arguments, 0);
+ if (eventName.toLowerCase() !== "backbutton") {
+ _org_removeEventListener.apply(this, args);
+ return;
}
+ if (anotherBackbuttonHandler === callback) {
+ anotherBackbuttonHandler = null;
}
- document.addEventListener("backbutton", onBackButton, false);
+ };
}());

Add: trigger the plugin_touch event when you tap on marker (in order to detect the dialog something)
Update: Allow the backbutton event to another code (#1639)