daily pastebin goal
49%
SHARE
TWEET

Pass user Latitude/Longitude as line items based on input

mikele027 Jan 12th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   <script>
  2.     $('#address').on('input', function() {
  3.       var geocoder = new google.maps.Geocoder();
  4.       var address = $(this).val();
  5.  
  6.       geocoder.geocode( { 'address': address}, function(results, status) {
  7.  
  8.         if (status == google.maps.GeocoderStatus.OK) {
  9.           var latitude = results[0].geometry.location.lat();
  10.           var latitude = String(latitude).substr(0, 5);
  11.           var longitude = results[0].geometry.location.lng();
  12.           var longitude = String(longitude).substr(0, 6);
  13.           var cordinates = latitude+', '+longitude;
  14.           jQuery('#latitudelongitude').attr('value', cordinates);
  15.         }
  16.       });
  17.     });
  18.   </script>
RAW Paste Data
Top