【问题标题】:How to clear the infowindow in gmaps如何清除gmaps中的信息窗口
【发布时间】:2013-03-18 12:51:40
【问题描述】:

我的项目是单个 JQM,因为信息窗口在项目中只出现一次。当我移动到另一个页面并返回到地图页面时,信息窗口处于死状态。如何恢复它。

 firstmap = new google.maps.Map(document.getElementById("map"), myOptions);

            var latlng = new google.maps.LatLng(Lat, Long);
            geocoder.geocode({'latLng': latlng}, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
                if (results[1]) {

                    firstmap.setZoom(10);
                  marker = new google.maps.Marker({
                      icon:image,
                      position: latlng,
                      map: firstmap
                  });

                  infowindow.setContent(results[1].formatted_address);
                  infowindow.open(map, marker);
                google.maps.event.addListener(marker, 'click', clearWindow);

                }
              } else {
                alert("Geocoding failed to this location " + status);
              }
            });
    }

function clearWindow() {

    if (infowindow) {
         google.maps.event.clearInstanceListeners(infowindow); 
         infowindow = null;
    }
    infowindow = new google.maps.InfoWindow();
    }

我需要清除信息窗口中的数据。给我一些建议

【问题讨论】:

  • 您是要关闭信息窗口还是只是想清除其中的内容?
  • @DeadMan 嗨,我需要清除内容。

标签: jquery google-maps jquery-mobile google-maps-api-3


【解决方案1】:

然后只需将里面的内容替换为空白:

infowindow.setContent('');

【讨论】:

  • 不,它没有第二次显示带有内容的信息窗口
  • 是什么意思。实际发生的事情以及您想要实现的目标。
  • 我想每次都显示带有新地址的信息窗口。当我导航到地图页面时。但是信息窗口在项目中出现一次。这是我的查询?如果我的帖子不清楚我很抱歉
  • 你能现场直播吗?因为我在谷歌地图上做了很多工作,所以我可以帮助你。
  • 我认为在 js fiddle 中展示并不容易。你能解决我的疑问吗?在没有我明确调用的情况下,infowindow 是如何接近的。
猜你喜欢
  • 1970-01-01
  • 2011-10-15
  • 2011-07-28
  • 2018-08-03
  • 2015-04-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-08
相关资源
最近更新 更多