Bug fix: Can not click on button outside the map div
MODIFY
src/android/plugin/google/maps/MyPluginLayout.java
src/android/plugin/google/maps/MyPluginLayout.java
@@ -517,11 +517,12 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
}
private String findClickedDom(String domId, PointF clickPoint, boolean isMapChild, Overflow overflow) {
- //Log.d(TAG, "----domId = " + domId + ", clickPoint = " + clickPoint.x + ", " + clickPoint.y);
+ //Log.d(TAG, "-(findClickedDom)domId = " + domId + ", clickPoint = " + clickPoint.x + ", " + clickPoint.y);
String maxDomId = null;
RectF rect;
Bundle domInfo = HTMLNodes.get(domId);
+ Bundle zIndexProp;
int containMapCnt = 0;
if (domInfo.containsKey("containMapIDs")) {
Set<String> keys = domInfo.getBundle("containMapIDs").keySet();
@@ -542,11 +543,12 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
overflow.rect = HTMLNodeRectFs.get(domId);
}
- //Log.d(TAG, "----domId = " + domId + ", domInfo = " + domInfo);
+ //Log.d(TAG, "--domId = " + domId + ", domInfo = " + domInfo);
+ zIndexProp = domInfo.getBundle("zIndex");
ArrayList<String> children = domInfo.getStringArrayList("children");
- if ((containMapCnt > 0 || isMapChild || "none".equals(pointerEvents)) && children != null && children.size() > 0) {
+ if ((containMapCnt > 0 || isMapChild || "none".equals(pointerEvents) || zIndexProp.getBoolean("isInherit")) && children != null && children.size() > 0) {
int maxZindex = (int) Double.NEGATIVE_INFINITY;
- int zIndex;
+ int zIndexValue;
String childId, grandChildId;
ArrayList<String> grandChildren;
for (int i = children.size() - 1; i >= 0; i--) {
@@ -556,8 +558,9 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
continue;
}
- zIndex = domInfo.getInt("zIndex");
- if (maxZindex < zIndex) {
+ zIndexProp = domInfo.getBundle("zIndex");
+ zIndexValue = zIndexProp.getInt("z");
+ if (maxZindex < zIndexValue || zIndexProp.getBoolean("isInherit")) {
grandChildren = domInfo.getStringArrayList("children");
if (grandChildren == null || grandChildren.size() == 0) {
rect = HTMLNodeRectFs.get(childId);
@@ -575,16 +578,22 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
continue;
}
- //Log.d(TAG, "----childId = " + childId + ", domInfo = " + domInfo);
+ //Log.d(TAG, "---childId = " + childId + ", domInfo = " + domInfo);
if ("none".equals(domInfo.getString("pointerEvents"))) {
continue;
}
+ //Log.d(TAG, "----childId = " + childId + ", maxZindex = " + maxZindex + ", zIndexValue = " + zIndexValue);
+ if (maxZindex < zIndexValue) {
+ maxZindex = zIndexValue;
maxDomId = childId;
+ }
} else {
grandChildId = findClickedDom(childId, clickPoint, isMapChild, overflow);
- //Log.d(TAG, "----findClickedDom("+ childId + ") -> " + grandChildId);
+ //Log.d(TAG, "---findClickedDom("+ childId + ") -> " + grandChildId);
if (grandChildId == null) {
grandChildId = childId;
+ } else {
+ zIndexValue = HTMLNodes.get(grandChildId).getBundle("zIndex").getInt("z");
}
rect = HTMLNodeRectFs.get(grandChildId);
if (overflow != null ) {
@@ -606,9 +615,12 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
if ("none".equals(domInfo.getString("pointerEvents"))) {
continue;
}
+ //Log.d(TAG, "----grandChildId = " + grandChildId + ", maxZindex = " + maxZindex + ", zIndexValue = " + zIndexValue);
+ if (maxZindex < zIndexValue) {
+ maxZindex = zIndexValue;
maxDomId = grandChildId;
}
- maxZindex = zIndex;
+ }
}
}
}

MODIFY
src/ios/GoogleMaps/MyPluginLayer.m
src/ios/GoogleMaps/MyPluginLayer.m
NSString *maxDomId = nil;
CGRect rect;
float right, bottom;
+ NSDictionary *zIndexProp;
domInfo = [self.pluginScrollView.debugView.HTMLNodes objectForKey:domId];
overflow.rect = CGRectFromString([domInfo objectForKey:@"size"]);
}
- if ((containMapCnt > 0 || isMapChild || [@"none" isEqualToString:pointerEvents]) && children != nil && children.count > 0) {
+ zIndexProp = [domInfo objectForKey:@"zIndex"];
+ if ((containMapCnt > 0 || isMapChild || [@"none" isEqualToString:pointerEvents] ||
+ [[zIndexProp objectForKey:@"isInherit"] boolValue]) && children != nil && children.count > 0) {
int maxZIndex = -1215752192;
- int zIndex;
+ int zIndexValue;
NSString *childId, *grandChildId;
NSArray *grandChildren;
for (int i = (int)children.count - 1; i >= 0; i--) {
childId = [children objectAtIndex:i];
domInfo = [self.pluginScrollView.debugView.HTMLNodes objectForKey:childId];
- zIndex = [[domInfo objectForKey:@"zIndex"] intValue];
+ zIndexProp = [domInfo objectForKey:@"zIndex"];
+ zIndexValue = [[zIndexProp objectForKey:@"z"] intValue];
+
+ if (maxZIndex < zIndexValue || [[zIndexProp objectForKey:@"isInherit"] boolValue]) {
- if (maxZIndex < zIndex) {
grandChildren = [domInfo objectForKey:@"children"];
if (grandChildren == nil || grandChildren.count == 0) {
rect = CGRectFromString([domInfo objectForKey:@"size"]);
if ([@"none" isEqualToString:[domInfo objectForKey:@"pointerEvents"]]) {
continue;
}
+ if (maxZIndex < zIndexValue) {
+ maxZIndex = zIndexValue;
maxDomId = childId;
+ }
} else {
grandChildId = [self findClickedDom:childId withPoint:clickPoint isMapChild: isMapChild overflow:overflow];
if (grandChildId == nil) {
+ domInfo = [self.pluginScrollView.debugView.HTMLNodes objectForKey:grandChildId];
grandChildId = childId;
- }
+ } else {
domInfo = [self.pluginScrollView.debugView.HTMLNodes objectForKey:grandChildId];
+ zIndexProp = [domInfo objectForKey:@"zIndex"];
+ zIndexValue = [[zIndexProp objectForKey:@"z"] intValue];
+ }
rect = CGRectFromString([domInfo objectForKey:@"size"]);
right = rect.origin.x + rect.size.width;
if ([@"none" isEqualToString:[domInfo objectForKey:@"pointerEvents"]]) {
continue;
}
+ if (maxZIndex < zIndexValue) {
+ maxZIndex = zIndexValue;
maxDomId = grandChildId;
}
- maxZIndex = zIndex;
+ }
+
}
}
}

MODIFY
www/Common.js
www/Common.js
@@ -322,18 +322,21 @@ function getZIndex(dom) {
}
}
- if (z === "auto") {
+ var isInherit = false;
+ if (z === "unset" || z === "initial") {
z = 0;
- } else if (z === "inherit") {
- z = 0;
- } else if (z === "initial" || z === "unset") {
+ } else if (z === "auto" || z === "inherit") {
z = 0;
+ isInherit = true;
} else {
z = parseInt(z);
}
- //dom.setAttribute("__ZIndex", z);
+ dom.setAttribute("__ZIndex", z);
internalCache[elemId] = z + parentZIndex;
- return z;
+ return {
+ isInherit: isInherit,
+ z: z
+ };
}
// Get CSS value of an element

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -518,7 +518,7 @@ if (!cordova) {
}
// Get the z-index CSS
- var zIndex = common.getZIndex(element);
+ var zIndexProp = common.getZIndex(element);
// Calculate dom clickable region
var rect = common.getDivRect(element);
@@ -529,7 +529,7 @@ if (!cordova) {
pointerEvents: common.getStyle(element, 'pointer-events'),
isMap: element.hasAttribute("__pluginMapId"),
size: rect,
- zIndex: zIndex,
+ zIndex: zIndexProp,
overflowX: common.getStyle(element, "overflow-x"),
overflowY: common.getStyle(element, "overflow-y"),
children: [],
@@ -537,7 +537,7 @@ if (!cordova) {
};
var containMapCnt = (Object.keys(domPositions[elemId].containMapIDs)).length;
isMapChild = isMapChild || domPositions[elemId].isMap;
- if ((containMapCnt > 0 || isMapChild || domPositions[elemId].pointerEvents === "none") && element.children.length > 0) {
+ if ((containMapCnt > 0 || isMapChild || domPositions[elemId].pointerEvents === "none" || zIndexProp.isInherit) && element.children.length > 0) {
var child;
for (var i = 0; i < element.children.length; i++) {
child = element.children[i];

Bug fix: Can not click on button outside the map div #2083