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

18 lines
590 B
JavaScript
Raw Normal View History

2021-03-01 09:56:10 +00:00
var input = document.getElementById('id_destination_name');
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();
$("#id_destination_lat").val(place.geometry.location.lat);
$("#id_destination_lon").val(place.geometry.location.lon);
}