2
当我在Google Maps应用程序中添加标记和InfoWindow时,标记会正确添加到地图和默认的StreetView全景图中。谷歌地图StreetView InfowIndows在地图上打开
我还通过以地图作为参数调用我的bindInfoWindow
函数,并以StreetView全景作为参数一次,将InfoWindows添加到标记的两个副本。
直到几个星期前,这工作完美。
现在,由于某些原因,两个InfoWindows都显示在地图上,并附加到地图标记上。
我已经创建了simple fiddle(基于this公共小提琴),它显示问题here。
基本上我创建以正常的方式标记和信息窗口:
var myMarker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(-34.397, 150.644),
title: "My Marker",
draggable:true,
});
然后,我用我的bindInfoWindow功能
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);
}
}
创建为标志的的onClick行为,而且还会自动打开信息窗口如果需要。
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);
直到大约一两个星期前这是完美的工作,但一下子信息窗口都出现在地图上,而不是一个出现在地图上,一个出现在默认的街景的。
在the fiddle中,您可以清楚地看到StreetView InfoWindow已经在主地图InfoWindow的顶部打开,尽管已指定在StreetView上打开它。
注意map
是我的地图对象和defaultStreetViewPanorama
是创建刚过
var defaultStreetViewPanorama = map.getStreetView();
地图对象,并设置街景选项之前检索到的街景Panormama对象。请注意,正确设置StreetView选项为,因此map.getStreetView()
似乎正在返回正确的对象。
Google于2016年5月24日发布了新版本3.24。在您的代码中,您使用的是实验版本3.25。我可以看到这个问题只能在实验版本中重现。我认为值得在公开问题跟踪器https://code.google。中创建一个问题。com/p/gmaps-api-issues/ – xomena
在https://code.google.com/p/gmaps-api-issues/issues/detail?id=9925 –
登录为问题9925非常非常奇怪...全部突然在这个周末,这个问题也开始在v3.24中发生! (或者至少在调用页面的'