Update positioning mechanism
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.3.0-beta-20180408-2242" 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-20180409-1717" 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/MyPluginLayout.java
src/android/plugin/google/maps/MyPluginLayout.java
@@ -466,8 +466,7 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
}
}
- Log.d(TAG, "---->index = " + index);
- scrollFrameLayout.addView(pluginOverlay.getView(), index + 1);
+ scrollFrameLayout.addView(pluginOverlay.getView(), (childCnt - index));
}
//mActivity.getWindow().getDecorView().requestFocus();

MODIFY
www/CordovaGoogleMaps.js
www/CordovaGoogleMaps.js
@@ -84,6 +84,10 @@ function CordovaGoogleMaps(execCmd) {
}
if (mutation.target.hasAttribute("__pluginDomId")) {
self.traceDomTree.call(self, mutation.target, mutation.target.getAttribute("__pluginDomId"), false);
+ var transformCSS = common.getStyle(mutation.target, "transform") || common.getStyle(mutation.target, "-webkit-transform");
+ if (transformCSS !== "none") {
+ cordova.fireDocumentEvent("transitionstart", mutation.target);
+ }
}
}
@@ -448,7 +452,7 @@ CordovaGoogleMaps.prototype.followMapDivPositionOnly = function(opts) {
self.prevMapRects[divId].size.top !== mapRects[divId].size.top ||
self.prevMapRects[divId].size.width !== mapRects[divId].size.width ||
self.prevMapRects[divId].size.height !== mapRects[divId].size.height ||
- self.prevMapRects[divId].zIndex !== mapRects[divId].zIndex)) {
+ self.prevMapRects[divId].zIndex.z !== mapRects[divId].zIndex.z)) {
changed = true;
}
}
@@ -459,7 +463,9 @@ CordovaGoogleMaps.prototype.followMapDivPositionOnly = function(opts) {
// If changed, move the map views.
if (changed || opts.force) {
cordova_exec(null, null, 'CordovaGoogleMaps', 'updateMapPositionOnly', [mapRects]);
+ return changed;
}
+ return false;
};
CordovaGoogleMaps.prototype.invalidateN = function(cnt) {

MODIFY
www/Map.js
www/Map.js
@@ -149,11 +149,11 @@ Map.prototype.getMap = function(meta, div, options) {
div.style.overflow = "hidden";
self.set("div", div);
- if (div.offsetWidth < 200 || div.offsetHeight < 200) {
+ if (div.offsetWidth < 100 || div.offsetHeight < 100) {
// If the map Div is too small, wait a little.
var callee = arguments.callee;
setTimeout(function() {
- callee.call(self, mapId, div, options);
+ callee.call(self, meta, div, options);
}, 250 + Math.random() * 100);
return;
}

MODIFY
www/StreetViewPanorama.js
www/StreetViewPanorama.js
@@ -100,7 +100,6 @@ StreetViewPanorama.prototype.getPanorama = function(meta, div, options) {
options.controls.zoom = common.defaultTrueOption(options.controls.streetNames);
self.set("control_navigation", options.controls.navigation, true);
self.set("control_streetNames", options.controls.streetNames, true);
- console.log(options);
// Gets the map div size.
// The plugin needs to consider the viewport zoom ratio
@@ -260,7 +259,7 @@ StreetViewPanorama.prototype.remove = function(callback) {
};
StreetViewPanorama.prototype._onPanoramaCameraChange = function(eventName, cameraPosition) {
var self = this;
- self.set('camera', Object.assign(self.get("camera"), cameraPosition));
+ self.set('camera', Object.assign(self.get("camera") || {}, cameraPosition));
self.set('camera_zoom', cameraPosition.zoom);
self.set('camera_bearing', cameraPosition.bearing);
self.set('camera_tilt', cameraPosition.viewAngle || cameraPosition.tilt);

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -36,9 +36,9 @@ if (!cordova) {
var execCmd = require("./commandQueueExecutor");
var cordovaGoogleMaps = new (require('./CordovaGoogleMaps'))(execCmd);
- function onScrollEnd() {
+ var onScrollEnd = function() {
cordovaGoogleMaps.invalidate.call(cordovaGoogleMaps, {force: true});
- }
+ };
window.addEventListener("load", function() {
common.nextTick(function() {
@@ -59,25 +59,30 @@ if (!cordova) {
// 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) {
- if (!e.target.hasAttribute("__pluginDomId")) {
- return;
- }
- cordovaGoogleMaps.invalidateN(5);
- }, true);
-
- // If the `scroll` event is ocurred on the observed element,
- // adjust the position and size of the map view
var scrollEndTimer = null;
- document.body.addEventListener("scroll", function(e) {
+ function followMaps() {
+ if (cordovaGoogleMaps.followMapDivPositionOnly.call(cordovaGoogleMaps)) {
if (scrollEndTimer) {
clearTimeout(scrollEndTimer);
}
scrollEndTimer = setTimeout(function() {
- common.nextTick(onScrollEnd);
+ common.nextTick(followMaps);
}, 100);
- cordovaGoogleMaps.followMapDivPositionOnly.call(cordovaGoogleMaps);
- }, true);
+ }
+ }
+
+ document.addEventListener("transitionstart", followMaps);
+ document.body.addEventListener("transitionend", followMaps);
+ // document.body.addEventListener("transitionend", function(e) {
+ // if (!e.target.hasAttribute("__pluginDomId")) {
+ // return;
+ // }
+ // cordovaGoogleMaps.invalidateN(5);
+ // }, true);
+
+ // If the `scroll` event is ocurred on the observed element,
+ // adjust the position and size of the map view
+ document.body.addEventListener("scroll", followMaps, true);
common.nextTick(onScrollEnd);
});

Update positioning mechanism