如何清除gmaps中的信息窗口

时间:2013-03-28 06:47:13

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

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

 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();
    }

我需要清除infowindow中的数据。建议我一些想法

1 个答案:

答案 0 :(得分:2)

然后用空白替换其中的内容:

infowindow.setContent('');
相关问题