(JS) Bug fix: can not detect another page that places over the map page
(I hate ionic!)
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.1.2-beta-20171206-1705" 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.1.2-beta-20171207-1825" 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
@@ -568,9 +568,9 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
if (domInfo == null) {
continue;
}
- if (domInfo.getDouble("depth") <= mapDivDepth) {
- continue;
- }
+ //if (domInfo.getDouble("depth") <= mapDivDepth) {
+ // continue;
+ //}
htmlElementRect = HTMLNodeRectFs.get(domId);
if (htmlElementRect.width() == 0 || htmlElementRect.height() == 0) {

MODIFY
src/ios/GoogleMaps/MyPluginLayer.m
src/ios/GoogleMaps/MyPluginLayer.m
domInfo = [self.pluginScrollView.debugView.HTMLNodes objectForKey:domId];
domDepth = [[domInfo objectForKey:@"depth"] doubleValue];
- if (domDepth < mapDivDepth) {
- continue;
- }
+ //if (domDepth < mapDivDepth) {
+ // continue;
+ //}
elementRect = [domInfo objectForKey:@"size"];
htmlElementRect = CGRectFromString(elementRect);
if (htmlElementRect.size.width == 0 || htmlElementRect.size.height == 0) {

MODIFY
www/Common.js
www/Common.js
@@ -329,7 +329,7 @@ function getDomDepth(dom, idx, zIndex) {
if (dom.nodeType !== Node.ELEMENT_NODE) {
return 0;
}
- var result = (zIndex) + (idx / (1 << Math.pow(idx, idx)) / 10);
+ var result = (zIndex) + (idx / (1 << Math.pow(idx, idx)) / 10) + 0.01;
/* for debug */
var currentDepth = parseFloat(dom.getAttribute("_depth")) || 0;
@@ -784,7 +784,47 @@ function getClickableRect(element, parentRect) {
return rect;
}
-function quickfilter(domPositions, minMapDepth) {
+function quickfilter(domPositions, minMapDepth, mapElemIDs) {
+ //console.log("before", JSON.parse(JSON.stringify(domPositions)));
+ var keys = Object.keys(domPositions);
+
+ var tree = {};
+ mapElemIDs.forEach(function(mapElemId) {
+ var size = domPositions[mapElemId].size;
+ var mapRect = {
+ left: size.left,
+ top: size.top,
+ right: size.left + size.width,
+ bottom: size.top + size.height
+ };
+
+ tree[mapElemId] = domPositions[mapElemId];
+
+ keys.forEach(function(elemId) {
+ if (domPositions[elemId].parent) {
+ return;
+ }
+ var domSize = {
+ left: domPositions[elemId].size.left,
+ top: domPositions[elemId].size.top,
+ right: domPositions[elemId].size.left + domPositions[elemId].size.width,
+ bottom: domPositions[elemId].size.bottom + domPositions[elemId].size.height
+ };
+ if (
+ ((domSize.left >= mapRect.left && domSize.left <= mapRect.right) ||
+ (domSize.right >= mapRect.left && domSize.right <= mapRect.right)) &&
+ ((domSize.top >= mapRect.top && domSize.top <= mapRect.bottom) ||
+ (domSize.bottom >= mapRect.top && domSize.bottom <= mapRect.bottom))
+ ) {
+ tree[elemId] = domPositions[elemId];
+ }
+ });
+ });
+
+ //console.log("after", JSON.parse(JSON.stringify(tree)));
+ return tree;
+}
+function quickfilterOld(domPositions, minMapDepth) {
var list = Object.keys(domPositions);
var finalDomPositions = {};
var i = 0, j = list.length - 1;

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -433,14 +433,30 @@ if (!cordova) {
var minMapDepth = 9999999;
var maxMapDepth = -1;
var stopFlag = false;
+ var mapElemIDs = [];
mapIDs.forEach(function(mapId) {
var div = MAPS[mapId].getDiv();
if (div) {
var elemId = div.getAttribute("__pluginDomId");
if (elemId) {
if (elemId in domPositions) {
+ mapElemIDs.push(elemId);
minMapDepth = Math.min(minMapDepth, domPositions[elemId].depth);
maxMapDepth = Math.max(maxMapDepth, domPositions[elemId].depth);
+
+ div = div.parentNode;
+ while(div) {
+ children = div.children;
+ for (var i = 0; i < children.length; i++) {
+ elemId = children[i].getAttribute("__pluginDomId");
+ if (elemId in domPositions) {
+ domPositions[elemId].parent = true;
+ }
+ }
+ div = div.parentNode;
+ }
+
+
} else {
// Is the map div removed?
if (window.document.querySelector) {
@@ -478,7 +494,7 @@ if (!cordova) {
if (touchableMapList.length === 0) {
finalDomPositions = domPositions;
} else {
- finalDomPositions = common.quickfilter(domPositions, minMapDepth);
+ finalDomPositions = common.quickfilter(domPositions, minMapDepth, mapElemIDs);
}
var prevKeys = Object.keys(prevFinal);
var currentKeys = Object.keys(finalDomPositions);
@@ -590,7 +606,8 @@ if (!cordova) {
domPositions[elemId] = {
size: rect,
depth: depth,
- zIndex: zIndex
+ zIndex: zIndex,
+ parent: element.className.indexOf("_gmaps_cdv_") > -1
};
parentRect = rect;
parentRect.elemId = elemId;

(JS) Bug fix: can not detect another page that places over the map page

(I hate ionic!)