1. <html>
  2. <head>
  3. <title>Location-Test Page</title>
  4. </head>
  5. <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
  6. <script>
  7. function convertAddress() {
  8. var geocoder;
  9. var address = document.getElementById("address").value;
  10. geocoder = new google.maps.Geocoder();
  11. geocoder.geocode( { 'address': address}, function(results, status) {
  12. if (status == google.maps.GeocoderStatus.OK) {
  13. document.getElementById('latlong').value = (results[0].geometry.location);
  14. }
  15. else {
  16. alert("Geocode was not successful for the following reason: " + status);
  17. }
  18. });
  19. }
  20. </script>
  21. <body>
  22. <input id="address" type="textbox" value="Washington, DC">
  23. <input id="latlong" type="text" />
  24. <input type="button" value="Convert" onclick="convertAddress()">
  25. </body>