Quiero colocar la llamada a la funcion antes de que empiece body, para ello estoy intentando usar window.onload pero no funciona.
Si funciona cuando coloco
Código HTML:
<body onload="initialize();">
pero no es lo que quiero. Que estoy haciendo mal?.
Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head><title>mapa</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(-43.43787, -70.645094);
var settings = {
zoom: 15,
center: latlng,
mapTypeControl: true,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: true,
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP};
var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
}
window.onload = initialize();
</script>
</head>
<body>
<div id="map_canvas" style="width:500px; height:300px"></div>
</body>
</html>