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

18 lines
No EOL
590 B
JavaScript

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);
}