update: reduce the number of invalidate process
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.2.9-beta-20180325-0117" 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.2.9-beta-20180325-1924" 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/CordovaGoogleMaps.js
www/CordovaGoogleMaps.js
@@ -390,14 +390,17 @@ CordovaGoogleMaps.prototype.invalidate = function(opts) {
// Recheck the DOM positions
//-------------------------------
var self = this;
+ //console.log("-->invalidate", JSON.parse(JSON.stringify(opts)));
opts = opts || {};
if (opts.force) {
self.isThereAnyChange = true;
self.isSuspended = false;
+ self.resume();
}
common.nextTick(function() {
+ self.resume.call(self);
self.putHtmlElements.call(self);
if (opts.force) {
self.followMapDivPositionOnly.call(self, opts);
@@ -452,6 +455,22 @@ CordovaGoogleMaps.prototype.followMapDivPositionOnly = function(opts) {
}
};
+CordovaGoogleMaps.prototype.invalidateN = function(cnt) {
+ var self = this;
+ if (self.cnt > 0) {
+ return;
+ }
+ self.cnt = cnt;
+ var timer = setInterval(function() {
+ self.followMapDivPositionOnly.call(self);
+ self.cnt--;
+ if (self.cnt === 0) {
+ clearInterval(timer);
+ self.invalidate.call(self, {force: true});
+ }
+ }, 50);
+};
+
CordovaGoogleMaps.prototype.getMap = function(div, mapOptions) {
//----------------------------------------------------------------------------

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -27,15 +27,7 @@ if (!cordova) {
if (!e.target.hasAttribute("__pluginDomId")) {
return;
}
- var cnt = 5;
- var timer = setInterval(function() {
- cnt--;
- if (cnt > 0) {
- cordovaGoogleMaps.invalidate({force: true});
- } else {
- clearInterval(timer);
- }
- }, 50);
+ cordovaGoogleMaps.invalidateN(5);
}, true);
// If the `scroll` event is ocurred on the observed element,
@@ -65,15 +57,7 @@ if (!cordova) {
// Repositioning 30 times when the device orientaion is changed.
window.addEventListener("orientationchange", function() {
- var cnt = 30;
- var timer = setInterval(function() {
- cnt--;
- if (cnt > 0) {
- onScrollEnd();
- } else {
- clearInterval(timer);
- }
- }, 50);
+ cordovaGoogleMaps.invalidateN(30);
});

update: reduce the number of invalidate process