using javascript and body onload

Hi Guys,

Just a quick question. I'm trying to implement a google map function in my project. I'm just adding the javascript in the head section

      function initialize() {
        var latlng = new google.maps.LatLng(<?php echo $centerLat;?>, <?php echo $centerLng;?>);
        var myOptions = {
          zoom: 11,
          center: LatLng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
and then using

But for some reason the map is not loading. Other small tests indicate everything seems to be working ok so I got a feeling its not doing the body onload bit??? Any ideas??


Hmm sorry the body tag should read <body>

damn...body onload initialize()

Hope this works

Well first off, you're setting a variable of latlng but you're calling it as LatLng for the center.

I assume the body tag is <body onload="initialize()">

I don't see any html but I also assume there's an html element somewhere with an id of map_canvas?

<div id="map_canvas"></div>

and that you're calling the google map javascript correctly.

Hello, thanks for taking the time to look at my little problem. It seems that the problem must have been related to a GOOGLE thingy and not the code. I got it all working 6-7hours later but have no idea why (nothing in the code changed)

ho hum, just another one of life's little mysteries....:gulp:

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.