<div class="input-white flex-grow-1" style="min-width: 200px;"><label for="input-localisation" class="w-100" style="padding-right: 10px;"><div><svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22.139 26.614"><g id="Icon_feather-map-pin" data-name="Icon feather-map-pin" transform="translate(-3.5 -0.5)"><path id="Tracé_17" data-name="Tracé 17" d="M24.639,11.569c0,7.832-10.069,14.545-10.069,14.545S4.5,19.4,4.5,11.569a10.069,10.069,0,1,1,20.139,0Z" transform="translate(0 0)" fill="none" stroke="#186d7c" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/><path id="Tracé_18" data-name="Tracé 18" d="M20.213,13.856A3.356,3.356,0,1,1,16.856,10.5a3.356,3.356,0,0,1,3.356,3.356Z" transform="translate(-2.287 -2.287)" fill="none" stroke="#186d7c" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/></g></svg></div><input type="text" placeholder="Localisation" id="input-localisation" name="location" class="w-100" autocomplete="off" value="{% if location is defined and location %}{{ location }}{% endif %}" /><div id="start-localisation"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 512 512"><path d="M256 0c17.7 0 32 14.3 32 32V42.4c93.7 13.9 167.7 88 181.6 181.6H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H469.6c-13.9 93.7-88 167.7-181.6 181.6V480c0 17.7-14.3 32-32 32s-32-14.3-32-32V469.6C130.3 455.7 56.3 381.7 42.4 288H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H42.4C56.3 130.3 130.3 56.3 224 42.4V32c0-17.7 14.3-32 32-32zM107.4 288c12.5 58.3 58.4 104.1 116.6 116.6V384c0-17.7 14.3-32 32-32s32 14.3 32 32v20.6c58.3-12.5 104.1-58.4 116.6-116.6H384c-17.7 0-32-14.3-32-32s14.3-32 32-32h20.6C392.1 165.7 346.3 119.9 288 107.4V128c0 17.7-14.3 32-32 32s-32-14.3-32-32V107.4C165.7 119.9 119.9 165.7 107.4 224H128c17.7 0 32 14.3 32 32s-14.3 32-32 32H107.4zM256 224a32 32 0 1 1 0 64 32 32 0 1 1 0-64z" fill="#186d7c"/></svg></div></label></div><input type="hidden" name="lat" id="input-lat" value="{% if lat is defined and lat and location is defined and location %}{{ lat }}{% endif %}" /><input type="hidden" name="lon" id="input-lon" value="{% if lon is defined and lon and location is defined and location %}{{ lon }}{% endif %}" /><script src="{{ asset('lib/autocomplete/dist/autoComplete.min.js') }}"></script><script>(function() {const config = {selector: "#input-localisation",data: {src: async (query) => {try {const source = await fetch(`/publicapi/villes/${query}`);const data = await source.json();return data;} catch (error) {return error;}},keys: ["villeNomReel"]},resultsList: {element: (list, data) => {if (!data.results.length) {const message = document.createElement("div");message.setAttribute("class", "no_result");message.innerHTML = `<span>Aucun résultat pour "${data.query}"</span>`;list.prepend(message);}},noResults: true,},resultItem: {element: (list, data) => {list.innerHTML = "<div class='d-flex align-items-center justify-content-between gap-5'><div class='fw-semibold'>"+ data.value.villeNomReel +"</div><div>"+ data.value.villeCodePostal.split('-')[0] +"</div></div>"},},debounce: 300,submit: true,searchEngine: (query, record) => {return record;},};const autoCompleteJS = new autoComplete(config);document.getElementById("input-localisation").addEventListener("selection", function (event) {if (event.detail.selection) {document.getElementById('input-localisation').value = event.detail.selection.value.villeNomReel;document.getElementById('input-lat').value = event.detail.selection.value.villeLatitudeDeg;document.getElementById('input-lon').value = event.detail.selection.value.villeLongitudeDeg;}});document.getElementById("start-localisation").addEventListener("click", function (event) {if (navigator.geolocation) {navigator.geolocation.getCurrentPosition(function(position) {document.getElementById('input-localisation').value = "Ma position";document.getElementById('input-lat').value = position.coords.latitude;document.getElementById('input-lon').value = position.coords.longitude;});} else {alert("La géolocalisation n'est pas disponible sur votre appareil.");}});})();</script>