Fix: error show htmlinfowindow
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.3.0-beta-20180416-1417" 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.3.0-beta-20180416-1757" 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
www/CordovaGoogleMaps.js
www/CordovaGoogleMaps.js
@@ -155,7 +155,13 @@ CordovaGoogleMaps.prototype.traceDomTree = function(element, elemId, isMapChild)
children: [],
// Hold the list of map id.
- containMapIDs: (isCached ? self.domPositions[elemId].containMapIDs : {})
+ containMapIDs: (isCached ? self.domPositions[elemId].containMapIDs : {}),
+
+ line: 161,
+
+ shouldWatchByNative: common.shouldWatchByNative(element),
+ display: common.getStyle(element, 'display'),
+ visibility: common.getStyle(element, 'visibility')
};
// Should this process continue to child elements?
@@ -180,6 +186,7 @@ CordovaGoogleMaps.prototype.traceDomTree = function(element, elemId, isMapChild)
child = element.children[i];
if (self.doNotTraceTags.indexOf(child.tagName.toLowerCase()) > -1 ||
!common.shouldWatchByNative(child)) {
+ self.removeDomTree.call(self, child);
continue;
}
@@ -600,6 +607,7 @@ CordovaGoogleMaps.prototype.getMap = function(div, mapOptions) {
var isCached;
while(elem && elem.nodeType === Node.ELEMENT_NODE) {
elemId = common.getPluginDomId(elem);
+ if (common.shouldWatchByNative(elem)) {
isCached = elemId in self.domPositions;
self.domPositions[elemId] = {
pointerEvents: common.getStyle(elem, 'pointer-events'),
@@ -612,6 +620,9 @@ CordovaGoogleMaps.prototype.getMap = function(div, mapOptions) {
containMapIDs: (isCached ? self.domPositions[elemId].containMapIDs : {})
};
self.domPositions[elemId].containMapIDs[mapId] = 1;
+ } else {
+ self.removeDomTree.call(self, element);
+ }
elem = elem.parentNode;
}
@@ -667,6 +678,7 @@ CordovaGoogleMaps.prototype.getPanorama = function(div, streetViewOptions) {
var isCached, zIndexList = [];
while(elem && elem.nodeType === Node.ELEMENT_NODE) {
elemId = common.getPluginDomId(elem);
+ if (common.shouldWatchByNative(elem)) {
isCached = elemId in self.domPositions;
self.domPositions[elemId] = {
pointerEvents: common.getStyle(elem, 'pointer-events'),
@@ -680,6 +692,9 @@ CordovaGoogleMaps.prototype.getPanorama = function(div, streetViewOptions) {
};
zIndexList.unshift(self.domPositions[elemId].zIndex);
self.domPositions[elemId].containMapIDs[mapId] = 1;
+ } else {
+ self.removeDomTree.call(self, element);
+ }
elem = elem.parentNode;
}
@@ -768,6 +783,7 @@ function postMapInit(map, div, options) {
var zIndexList = [];
while(elem && elem.nodeType === Node.ELEMENT_NODE) {
elemId = common.getPluginDomId(elem);
+ if (common.shouldWatchByNative(elem)) {
isCached = elemId in self.domPositions;
self.domPositions[elemId] = {
pointerEvents: common.getStyle(elem, 'pointer-events'),
@@ -777,10 +793,14 @@ function postMapInit(map, div, options) {
children: [],
overflowX: common.getStyle(elem, "overflow-x"),
overflowY: common.getStyle(elem, "overflow-y"),
- containMapIDs: (isCached ? self.domPositions[elemId].containMapIDs : {})
+ containMapIDs: (isCached ? self.domPositions[elemId].containMapIDs : {}),
+ line:792
};
zIndexList.unshift(self.domPositions[elemId].zIndex);
self.domPositions[elemId].containMapIDs[mapId] = 1;
+ } else {
+ self.removeDomTree.call(self, element);
+ }
elem = elem.parentNode;
}

MODIFY
www/HtmlInfoWindow.js
www/HtmlInfoWindow.js
@@ -64,8 +64,8 @@ var HTMLInfoWindow = function () {
anchorDiv.style.overflow = "visible";
anchorDiv.style.position = "absolute";
anchorDiv.style["z-index"] = 0;
- anchorDiv.style.width = 0;
- anchorDiv.style.height = 0;
+ anchorDiv.style.width = "0 !important";
+ anchorDiv.style.height = "0 !important";
//anchorDiv.style.border = "1px solid green";
//anchorDiv.style.backgroundColor = "rgba(125, 125, 255, 0.5)";
@@ -233,7 +233,6 @@ var HTMLInfoWindow = function () {
// Adjust the HTMLInfoWindow size
var contentsWidth = contentBox.offsetWidth + 10; // padding 5px x 2
- self.set("contentsWidth", contentsWidth);
var contentsHeight = contentBox.offsetHeight;
self.set("contentsHeight", contentsHeight);
contentFrame.style.width = contentsWidth + "px";
@@ -244,6 +243,7 @@ var HTMLInfoWindow = function () {
if (contentBox.offsetWidth > div.offsetWidth * 0.9) {
contentBox.style.width = (div.offsetWidth * 0.9) + "px";
}
+ self.set("contentsWidth", contentsWidth);
var infoOffset = {
x: 31,
@@ -265,16 +265,16 @@ var HTMLInfoWindow = function () {
var icon = marker.get("icon");
if (typeof icon === "object") {
- if (typeof icon.size === "object") {
- iconSize.width = icon.size.width;
- iconSize.height = icon.size.height;
- }
if (typeof icon.url === "string" && icon.url.indexOf("data:image/") === 0) {
var img = document.createElement("img");
img.src = icon.url;
iconSize.width = img.width;
iconSize.height = img.height;
}
+ if (typeof icon.size === "object") {
+ iconSize.width = icon.size.width;
+ iconSize.height = icon.size.height;
+ }
if (Array.isArray(icon.anchor)) {
anchor.x = icon.anchor[0];
@@ -376,7 +376,7 @@ HTMLInfoWindow.prototype.close = function () {
//self._hook.off(self, "infoWindowAnchor_changed");
self._hook.off(marker, event.INFO_CLOSE); //This event listener is assigned in the open method. So detach it.
self.trigger(event.INFO_CLOSE);
- map.set("active_marker_id", null);
+ map.set("active_marker", null);
//var div = map.getDiv();
var anchorDiv = self.get("anchor");
@@ -397,6 +397,19 @@ HTMLInfoWindow.prototype.setContent = function (content, cssOptions) {
self.set("cssOptions", cssOptions);
var marker = self.get("marker");
if (content !== prevContent && marker && marker.isInfoWindowShown()) {
+ var anchorDiv = self.get("anchor");
+ if (anchorDiv) {
+ anchorDiv.style.width = "0 !important";
+ anchorDiv.style.height = "0 !important";
+ if (anchorDiv.parentNode) {
+ anchorDiv.parentNode.removeChild(anchorDiv);
+
+ // Remove the contents from this HTMLInfoWindow
+ var contentFrame = anchorDiv.firstChild.firstChild;
+ var contentBox = contentFrame.firstChild;
+ contentBox.innerHTML = "";
+ }
+ }
self.trigger("infoWindowAnchor_changed", marker);
}
};
@@ -438,7 +451,7 @@ HTMLInfoWindow.prototype.open = function (marker) {
self._hook.one(marker.getMap(), "map_clear", self.close.bind(self));
self._hook.one(marker, event.INFO_CLOSE, self.close.bind(self));
self.set("marker", marker);
- map.set("active_marker_id", marker.getId());
+ map.set("active_marker", marker);
self.trigger.call(self, "infoWindowAnchor_changed", marker);
});
};

MODIFY
www/Map.js
www/Map.js
@@ -58,14 +58,15 @@ var Map = function(id, _exec) {
});
self.on(event.MAP_CLICK, function() {
- self.set("active_marker_id", undefined);
+ self.set("active_marker", undefined);
});
- self.on("active_marker_id_changed", function(prevId, newId) {
- if (prevId in self.MARKERS) {
- self.MARKERS[prevId].hideInfoWindow.call(self.MARKERS[prevId]);
+ self.on("active_marker_changed", function(prevMarker, newMarker) {
+ var newMarkerId = newMarker ? newMarker.getId() : null;
+ if (prevMarker) {
+ prevMarker.hideInfoWindow.call(prevMarker);
}
- self.exec.call(self, null, null, self.id, 'setActiveMarkerId', [newId]);
+ self.exec.call(self, null, null, self.id, 'setActiveMarkerId', [newMarkerId]);
});
};
@@ -321,9 +322,9 @@ Map.prototype.clear = function(callback) {
}
// Close the active infoWindow
- var active_marker_id = self.get("active_marker_id");
- if (active_marker_id && active_marker_id in self.MARKERS) {
- self.MARKERS[active_marker_id].trigger(event.INFO_CLOSE);
+ var active_marker = self.get("active_marker");
+ if (active_marker) {
+ active_marker.trigger(event.INFO_CLOSE);
}
var clearObj = function(obj) {
@@ -659,9 +660,9 @@ Map.prototype.remove = function(callback) {
// Close the active infoWindow
- var active_marker_id = self.get("active_marker_id");
- if (active_marker_id && active_marker_id in self.MARKERS) {
- self.MARKERS[active_marker_id].trigger(event.INFO_CLOSE);
+ var active_marker = self.get("active_marker");
+ if (active_marker) {
+ active_marker.trigger(event.INFO_CLOSE);
}
var clearObj = function(obj) {

MODIFY
www/MarkerCluster.js
www/MarkerCluster.js
@@ -232,7 +232,7 @@ MarkerCluster.prototype.remove = function() {
var keys;
var resolution = self.get("resolution"),
- activeMarkerId = self.map.get("active_marker_id"),
+ activeMarker = self.map.get("active_marker"),
deleteClusters = [];
self.taskQueue = [];
@@ -242,6 +242,7 @@ MarkerCluster.prototype.remove = function() {
});
self.trigger("remove");
+ var activeMarkerId = activeMarker ? activeMarker.getId() : null;
if (resolution === self.OUT_OF_RESOLUTION) {
while (self._clusters[resolution].length > 0) {
markerOpts = self._clusters[resolution].shift();
@@ -508,7 +509,8 @@ MarkerCluster.prototype._redraw = function(params) {
}
//console.log("---->548");
- var activeMarkerId = self.map.get("active_marker_id");
+ var activeMarker = self.map.get("active_marker");
+ var activeMarkerId = activeMarker ? activeMarker.getId() : null;
if (prevResolution === self.OUT_OF_RESOLUTION) {
if (resolution === self.OUT_OF_RESOLUTION) {
//console.log("---->552");

Fix: error show htmlinfowindow #2217