When I add a marker and InfoWindow to my Google Maps application the marker is correctly added to both the map and the default StreetView panorama.
I also add InfoWindows to both copies of the marker by calling my bindInfoWindow
function once with the map as an argument and once with the StreetView panorama as an argument.
This was working perfectly until a few weeks ago.
Now, for some reason, both InfoWindows are being displayed on the map, attached to the map marker.
I have created a simple fiddle (based on this public fiddle) which shows the problem here.
Basically I create the marker and InfoWindows in the normal way:
var myMarker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(-34.397, 150.644),
title: "My Marker",
draggable:true,
});
Then I use my bindInfoWindow function
function bindInfoWindow(marker, mapOrStreetView, whichInfoWindow, html, openWindow,markerId) {
openWindow = ((typeof openWindow === 'undefined')?false:openWindow);
markerId = ((typeof markerId === 'undefined')?'':markerId);
google.maps.event.addListener(marker, 'click', function() {
whichInfoWindow.setContent(html);
whichInfoWindow.open(mapOrStreetView, marker);
});
if ( openWindow === true ) {
whichInfoWindow.setContent(html);
whichInfoWindow.open(mapOrStreetView, marker);
}
}
to create the onClick actions for the markers and also open the InfoWindows automatically if required.
var myMarkerInfoWindow = new google.maps.InfoWindow;
bindInfoWindow(myMarker, map, myMarkerInfoWindow, "<h1>My Map Info Window Text<br /> <br /></h1>", true);
var myMarkerStreetViewInfoWindow = new google.maps.InfoWindow;
bindInfoWindow(myMarker, defaultStreetViewPanorama, myMarkerStreetViewInfoWindow, "<h1>My StreetView Info Window Text</h1>", true);
Up until about a week or two ago this was working perfectly, but all of a sudden the InfoWindows are both appearing on the map, rather than one appearing on the map and one appearing on the default StreetView.
In the fiddle, you can clearly see that the StreetView InfoWindow has opened over the top of the main map InfoWindow despite having been specified to open on the StreetView.
Note that map
is my map object and defaultStreetViewPanorama
is the StreetView Panormama object retrieved with
var defaultStreetViewPanorama = map.getStreetView();
just after the map object is created and just before the StreetView options are set. Note that the StreetView options are being correctly set, so it seems that map.getStreetView()
is returning the correct object.
Google broke this functionality in v3.25.
v3.24 was the last version which worked correctly.
v3.24 has been retired and is no longer available - there does not seem to be any simple workaround in the meantime.
The issue has been logged with Google on their bug-tracker at https://code.google.com/p/gmaps-api-issues/issues/detail?id=9925 and has been accepted but at the time of writing has not been fixed.
I will update this answer if/when there is any progress.