18 lines
651 B
HTML
18 lines
651 B
HTML
{% extends "chrono/manager_ants_hub_add_form.html" %}
|
|
{% load i18n gadjo %}
|
|
|
|
{% block after-form %}
|
|
<script>
|
|
$('form').on('change keyup', '#id_address, #id_zipcode, #id_city_name', function (event) {
|
|
var q = $('#id_address').val() + ' ' + $('#id_zipcode').val() + ' ' + $('#id_city_name').val();
|
|
console.log('q', q)
|
|
var url = "https://api-adresse.data.gouv.fr/search/?q=" + encodeURIComponent(q);
|
|
$.ajax(url).done(function (data) {
|
|
var coords = data.features[0].geometry.coordinates;
|
|
$('#id_longitude').val(coords[0]);
|
|
$('#id_latitude').val(coords[1]);
|
|
})
|
|
});
|
|
</script>
|
|
{% endblock %}
|