I'm trying to design a web page that gets the users position and displays it on google maps. I'm trying to get the getLocation() to load at the start with the map. For some reason I doesn't. Here is a link to where I found the get location code. http://www.w3schools.com/html/tryit....l5_geolocation

Code:
script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyAc3TUzM5iM79TeE5JBYi1nYRcKW2HjCec&sensor=false">
</script>

<script>

//var locations = new Array();

var displayLoc = document.getElementById("trackLocs");

//get positions
function getLocation()
 { 	 
  if (navigator.geolocation)
   {
   	navigator.geolocation.getCurrentPosition(showPosition);
   }	
  else{displayLoc.innerHTML="Geolocation is not supported by this browser.";}
}
  
function showPosition(position)
{
  displayLoc.innerHTML="Latitude: " + position.coords.latitude + 
  "<br>Longitude: " + position.coords.longitude;	
}

//load map
function initialize()
{
var mapProp = {
  center:new google.maps.LatLng(51.508742,-0.120850),
  zoom:5,
  mapTypeId:google.maps.MapTypeId.ROADMAP
  };
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}

google.maps.event.addDomListener(window, 'load', initialize);
window.onload = getLocation();
</script>

</head>

<body>
<div class="span-24 last" id="googleMap" style="width:100%; height: 380px;"></div>

<div class="span-24 last" id="trackLocs"> </div>
</body>