Advertisement
Hellboyandso

js js js

Feb 12th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
  5. </head>
  6. <body>
  7.    
  8.     <button type="button" onclick="enterCity()">Lookup city coordinates</button>
  9.     <input type="text" id="city" value="">
  10.    
  11.     /*<div id="ooo">
  12.     </div>*/
  13.    
  14.     <script>
  15.         function enterCity(){
  16.             var city = document.getElementById("city").value;
  17.             googleMapsAPI(city);
  18.         }
  19.        
  20.         function googleMapsAPI(city){
  21.             var geocoder =  new google.maps.Geocoder();
  22.             geocoder.geocode( {'address': city}, function(results, status) {
  23.                 if (status == google.maps.GeocoderStatus.OK) {
  24.                     /*document.getElementById( 'ooo' ).innerHTML += "De co&ouml;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.";*/
  25.                     writeToTxtBox(results);
  26.             } else {
  27.                 alert("Something got wrong " + status);
  28.             }
  29.             });
  30.         }
  31.        
  32.         function writeToTxtBox(results){
  33.             var personName = "Joske";
  34.             var lat = "" + results[0].geometry.location.lat();
  35.             var lon = "" + results[0].geometry.location.lng();
  36.             document.getElementById("ctl00_ctl34_g_28d8cf9b_e2d9_401c_855a_f9f8b638d402_ff11_ctl00_ctl00_TextField").value = personName;
  37.             document.getElementById("ctl00_ctl34_g_28d8cf9b_e2d9_401c_855a_f9f8b638d402_ff21_ctl00_ctl00_TextField").value = lat;
  38.             document.getElementById("ctl00_ctl34_g_28d8cf9b_e2d9_401c_855a_f9f8b638d402_ff31_ctl00_ctl00_TextField").value = lon;
  39.         }
  40.     </script>
  41. </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement