this is driving me crazy and I know it should be simple.

I do not currently have a server to post this on...but I'm workng on
it.

I just want to click a button and have an alert show the lat, long of
the map center.  I keep getting an error that the 'map' variable is
not defined.

any thoughts?



<html>
<head>
  <title></title>




  <!-- Load Google Maps API  -->
  <script type="text/javascript" src="http://maps.google.com/maps/api/
js?sensor=false"></script>



 <script type="text/javascript">
//Google Load
function GoogleLoadMap() {
    try {
        var latlng = new google.maps.LatLng(-34.397, 150.644);
        var myOptions = {
            zoom: 8,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new
google.maps.Map(document.getElementById("MyMap"), myOptions);
        }
    catch (e) {
        alert("Google Maps could not load (GoogleLoadMap Function
Error) : " + e.message);
    }
}

//get map info for alert window
function GoogleMapInfo() {
    try {

        var center = map.getCenter();
        var zoom = map.getZoom();
        alert("Center: " + center + "   Zoom: " + zoom);
        }
    catch (e) {
        alert("Google Maps could not load (GoogleMapInfo Function
Error) : " + e.message);
    }
}


</script>
</head>

<body onload="GoogleLoadMap()" bgcolor= "black">
      <input type="button" value="Map Info?" onclick="GoogleMapInfo()"/
>

  <div id="MyMap" style="width: 100%; height: 100%">
  </div>




</body>
</html>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to