开发者

Why can't I open the info window again when I use google api?

开发者 https://www.devze.com 2023-03-26 12:38 出处:网络
I just want to add the google API to have a little map in a website, but I noticed, that the info window opens and then if I close it i cant open it again, I need to refresh the page.

I just want to add the google API to have a little map in a website, but I noticed, that the info window opens and then if I close it i cant open it again, I need to refresh the page.

Any idea how can a fix this little bug? Here is my code.

function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(42.42895, 19.27435), 14);
        map开发者_开发技巧.setUIToDefault();


        var marker = new GMarker(new GLatLng(42.42895, 19.27435), {  
        draggable: false,  
        title: 'Kuca nemanja'  
        });             

        GEvent.addListener(marker, "click", function() {  
        marker.openInfoWindowHtml('<b>Ovde zivi moj drug <a href="#">link</a></b>');  
        map.closeInfoWindow(); 
        });                         

        map.addOverlay(marker);

      } 

Why can't I open the info window again when I use google api?


Just for everyone to know, the map.closeInfoWindow(); caused the infowindow to close before the close button was clicked therefore when try opening the infowindow again the item could not be opened it was 'double closed'.

GEvent.addListener(marker, "click", function() {  
 marker.openInfoWindowHtml('<b>Ovde zivi moj drug <a href="#">link</a></b>');  
});  
0

精彩评论

暂无评论...
验证码 换一张
取 消