开发者

Opening Google Maps V2 InfoWindow automatically when map and marker loads

How do you call a markers' infowindow to open when the map loads. For some reason the Google documentation only shows how to respond to a click action. I'm not very good with JavaScript so any help would be appreciated. Thanks!

this is my current code, but for some reason, no map appears. But there is no error to help me pinpoint the problem...

<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">
开发者_C百科</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>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜