如何在地图加载时调用标记'infowindow打开。出于某种原因,Google文档仅显示如何响应点击操作。我对JavaScript不太了解,所以任何帮助都会受到赞赏。谢谢!
这是我目前的代码,但出于某种原因,没有地图显示。但是没有任何错误可以帮助我查明问题...
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?sensor=true">
</script>
<script type="text/javascript">
function initialize() {
var map = new GMap2(document.getElementById("map"));
var point = new GLatLng(53.3407791, -6.2596385);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(point, 16);
// Set up three markers with info windows
var html = 'South Anne Street,<br />Dublin 2, Ireland';
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(html); // This opens the info window automatically
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>