当我在我的Google Maps应用程序中添加标记和InfoWindow时,标记被正确地添加到地图和默认的StreetView全景图中。
我还通过将我的
这在几周前一直很完美地工作着。
现在,由于某种原因,两个InfoWindows都显示在地图上,附加在地图标记上。
我创建了一个simple fiddle(基于this公共fiddle),其中展示了该问题here。
基本上,我以正常方式创建标记和InfoWindows:
然后我使用我的 bindInfoWindow 函数。
为标记创建onClick操作,并在需要时自动打开InfoWindows。
直到一两周前,这个功能一直完美运行,但突然间InfoWindows都出现在地图上,而不是一个出现在地图上,另一个出现在默认的StreetView上。
在这个fiddle中,您可以清楚地看到,尽管已指定在StreetView上打开,但StreetView InfoWindow已经打开在了主地图InfoWindow的上方。
请注意,
在创建地图对象后,设置街景选项之前,请注意。请注意,街景选项已正确设置,因此似乎
我还通过将我的
bindInfoWindow
函数分别传入地图和StreetView全景图作为参数来向两个副本的标记添加了InfoWindows。这在几周前一直很完美地工作着。
现在,由于某种原因,两个InfoWindows都显示在地图上,附加在地图标记上。
我创建了一个simple fiddle(基于this公共fiddle),其中展示了该问题here。
基本上,我以正常方式创建标记和InfoWindows:
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操作,并在需要时自动打开InfoWindows。
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);
直到一两周前,这个功能一直完美运行,但突然间InfoWindows都出现在地图上,而不是一个出现在地图上,另一个出现在默认的StreetView上。
在这个fiddle中,您可以清楚地看到,尽管已指定在StreetView上打开,但StreetView InfoWindow已经打开在了主地图InfoWindow的上方。
请注意,
map
是我的地图对象,defaultStreetViewPanorama
是通过获取的StreetView Panormama对象。var defaultStreetViewPanorama = map.getStreetView();
在创建地图对象后,设置街景选项之前,请注意。请注意,街景选项已正确设置,因此似乎
map.getStreetView()
返回了正确的对象。
<script>
标签中指定v3.24时是如此。现在问题似乎也发生在所有版本回到3.21...我已经更新了Google问题。(请注意,尽管Google承认了这个问题,但它在最新的3.27实验版本中也没有得到解决) - Fat Monk