Page 1 of 1

Google Maps Problem ;(

Posted: Sat Dec 05, 2009 8:12 am
by drumking88
I am currently trying to get the center of a point on a Google Map. Ive used the Google Maps API to get the map, and am trying to get the Lattitude, Longitude values.

My Javascript code is:

Code: Select all

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(-29.966889,30.945416);
    var myOptions = {
      zoom: 15,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  }
 
</script>
</head>
<body onload="initialize()">
  <div id="map_canvas" style="width:25%; height:25%"></div>
 
I need to get the Lattitude/Long values of locations. From a developers viewpoint, Ive used a hack (http://www.tech-recipes.com/rx/2403/goo ... de_values/), but I need to make it an automatic process so that the long/lat values appear underneath the map.

Im slowly picking up more and more javascript, and I tried the following:

Code: Select all

<script type = "text/javascript">
  document.write(gApplication.getMap().getCenter());
  </script>
This didn't work - gApplication.getMap() is a call from the hack (see link above).

Any help would be appreciated.

Thanks

Drumking88