Prevent the "plugin is undefined" error
(Especially when you reload the index.html)
MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -396,8 +396,19 @@ module.exports = {
}
};
+cordova.addConstructor(function() {
+ if (!window.Cordova) {
+ window.Cordova = cordova;
+ }
+ window.plugin = window.plugin || {};
+ window.plugin.google = window.plugin.google || {};
+ window.plugin.google.maps = window.plugin.google.maps || module.exports;
document.addEventListener("deviceready", function() {
document.removeEventListener("deviceready", arguments.callee);
+ // workaround for issue on android-19: Cannot read property 'maps' of undefined
+ if (!window.plugin) { console.warn('re-init window.plugin'); window.plugin = window.plugin || {}; }
+ if (!window.plugin.google) { console.warn('re-init window.plugin.google'); window.plugin.google = window.plugin.google || {}; }
+ if (!window.plugin.google.maps) { console.warn('re-init window.plugin.google.maps'); window.plugin.google.maps = window.plugin.google.maps || module.exports; }
// Check the Google Maps Android API v2 if the device platform is Android.
if (/Android/i.test(window.navigator.userAgent)) {
@@ -410,3 +421,4 @@ document.addEventListener("deviceready", function() {
}, 'Environment', 'isAvailable', ['']);
}
});
+});

Prevent the "plugin is undefined" error
(Especially when you reload the index.html)