- <html>
- <head>
- <title>Location-Test Page</title>
- </head>
- <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
- <script>
- function convertAddress() {
- var geocoder;
- var address = document.getElementById("address").value;
- geocoder = new google.maps.Geocoder();
- geocoder.geocode( { 'address': address}, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- document.getElementById('latlong').value = (results[0].geometry.location);
- }
- else {
- alert("Geocode was not successful for the following reason: " + status);
- }
- });
- }
- </script>
- <body>
- <input id="address" type="textbox" value="Washington, DC">
- <input id="latlong" type="text" />
- <input type="button" value="Convert" onclick="convertAddress()">
- </body>