Fix: Application stuck in splash screen after install google maps native
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.3.0-beta-20180327-1638" 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.3.0-beta-20180403-1708" 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
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -8,19 +8,61 @@ if (!cordova) {
});
} else {
var common = require('./Common');
-
// The pluginInit.js must execute before loading HTML is completed.
require("./pluginInit")();
- (function() {
- // If <body> is not ready yet, wait 25ms, then execute this function again.
- if (!document.body || !document.body.firstChild) {
- common.nextTick(arguments.callee, 25);
- return;
+ 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() {
+ // 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)) {
+ //------------------------------------------------------------------------
+ // If Google Maps Android API v2 is not available,
+ // display the warning alert.
+ //------------------------------------------------------------------------
+ cordova.exec(null, function(message) {
+ alert(message);
+ }, 'Environment', 'isAvailable', ['']);
}
+ }, {
+ once: true
+ });
+ });
+
var execCmd = require("./commandQueueExecutor");
var cordovaGoogleMaps = new (require('./CordovaGoogleMaps'))(execCmd);
+ function onScrollEnd() {
+ cordovaGoogleMaps.invalidate.call(cordovaGoogleMaps, {force: true});
+ }
+
+ window.addEventListener("load", function() {
+ common.nextTick(function() {
+ // If the developer needs to recalculate the DOM tree graph,
+ // use `cordova.fireDocumentEvent('plugin_touch')`
+ document.addEventListener("plugin_touch", cordovaGoogleMaps.invalidate.bind(cordovaGoogleMaps));
+
+ // Repositioning 30 times when the device orientaion is changed.
+ window.addEventListener("orientationchange", function() {
+ cordovaGoogleMaps.invalidateN(30);
+ });
+
+ // If <body> is not ready yet, wait 25ms, then execute this function again.
+ // if (!document.body || !document.body.firstChild) {
+ // common.nextTick(arguments.callee, 25);
+ // return;
+ // }
+
// If the `transitionend` event is ocurred on the observed element,
// adjust the position and size of the map view
document.body.addEventListener("transitionend", function(e) {
@@ -43,29 +85,15 @@ if (!cordova) {
cordovaGoogleMaps.followMapDivPositionOnly.call(cordovaGoogleMaps);
}, true);
- function onScrollEnd() {
- cordovaGoogleMaps.invalidate.call(cordovaGoogleMaps, {force: true});
- }
- // When the app is initialized,
- // create the DOM hierarchy tree graph at once.
- document.addEventListener("deviceready", onScrollEnd, {
- once: true
+ onScrollEnd();
});
-
- // If the developer needs to recalculate the DOM tree graph,
- // use `cordova.fireDocumentEvent('plugin_touch')`
- document.addEventListener("plugin_touch", cordovaGoogleMaps.invalidate.bind(cordovaGoogleMaps));
-
- // Repositioning 30 times when the device orientaion is changed.
- window.addEventListener("orientationchange", function() {
- cordovaGoogleMaps.invalidateN(50);
});
-
/*****************************************************************************
* Name space
*****************************************************************************/
+
module.exports = {
event: require('./event'),
Animation: {
@@ -94,35 +122,4 @@ if (!cordova) {
poly: require('./poly')
}
};
-
- }());
-
-
- 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() {
- // 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)) {
- //------------------------------------------------------------------------
- // If Google Maps Android API v2 is not available,
- // display the warning alert.
- //------------------------------------------------------------------------
- cordova.exec(null, function(message) {
- alert(message);
- }, 'Environment', 'isAvailable', ['']);
- }
- }, {
- once: true
- });
- });
}

Fix: Application stuck in splash screen after install google maps native #2191