作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的站点中有一个谷歌地图并附加到它的 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/
leaflet:一个开源并且对移动端友好的交互式地图 JavaScript 库 中文文档: https://leafletjs.cn/reference.html 官网(英文): ht
我是一名优秀的程序员,十分优秀!