Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
- </head>
- <body>
- <button type="button" onclick="enterCity()">Lookup city coordinates</button>
- <input type="text" id="city" value="">
- /*<div id="ooo">
- </div>*/
- <script>
- function enterCity(){
- var city = document.getElementById("city").value;
- googleMapsAPI(city);
- }
- function googleMapsAPI(city){
- var geocoder = new google.maps.Geocoder();
- geocoder.geocode( {'address': city}, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- /*document.getElementById( 'ooo' ).innerHTML += "De coördinaten van " + city + " zijn:<br>" + "Lat: " + results[0].geometry.location.lat() + "<br> Lon: " +results[0].geometry.location.lng() + "<br> Gebruik deze in het onderstaande formulier.";*/
- writeToTxtBox(results);
- } else {
- alert("Something got wrong " + status);
- }
- });
- }
- function writeToTxtBox(results){
- var personName = "Joske";
- var lat = "" + results[0].geometry.location.lat();
- var lon = "" + results[0].geometry.location.lng();
- document.getElementById("ctl00_ctl34_g_28d8cf9b_e2d9_401c_855a_f9f8b638d402_ff11_ctl00_ctl00_TextField").value = personName;
- document.getElementById("ctl00_ctl34_g_28d8cf9b_e2d9_401c_855a_f9f8b638d402_ff21_ctl00_ctl00_TextField").value = lat;
- document.getElementById("ctl00_ctl34_g_28d8cf9b_e2d9_401c_855a_f9f8b638d402_ff31_ctl00_ctl00_TextField").value = lon;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement