如何使infowindow显示取决于它已有的空间并且不移动地图
我在Google地图中显示少量地点。如果用户放大/缩小或拖动地图,我会刷新这些位置。现在的问题是,如果我点击某个位置的标记,那么信息窗口打开并拖动地图,如果它没有任何显示空间的话。这种拖动导致我的位置被刷新,因此我的标记消失。
I am displaying few locations in google maps. I refresh these locations if a user zoom in/out or drags the map. Now the issue is if i click on the marker of a location then the info window opens up and drags the map if it doesn't have any space to show. This dragging causes my locations to be refreshed and hence my marker vanishes.
我试过 disableAutoPan:true 信息窗口不是只能看到。有什么方法可以让信息窗口自动调整自己。有什么方法可以对此进行排序吗?
I tried disableAutoPan: true but then the info window is not seen only. Is there any way that the info window auto adjust itself. is there any way to sort this out?
使用全局变量来指示何时应该忽略刷新,例如:
Use a global variable to indicate when the refresh should be ignored, for example:
// Global var
var ignoreRefresh = false;
google.maps.addListener(marker,'click', function(){
ignoreRefresh = true;
infoWindow.setContent('Hello');
infoWindow.open(map,marker);
})
function refresh(){
if (ignoreRefresh) {
ignoreRefresh = false;
return;
}
//...
//do your normal refresh of data
//...
}