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);
}
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>');
});
精彩评论