(Browser)Fix: marker.setInfoWindowAnchor is incorrect
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.4.4-beta-20180912-1517" 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.4.4-beta-20180912-1557" 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">
<runs/>

MODIFY
src/browser/PluginMarker.js
src/browser/PluginMarker.js
@@ -234,9 +234,19 @@ PluginMarker.prototype.setInfoWindowAnchor = function(onSuccess, onError, args)
var overlayId = args[0];
var marker = self.pluginMap.objects[overlayId];
if (marker) {
+ (new Promise(function(resolve, reject) {
+ var icon = marker.getIcon();
+ var anchorX = args[1];
+ anchorX = anchorX - icon.size.width / 2;
+ var anchorY = args[2];
+ anchorY = anchorY - icon.size.height / 2;
marker.setOptions({
- 'anchorPoint': new google.maps.Point(args[1], args[2])
+ 'anchorPoint': new google.maps.Point(anchorX, anchorY)
});
+ if (self.infoWnd) {
+ self._showInfoWindow.call(self, marker);
+ }
+ }));
}
onSuccess();
};
@@ -400,7 +410,9 @@ PluginMarker.prototype.onMarkerEvent = function(evtName, marker) {
PluginMarker.prototype._showInfoWindow = function(marker) {
var self = this;
if (!self.infoWnd) {
- self.infoWnd = new google.maps.InfoWindow();
+ self.infoWnd = new google.maps.InfoWindow({
+ 'pixelOffset': new google.maps.Size(0, 0)
+ });
}
var container = document.createElement('div');
self.pluginMap.activeMarker = marker;
@@ -429,7 +441,6 @@ PluginMarker.prototype._showInfoWindow = function(marker) {
maxWidth: maxWidth
});
google.maps.event.addListener(self.infoWnd, 'closeclick', function() {
- google.maps.event.clearInstanceListeners(container.parentNode.parentNode.parentNode);
google.maps.event.clearInstanceListeners(self.infoWnd);
self.onMarkerClickEvent(event.INFO_CLOSE, marker);
});

(Browser)Fix: marker.setInfoWindowAnchor is incorrect