Reputation: 458
I have a form in laravel where there is google's autocomplete field named as address. There is no map and stores address as New Road, Kathmandu, Nepal. I need to obtain its geo coordinates(lat lng) in controller before storing to database. So that I could calculate radius from it and provide information to users about near people.
Upvotes: 1
Views: 1664
Reputation: 2667
You can do it when you fill address fields on the form. Following is the code to fill longitude and latitude. And then post the form and calculate radius in your controller.
$('#latitude').val(place.geometry.location.lat());
$('#longitude').val(place.geometry.location.lng());
Upvotes: 3