(iOS) WIP: Use this Plugin with React
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.5.0-beta-20181023-1856" 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.5.0-beta-20181026-2308" 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="Promise" src="www/Promise.js" />
<asset src="www/promise-7.0.4.min.js.map" target="promise-7.0.4.min.js.map" />

MODIFY
src/ios/GoogleMaps/MyPluginLayer.h
src/ios/GoogleMaps/MyPluginLayer.h
#import "PluginMapViewController.h"
#import "MyPluginScrollView.h"
+@interface CGDOMRect : NSObject
+ @property CGFloat left;
+ @property CGFloat right;
+ @property CGFloat top;
+ @property CGFloat bottom;
+@end
+
@interface OverflowCSS : NSObject
@property BOOL cropX;
@property BOOL cropY;

MODIFY
src/ios/GoogleMaps/MyPluginLayer.m
src/ios/GoogleMaps/MyPluginLayer.m
@end
+@implementation CGDOMRect : NSObject
+ CGFloat left;
+ CGFloat right;
+ CGFloat top;
+ CGFloat bottom;
+@end
+
@implementation MyPluginLayer
- (id)initWithWebView:(UIView *)webView {
@synchronized(self.pluginScrollView.HTMLNodes) {
//NSLog(@"--->browserClickPoint = %f, %f", browserClickPoint.x, browserClickPoint.y);
clickedDomId = [self findClickedDom:@"root" withPoint:browserClickPoint isMapChild:NO overflow:nil];
+ NSLog(@"--->clickedDomId = %@", clickedDomId);
while(mapId = [mapIDs nextObject]) {
mapCtrl = [self.pluginScrollView.mapCtrls objectForKey:mapId];
- (NSString *)findClickedDom:(NSString *)domId withPoint:(CGPoint)clickPoint isMapChild:(BOOL)isMapChild overflow:(OverflowCSS *)overflow {
if ([self.CACHE_FIND_DOM objectForKey:domId]) {
- return [self.CACHE_FIND_DOM objectForKey:domId];
+ NSString *cacheResult = [self.CACHE_FIND_DOM objectForKey:domId];
+ if ([@"(null)" isEqualToString:cacheResult]) {
+ cacheResult = nil;
+ }
+ return nil;
+ }
+
+ OverflowCSS *overflow1 = nil;
+ if (overflow) {
+ overflow1 = [[OverflowCSS alloc] init];
+ overflow1.cropX = overflow.cropX;
+ overflow1.cropY = overflow.cropY;
+ overflow1.rect = CGRectMake(overflow.rect.origin.x, overflow.rect.origin.y, overflow.rect.size.width, overflow.rect.size.height);
}
+
NSDictionary *domInfo = [self.pluginScrollView.HTMLNodes objectForKey:domId];
NSDictionary *domInfoChild;
- NSArray *children = [domInfo objectForKey:@"children"];
NSString *maxDomId = nil;
- CGRect rect;
- float right, bottom;
+ CGRect rect, tmpRect;
+ CGDOMRect *rect2, *rect3;
NSDictionary *zIndexProp;
-
+ unsigned long containMapCnt = 0;
domInfo = [self.pluginScrollView.HTMLNodes objectForKey:domId];
+ if ([domInfo objectForKey:@"containMapIDs"]) {
NSDictionary *containMapIDs = [domInfo objectForKey:@"containMapIDs"];
- unsigned long containMapCnt = [[containMapIDs allKeys] count];
- isMapChild = isMapChild || [[domInfo objectForKey:@"isMap"] boolValue];
+ containMapCnt = [[containMapIDs allKeys] count];
+ }
+ isMapChild = isMapChild || [[domInfo objectForKey:@"isMap"] boolValue] || false;
//NSLog(@"---- domId = %@, containMapCnt = %ld, isMapChild = %@", domId, containMapCnt, isMapChild ? @"YES":@"NO");
NSString *pointerEvents = [domInfo objectForKey:@"pointerEvents"];
NSString *overflowY = [domInfo objectForKey:@"overflowY"];
if ([@"hidden" isEqualToString:overflowX] || [@"scroll" isEqualToString:overflowX] ||
[@"hidden" isEqualToString:overflowY] || [@"scroll" isEqualToString:overflowY]) {
- overflow = [OverflowCSS alloc];
- overflow.cropX = [@"hidden" isEqualToString:overflowX] || [@"scroll" isEqualToString:overflowX];
- overflow.cropY = [@"hidden" isEqualToString:overflowY] || [@"scroll" isEqualToString:overflowY];
- overflow.rect = CGRectFromString([domInfo objectForKey:@"size"]);
+ overflow1 = [[OverflowCSS alloc] init];
+ overflow1.cropX = [@"hidden" isEqualToString:overflowX] || [@"scroll" isEqualToString:overflowX];
+ overflow1.cropY = [@"hidden" isEqualToString:overflowY] || [@"scroll" isEqualToString:overflowY];
+ overflow1.rect = CGRectFromString([domInfo objectForKey:@"size"]);
} else if ([@"visible" isEqualToString:overflowX] || [@"visible" isEqualToString:overflowX]) {
if (overflow != nil) {
- overflow.cropX = ![@"visible" isEqualToString:overflowX];
- overflow.cropY = ![@"visible" isEqualToString:overflowY];
+ overflow1.cropX = ![@"visible" isEqualToString:overflowX];
+ overflow1.cropY = ![@"visible" isEqualToString:overflowY];
}
}
zIndexProp = [domInfo objectForKey:@"zIndex"];
+ NSArray *children = [domInfo objectForKey:@"children"];
if ((containMapCnt > 0 || isMapChild || [@"none" isEqualToString:pointerEvents] ||
[[zIndexProp objectForKey:@"isInherit"] boolValue]) && children != nil && children.count > 0) {
for (int i = (int)children.count - 1; i >= 0; i--) {
childId = [children objectAtIndex:i];
domInfo = [self.pluginScrollView.HTMLNodes objectForKey:childId];
+ if (!domInfo) {
+ continue;
+ }
+
zIndexProp = [domInfo objectForKey:@"zIndex"];
zIndexValue = [[zIndexProp objectForKey:@"z"] intValue];
-
if (maxZIndex < zIndexValue || [[zIndexProp objectForKey:@"isInherit"] boolValue]) {
grandChildren = [domInfo objectForKey:@"children"];
if (grandChildren == nil || grandChildren.count == 0) {
- rect = CGRectFromString([domInfo objectForKey:@"size"]);
- right = rect.origin.x + rect.size.width;
- bottom = rect.origin.y + rect.size.height;
- if (overflow != nil && ![@"root" isEqualToString:domId ]) {
- if (overflow.cropX) {
- rect.origin.x = MAX(rect.origin.x, overflow.rect.origin.x);
- right = MIN(right, overflow.rect.origin.x + overflow.rect.size.width);
+ tmpRect = CGRectFromString([domInfo objectForKey:@"size"]);
+ rect2 = [[CGDOMRect alloc] init];
+ rect2.left = tmpRect.origin.x;
+ rect2.top = tmpRect.origin.y;
+ rect2.right = rect2.left + tmpRect.size.width;
+ rect2.bottom = rect2.top + tmpRect.size.height;
+
+ if (overflow1 && ![@"root" isEqualToString:domId]) {
+
+ tmpRect = CGRectFromString([domInfo objectForKey:@"size"]);
+ rect3 = [[CGDOMRect alloc] init];
+ rect3.left = tmpRect.origin.x;
+ rect3.top = tmpRect.origin.y;
+ rect3.right = rect3.left + tmpRect.size.width;
+ rect3.bottom = rect3.top + tmpRect.size.height;
+
+
+ if (overflow1.cropX) {
+ rect2.left = MAX(rect2.left, rect3.left);
+ rect2.right = MIN(rect2.right, rect3.right);
}
- if (overflow.cropY) {
- rect.origin.y = MAX(rect.origin.y, overflow.rect.origin.y);
- bottom = MIN(bottom, overflow.rect.origin.y + overflow.rect.size.height);
+ if (overflow1.cropY) {
+ rect2.top = MAX(rect2.top, rect3.top);
+ rect2.bottom = MIN(rect2.bottom, rect3.bottom);
}
+
}
- if (clickPoint.x < rect.origin.x ||
- clickPoint.y < rect.origin.y ||
- clickPoint.x > right ||
- clickPoint.y > bottom) {
+ if (clickPoint.x < rect2.left ||
+ clickPoint.y < rect2.top ||
+ clickPoint.x > rect2.right ||
+ clickPoint.y > rect2.bottom) {
continue;
}
+
if ([@"none" isEqualToString:[domInfo objectForKey:@"pointerEvents"]]) {
continue;
}
+
if (maxZIndex < zIndexValue) {
maxZIndex = zIndexValue;
maxDomId = childId;
}
+
+ overflow1.rect = CGRectMake(rect2.left, rect2.top, rect2.right - rect2.left, rect2.bottom - rect2.top);
+
} else {
if (zIndexValue < maxZIndex) {
// NSLog(@"-----skip because %d is %d < %d ", childId, zIndexValue, maxZindex);
continue;
}
- grandChildId = [self findClickedDom:childId withPoint:clickPoint isMapChild: isMapChild overflow:overflow];
+ grandChildId = [self findClickedDom:childId withPoint:clickPoint isMapChild: isMapChild overflow:overflow1];
if (grandChildId == nil) {
- domInfoChild = [self.pluginScrollView.HTMLNodes objectForKey:grandChildId];
grandChildId = childId;
} else {
domInfoChild = [self.pluginScrollView.HTMLNodes objectForKey:grandChildId];
- zIndexProp = [domInfo objectForKey:@"zIndex"];
+ zIndexProp = [domInfoChild objectForKey:@"zIndex"];
zIndexValue = [[zIndexProp objectForKey:@"z"] intValue];
}
rect = CGRectFromString([domInfoChild objectForKey:@"size"]);
- right = rect.origin.x + rect.size.width;
- bottom = rect.origin.y + rect.size.height;
- if (overflow != nil && ![@"root" isEqualToString:domId ]) {
- if (overflow.cropX) {
- rect.origin.x = MAX(rect.origin.x, overflow.rect.origin.x);
- right = MIN(right, overflow.rect.origin.x + overflow.rect.size.width);
+ rect2 = [[CGDOMRect alloc] init];
+ rect2.left = rect.origin.x;
+ rect2.top = rect.origin.y;
+ rect2.right = rect2.left + rect.size.width;
+ rect2.bottom = rect2.top + rect.size.height;
+
+ if (overflow1 && ![@"root" isEqualToString:domId]) {
+
+ tmpRect = CGRectFromString([domInfo objectForKey:@"size"]);
+ rect3 = [[CGDOMRect alloc] init];
+ rect3.left = tmpRect.origin.x;
+ rect3.top = tmpRect.origin.y;
+ rect3.right = rect3.left + tmpRect.size.width;
+ rect3.bottom = rect3.top + tmpRect.size.height;
+
+
+ if (overflow1.cropX) {
+ rect2.left = MAX(rect2.left, rect3.left);
+ rect2.right = MIN(rect2.right, rect3.right);
}
- if (overflow.cropY) {
- rect.origin.y = MAX(rect.origin.y, overflow.rect.origin.y);
- bottom = MIN(bottom, overflow.rect.origin.y + overflow.rect.size.height);
+ if (overflow1.cropY) {
+ rect2.top = MAX(rect2.top, rect3.top);
+ rect2.bottom = MIN(rect2.bottom, rect3.bottom);
}
+
}
- if (clickPoint.x < rect.origin.x ||
- clickPoint.y < rect.origin.y ||
- clickPoint.x > right ||
- clickPoint.y > bottom) {
+ if (clickPoint.x < rect2.left ||
+ clickPoint.y < rect2.top ||
+ clickPoint.x > rect2.right ||
+ clickPoint.y > rect2.bottom) {
continue;
}
+
+
domInfo = [self.pluginScrollView.HTMLNodes objectForKey:grandChildId];
if ([@"none" isEqualToString:[domInfo objectForKey:@"pointerEvents"]]) {
continue;
if (maxDomId == nil && ![@"root" isEqualToString:domId]) {
if ([@"none" isEqualToString:pointerEvents]) {
- [self.CACHE_FIND_DOM setValue:nil forKey:domId];
+ [self.CACHE_FIND_DOM setValue:@"(null)" forKey:domId];
return nil;
}
+
domInfo = [self.pluginScrollView.HTMLNodes objectForKey:domId];
rect = CGRectFromString([domInfo objectForKey:@"size"]);
- right = rect.origin.x + rect.size.width;
- bottom = rect.origin.y + rect.size.height;
- if (overflow != nil) {
- if (overflow.cropX) {
- rect.origin.x = MAX(rect.origin.x, overflow.rect.origin.x);
- right = MIN(right, overflow.rect.origin.x + overflow.rect.size.width);
+ rect2 = [[CGDOMRect alloc] init];
+ rect2.left = rect.origin.x;
+ rect2.top = rect.origin.y;
+ rect2.right = rect2.left + rect.size.width;
+ rect2.bottom = rect2.top + rect.size.height;
+
+
+ if (overflow1) {
+
+ tmpRect = CGRectFromString([domInfo objectForKey:@"size"]);
+ rect3 = [[CGDOMRect alloc] init];
+ rect3.left = tmpRect.origin.x;
+ rect3.top = tmpRect.origin.y;
+ rect3.right = rect3.left + tmpRect.size.width;
+ rect3.bottom = rect3.top + tmpRect.size.height;
+
+
+ if (overflow1.cropX) {
+ rect2.left = MAX(rect2.left, rect3.left);
+ rect2.right = MIN(rect2.right, rect3.right);
}
- if (overflow.cropY) {
- rect.origin.y = MAX(rect.origin.y, overflow.rect.origin.y);
- bottom = MIN(bottom, overflow.rect.origin.y + overflow.rect.size.height);
+ if (overflow1.cropY) {
+ rect2.top = MAX(rect2.top, rect3.top);
+ rect2.bottom = MIN(rect2.bottom, rect3.bottom);
}
+
}
- if (clickPoint.x < rect.origin.x ||
- clickPoint.y < rect.origin.y ||
- clickPoint.x > right ||
- clickPoint.y > bottom) {
- [self.CACHE_FIND_DOM setValue:nil forKey:domId];
+ if (clickPoint.x < rect2.left ||
+ clickPoint.y < rect2.top ||
+ clickPoint.x > rect2.right ||
+ clickPoint.y > rect2.bottom) {
+ [self.CACHE_FIND_DOM setValue:@"(null)" forKey:domId];
return nil;
}
+
maxDomId = domId;
}
+
+ if (!maxDomId) {
+ [self.CACHE_FIND_DOM setValue:@"(null)" forKey:domId];
+ } else {
[self.CACHE_FIND_DOM setValue:maxDomId forKey:domId];
+ }
+
return maxDomId;
}

(iOS) WIP: Use this Plugin with React #2487