Bug fix: the plugin keeps the information of removed elements
MODIFY
src/android/plugin/google/maps/MyPluginLayout.java
src/android/plugin/google/maps/MyPluginLayout.java
@@ -473,7 +473,7 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (isSuspended || pluginMaps == null || pluginMaps.size() == 0) {
- webView.loadUrl("javascript:cordova.fireDocumentEvent('plugin_touch', {});");
+ webView.loadUrl("javascript:(cordova && cordova.fireDocumentEvent('plugin_touch', {}));");
return false;
}
MyPluginLayout.this.stopFlag = true;
@@ -571,7 +571,7 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
if (!isMapAction) {
browserView.requestFocus(View.FOCUS_DOWN);
- webView.loadUrl("javascript:cordova.fireDocumentEvent('plugin_touch', {});");
+ webView.loadUrl("javascript:(cordova && cordova.fireDocumentEvent('plugin_touch', {}));");
}
MyPluginLayout.this.stopFlag = false;

MODIFY
src/ios/GoogleMaps/MyPluginLayer.m
src/ios/GoogleMaps/MyPluginLayer.m
@@ -295,9 +295,9 @@ BOOL hasCordovaStatusBar = NO; // YES if the app has cordova-plugin-statusbar
}
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
- if (self.isSuspended) {
+ if (self.isSuspended || self.pluginScrollView.debugView.mapCtrls == nil || self.pluginScrollView.debugView.mapCtrls.count == 0) {
// Assumes all touches for the browser
- [self execJS:@"javascript:cordova.fireDocumentEvent('plugin_touch', {});"];
+ [self execJS:@"javascript:(cordova && cordova.fireDocumentEvent('plugin_touch', {}));"];
return [self.webView hitTest:point withEvent:event];
}
@@ -407,9 +407,7 @@ BOOL hasCordovaStatusBar = NO; // YES if the app has cordova-plugin-statusbar
}
}
- if (isMapAction == NO) {
- continue;
- }
+ if (isMapAction == YES) {
// If user click on the map, return the mapCtrl.view.
offsetX = (mapCtrl.view.frame.origin.x * zoomScale) - offsetX;
@@ -421,17 +419,14 @@ BOOL hasCordovaStatusBar = NO; // YES if the app has cordova-plugin-statusbar
UIView *hitView =[mapCtrl.view hitTest:point2 withEvent:event];
//NSLog(@"--> (hit test) point = %f, %f / hit = %@", clickPointAsHtml.x, clickPointAsHtml.y, hitView.class);
- if (isMapAction == NO) {
- [self execJS:@"javascript:cordova.fireDocumentEvent('plugin_touch', {});"];
- }
-
return hitView;
}
}
+}
UIView *hitView =[self.webView hitTest:point withEvent:event];
//NSLog(@"--> (hit test) hit = %@", hitView.class);
- [self execJS:@"javascript:cordova.fireDocumentEvent('plugin_touch', {});"];
+ [self execJS:@"javascript:(cordova && cordova.fireDocumentEvent('plugin_touch', {}));"];
return hitView;
}

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
/* global cordova, plugin, CSSPrimitiveValue */
var MAP_CNT = 0;
+if (!cordova) {
+ return;
+}
+
var argscheck = require('cordova/argscheck'),
utils = require('cordova/utils'),
exec = require('cordova/exec'),
@@ -207,6 +211,7 @@ document.head.appendChild(navDecorBlocker);
shouldUpdate = true;
}
}
+
} else {
if (element.nodeType === Node.ELEMENT_NODE) {
if (element.hasAttribute("__pluginDomId")) {
@@ -238,6 +243,13 @@ document.head.appendChild(navDecorBlocker);
};
traceDomTree(document.body, 0);
+ // If some elements has been removed, should update the positions
+ var elementCnt = Object.keys(domPositions).length;
+ var prevElementCnt = Object.keys(prevDomPositions).length;
+ if (elementCnt !== prevElementCnt) {
+ shouldUpdate = true;
+ }
+
if (!shouldUpdate && idlingCnt > -1) {
idlingCnt++;
if (idlingCnt === 2) {

Bug fix: the plugin keeps the information of removed elements