gpt4 book ai didi

javascript - 从服务器检索信息后在谷歌地图上打开信息窗口html

转载 作者:行者123 更新时间:2023-11-30 06:09:03 28 4
gpt4 key购买 nike

我的站点中有一个谷歌地图并附加到它的 moveend 事件处理程序

   GEvent.addListener(map, "moveend", function() 
{
map.clearovrelays();
GetLayerDataFromServer(); //it set the markers again on the map according the map position
});

而且我还有点击标记的事件处理程序

GEvent.addListener(marker, 'click', function()
{
marker.openInfoWindowHtml('this is the data');
});

我的问题是这个

当用户按下 map 上的标记之一时它打开了相关标记的 openInfoWindowHtml。

它还会将 map 移动到该标记位置。然后触发事件

map.moveend

在事件 map.moveend 中,我清除了 map 上的所有标记并根据 map 新位置重新加载它们。

结果是当用户点击标记时,它会第二次打开他的 indoWindowHtml它会清除 map 并再次加载标记,不显示单击标记的 indoWindowHtml。

我的问题是我应该怎么做才能显示 infoWindowHtml?

最佳答案

您可以设置一个标志,指示用户是否单击了标记,如果是这种情况则不清除 map 。

var marker_clicked = false;

GEvent.addListener(map, "moveend", function()
{
if(!marker_clicked)
{
map.clearovrelays();
GetLayerDataFromServer(); //it set the markers again on the map acording the map position
}
marker_clicked = false;
});

GEvent.addListener(marker, 'click', function()
{
marker_clicked = true;
marker.openInfoWindowHtml('this is the data');
});

关于javascript - 从服务器检索信息后在谷歌地图上打开信息窗口html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1444021/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com