JourneyJoker/static/frontend/js/custom-autocomplete.js

18 lines
590 B
JavaScript
Raw Normal View History

2020-01-26 10:53:25 +00:00
var input = document.getElementById('id_destination_name');
2020-01-22 17:32:13 +00:00
var options = {
types: ['(cities)'],
componentRestrictions: {country: 'at'},
language: language
};
autocomplete = new google.maps.places.Autocomplete(input, options);
autocomplete.setFields(['geometry']);
autocomplete.addListener('place_changed', fillInAddress);
function fillInAddress() {
// Get the place details from the autocomplete object.
var place = autocomplete.getPlace();
2020-01-26 10:53:25 +00:00
$("#id_destination_lat").val(place.geometry.location.lat);
$("#id_destination_lon").val(place.geometry.location.lon);
2020-01-22 17:32:13 +00:00
}