Hi,
Could you add latitude and longitude in the google address widget ?
Thanks
Could you add latitude and longitude in the google address widget ?
Thanks
While you're waiting, you can add a little javascript to get it yourself
https://stackoverflow.com/questions/13478646/google-map-api-get-latitude-and-longitude-from-autocomplete-without-map
https://stackoverflow.com/questions/13478646/google-map-api-get-latitude-and-longitude-from-autocomplete-without-map
You sure do. This JS would be AFTER you've used the address widget to get the place ID
There sure are, do you know a little JS? Pick the one that seems best. Too tired to do it for you at the moment sorry, but it gives you a place to start.
something I don't understand
I load the api
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyArIMfFJkRRrUBQh1wfcUjYx8dYPfBt5mI&callback=initMap" type="text/javascript"></script>
the script js
After select a town the console indicate the key is not good!!!
Geocoding Service: This API project is not authorized to use this API. For more information on authentication and Google Maps JavaScript API services please see: https://developers.google.com/maps/documentation/javascript/get-api-key js:55:110
Geocode was not successful for the following reason: REQUEST_DENIED
The key is valid with the google address widget, it works...
I load the api
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyArIMfFJkRRrUBQh1wfcUjYx8dYPfBt5mI&callback=initMap" type="text/javascript"></script>
the script js
prospect_town = jQuery("#prospect_town");
prospect_country = jQuery("#prospect_country");
prospect_state = jQuery("#prospect_state");
jQuery(countries).on("change", function(){
prospect_country.val(countries.val());
});
jQuery(countries).on("change", function(){
prospect_state.val(states.val());
prospect_country.val(countries.val());
getLatLngFromAddress( prospect_town.val(), prospect_country.val() )
});
function getLatLngFromAddress(town, country){
var address = town +", "+ country;
var geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
jQuery('#latitude').val(results[0].geometry.location.Pa);
jQuery('#longitude').val(results[0].geometry.location.Qa);
} else {
console.log("Geocode was not successful for the following reason: " + status);
}
});
}
After select a town the console indicate the key is not good!!!
Geocoding Service: This API project is not authorized to use this API. For more information on authentication and Google Maps JavaScript API services please see: https://developers.google.com/maps/documentation/javascript/get-api-key js:55:110
Geocode was not successful for the following reason: REQUEST_DENIED
The key is valid with the google address widget, it works...
Places API and the Maps API might be different, follow the link and have a look
This topic is locked and no more replies can be posted.