【发布时间】:2012-01-04 13:53:25
【问题描述】:
以下示例在 Google 地图上显示了该位置的简单标记(标准图标),当单击该图标时,它会打开信息窗口。我可以显示默认打开的信息窗口,这样我就不需要点击图标来打开了吗?
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var myOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h2 id="firstHeading" class="firstHeading">Uluru</h2>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title:"Uluru (Ayers Rock)"
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
【问题讨论】:
标签: google-maps google-maps-markers