Hey guys,

Today is my first day with google maps API.
I created a code to get the coordination of the clicked location on
the map that I've created.

it works but it returns the wrong coordination in the map and
therefore it creates a marker in a wrong location. can you help me fix
this problem?

here's how I did that ...

Best Regards,
Sam
------------------------------------------------------------------------------------

<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/
>
    <title>Google Maps JavaScript API Example</title>
    <script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;sensor=false&amp;key=<<INSERT KEY>>"
            type="text/javascript"></script>
    <script type="text/javascript">

    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
                map.setMapType(G_HYBRID_MAP);
        map.setCenter(new GLatLng(42.4419, -307.1419), 5);
                //var center = map.getCenter();
      // alert(center.toString());
          GEvent.addListener(map,"click", function(overlay,latlng){
      if (latlng) {

          alert(" Latitude:" + latlng.lat().toString() + ", Longitude:" +
latlng.lng().toString());

        var latlng2 = new GLatLng(latlng.lat(),latlng.lng());
        map.addOverlay(new GMarker(latlng2));


      }
          });
             map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());


      }
    }

    </script>
  </head>
  <body onload="initialize()" onunload="GUnload()">
    <div id="map_canvas" style="width: 700px; height:
500px;border:solid 1px #333333"></div>
    <p>
      <label>
      <input type="text" Id="sam" name="textfield" />
      </label>
    </p>
  </body>
</html>

-----------------------------------------------------------------------------------------------------------

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to Google-Maps-API@googlegroups.com
To unsubscribe from this group, send email to 
google-maps-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to