Fix: Ionic toast notification is not clickable when displayed over Google Maps plugin
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.1.2-beta-20180111-1605" 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-20180112-1156" 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
@@ -511,6 +511,7 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
}
isMapChild = isMapChild || domInfo.getBoolean("isMap", false);
+ String pointerEvents = domInfo.getString("pointerEvents");
String overflowX = domInfo.getString("overflowX");
String overflowY = domInfo.getString("overflowY");
if ("hidden".equals(overflowX) || "scroll".equals(overflowX) ||
@@ -523,7 +524,7 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
//Log.d(TAG, "----domId = " + domId + ", domInfo = " + domInfo);
ArrayList<String> children = domInfo.getStringArrayList("children");
- if ((containMapCnt > 0 || isMapChild) && children != null && children.size() > 0) {
+ if ((containMapCnt > 0 || isMapChild || "none".equals(pointerEvents)) && children != null && children.size() > 0) {
int maxZindex = (int) Double.NEGATIVE_INFINITY;
int zIndex;
String childId, grandChildId;
@@ -531,7 +532,6 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
for (int i = children.size() - 1; i >= 0; i--) {
childId = children.get(i);
domInfo = HTMLNodes.get(childId);
- //Log.d(TAG, "----childId = " + childId + ", domInfo = " + domInfo);
if (domInfo == null) {
continue;
}
@@ -554,14 +554,17 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
if (!rect.contains(clickPoint.x, clickPoint.y)) {
continue;
}
- if (isMapChild) {
- return childId;
+
+ //Log.d(TAG, "----childId = " + childId + ", domInfo = " + domInfo);
+ if ("none".equals(domInfo.getString("pointerEvents"))) {
+ continue;
}
maxDomId = childId;
} else {
grandChildId = findClickedDom(childId, clickPoint, isMapChild, overflow);
+ //Log.d(TAG, "----findClickedDom("+ childId + ") -> " + grandChildId);
if (grandChildId == null) {
- continue;
+ grandChildId = childId;
}
rect = HTMLNodeRectFs.get(grandChildId);
if (overflow != null ) {
@@ -578,8 +581,10 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
continue;
}
- if (isMapChild) {
- return grandChildId;
+ domInfo = HTMLNodes.get(grandChildId);
+ //Log.d(TAG, "----grandChildId = " + grandChildId + ", domInfo = " + domInfo);
+ if ("none".equals(domInfo.getString("pointerEvents"))) {
+ continue;
}
maxDomId = grandChildId;
}
@@ -588,6 +593,9 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
}
}
if (maxDomId == null) {
+ if ("none".equals(pointerEvents)) {
+ return null;
+ }
rect = HTMLNodeRectFs.get(domId);
if (overflow != null ) {
if (overflow.cropX) {
@@ -616,7 +624,7 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
MyPluginLayout.this.stopFlag = true;
int action = event.getAction();
- //Log.d("FrontLayerLayout", "----> action = " + MotionEvent.actionToString(action) + ", isScrolling = " + isScrolling);
+ //Log.d("FrontLayerLayout", "----> action = " + action + ", isScrolling = " + isScrolling);
// The scroll action that started in the browser region is end.
isScrolling = action != MotionEvent.ACTION_UP && isScrolling;
@@ -660,7 +668,7 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
}
String clickedDomId = findClickedDom("root", clickPoint, false, null);
- //Log.d(TAG, "----clickedDomId = " + clickedDomId);
+ Log.d(TAG, "----clickedDomId = " + clickedDomId);
return pluginMap.mapDivId.equals(clickedDomId);

MODIFY
src/ios/GoogleMaps/MyPluginLayer.m
src/ios/GoogleMaps/MyPluginLayer.m
isMapChild = isMapChild || [[domInfo objectForKey:@"isMap"] boolValue];
//NSLog(@"---- domId = %@, containMapCnt = %ld, isMapChild = %@", domId, containMapCnt, isMapChild ? @"YES":@"NO");
+ NSString *pointerEvents = [domInfo objectForKey:@"pointerEvents"];
NSString *overflowX = [domInfo objectForKey:@"overflowX"];
NSString *overflowY = [domInfo objectForKey:@"overflowY"];
if ([@"hidden" isEqualToString:overflowX] || [@"scroll" isEqualToString:overflowX] ||
overflow.rect = CGRectFromString([domInfo objectForKey:@"size"]);
}
- if ((containMapCnt > 0 || isMapChild) && children != nil && children.count > 0) {
+ if ((containMapCnt > 0 || isMapChild || [@"none" isEqualToString:pointerEvents]) && children != nil && children.count > 0) {
int maxZIndex = -1215752192;
int zIndex;
clickPoint.y > bottom) {
continue;
}
- if (isMapChild) {
- return childId;
+ if ([@"none" isEqualToString:[domInfo objectForKey:@"pointerEvents"]]) {
+ continue;
}
maxDomId = childId;
} else {
grandChildId = [self findClickedDom:childId withPoint:clickPoint isMapChild: isMapChild overflow:overflow];
if (grandChildId == nil) {
- continue;
+ grandChildId = childId;
}
domInfo = [self.pluginScrollView.debugView.HTMLNodes objectForKey:grandChildId];
rect = CGRectFromString([domInfo objectForKey:@"size"]);
clickPoint.y > bottom) {
continue;
}
- if (isMapChild) {
- return grandChildId;
+ domInfo = [self.pluginScrollView.debugView.HTMLNodes objectForKey:grandChildId];
+ if ([@"none" isEqualToString:[domInfo objectForKey:@"pointerEvents"]]) {
+ continue;
}
maxDomId = grandChildId;
}
}
if (maxDomId == nil) {
+ if ([@"none" isEqualToString:pointerEvents]) {
+ return nil;
+ }
domInfo = [self.pluginScrollView.debugView.HTMLNodes objectForKey:domId];
rect = CGRectFromString([domInfo objectForKey:@"size"]);

MODIFY
www/Common.js
www/Common.js
@@ -259,7 +259,9 @@ function shouldWatchByNative(node) {
var visibilityCSS = getStyle(node, 'visibility');
var displayCSS = getStyle(node, 'display');
- var pointerEventsCSS = getStyle(node, 'pointer-events');
+
+ // Do not check this at here.
+ //var pointerEventsCSS = getStyle(node, 'pointer-events');
//-----------------------------------------
// no longer check the opacity property,
@@ -276,8 +278,7 @@ function shouldWatchByNative(node) {
// node.offsetHeight > 0 && node.offsetWidth > 0 ||
// node.clientHeight > 0 && node.clientWidth > 0);
return displayCSS !== "none" &&
- visibilityCSS !== "hidden" &&
- pointerEventsCSS !== "none";
+ visibilityCSS !== "hidden";
}

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -480,7 +480,7 @@ if (!cordova) {
return;
}
- // get dom z-index
+ // Get the z-index CSS
var zIndex = common.getZIndex(element);
// Calculate dom clickable region
@@ -489,6 +489,7 @@ if (!cordova) {
// Stores dom information
var isCached = elemId in domPositions;
domPositions[elemId] = {
+ pointerEvents: common.getStyle(element, 'pointer-events'),
isMap: element.hasAttribute("__pluginMapId"),
size: rect,
zIndex: zIndex,
@@ -499,7 +500,7 @@ if (!cordova) {
};
var containMapCnt = (Object.keys(domPositions[elemId].containMapIDs)).length;
isMapChild = isMapChild || domPositions[elemId].isMap;
- if ((containMapCnt > 0 || isMapChild) && element.children.length > 0) {
+ if ((containMapCnt > 0 || isMapChild || domPositions[elemId].pointerEvents === "none") && element.children.length > 0) {
var child;
for (var i = 0; i < element.children.length; i++) {
child = element.children[i];
@@ -718,10 +719,13 @@ if (!cordova) {
elemId = common.getPluginDomId(elem);
isCached = elemId in domPositions;
domPositions[elemId] = {
+ pointerEvents: common.getStyle(elem, 'pointer-events'),
isMap: false,
size: elem.getBoundingClientRect(),
zIndex: common.getZIndex(elem),
children: [],
+ overflowX: common.getStyle(elem, "overflow-x"),
+ overflowY: common.getStyle(elem, "overflow-y"),
containMapIDs: (isCached ? domPositions[elemId].containMapIDs : {})
};
domPositions[elemId].containMapIDs[mapId] = 1;

Fix: Ionic toast notification is not clickable when displayed over Google Maps plugin #1991