2010-10-25 37 views
0

我會用JavaScript在Google Maps上打開GMarker(openInfoWindowHtml)。我怎樣才能做到這一點?如何使用JavaScript打開GMarker?

非常感謝您

代碼爲Marker:

function createMarker(point, id, name, address, type, city, image) { 
    var marker = new GMarker(point, customIcons[type]); 
    var html = "Information"; 
    GEvent.addListener(marker, 'click', function() { 
    marker.openInfoWindowHtml(html); 
    }); 
    return marker; 

回答

1

1-2-3步驟是這樣的:

var map = new google.maps.Map(<object to make a map of>) 
var marker = new google.maps.Marker({map: map, title: 'title'}); 
var iwindow = new google.maps.InfoWindow({content: '<blah>html</blah>'}); 
iwindow.open(map,marker); 

只是事件綁定到它,你想要它。不過這是google api的新版本,而您使用的是舊版本(仍然支持)

相關問題