Rajveer Singh

Rajveer Singh

  • NA
  • 74
  • 7.7k

Google map address, longitude, latitude to save in database

Sep 23 2016 10:51 AM
<span>Origin:</span><input type="text" id="txtautocomplete" style="width:200px" placeholder="enter start address" /><br /><br />
<label id="lblResult"></label>
<br /><br />
 
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', intilize);
function intilize(){
var autocomplete = new google.maps.places.Autocomplete(document.getElementById('txtautocomplete'));
google.maps.event.addListener(autocomplete, 'place_changed', function(){
var place = autocomplete.getPlace();
var location = "<b>Address:</b>" + place.formatted_address + "<br/>";
location += "<b>Latitude:</b> " + place.geometry.location.lat() + "<br/>";
location += "<b>Longitude:</b> " + place.geometry.location.lng();
document.getElementById('lblResult').innerHTML = location
});
};
</script>
 
 
from this code, im able to auto complete an address from google map and display the address, longitude, latitude.. how can i get this address, longitude, latitude to be saved into mysql database? 

Answers (2)