list notes
This commit is contained in:
parent
0f5ff6ed45
commit
cb90be8ff2
10 changed files with 119 additions and 36 deletions
|
@ -21,7 +21,8 @@
|
|||
{{ parent() }}
|
||||
|
||||
<script src='https://cdn.jsdelivr.net/npm/maplibre-gl@3.6.2/dist/maplibre-gl.js'></script>
|
||||
<script>
|
||||
<script >
|
||||
|
||||
// Définir la fonction labourer dans le scope global
|
||||
function labourer() {
|
||||
window.location.href = '/admin/labourer/' + document.getElementById('app_admin_labourer').value;
|
||||
|
@ -45,7 +46,7 @@
|
|||
|
||||
|
||||
// Attendre le chargement du DOM
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.addEventListener('DOMContentLoaded', async function() {
|
||||
// Récupérer le bouton labourer
|
||||
const btnLabourer = document.querySelector('#labourer');
|
||||
if (btnLabourer) {
|
||||
|
@ -58,30 +59,29 @@
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
const postalCodes = [{% for stat in stats %}'{{ stat.zone }}'{% if not loop.last %}, {% endif %}{% endfor %}];
|
||||
const postalCodes = [{% for stat in stats %}'{{ stat.zone }}'{% if not loop.last %}, {% endif %}{% endfor %}];
|
||||
|
||||
console.log(postalCodes);
|
||||
let postalLines = ``;
|
||||
postalCodes.forEach(code => {
|
||||
if (/^\d+$/.test(code)) {
|
||||
postalLines += `nwr["boundary"="postal_code"][postal_code=${code}]["name"~"."];`;
|
||||
postalLines += `\nnode[place=city]["addr:postcode"=${code}][name];`
|
||||
}
|
||||
});
|
||||
const query = `[out:json];
|
||||
|
||||
const query = `[out:json][timeout:25];
|
||||
(
|
||||
${postalLines}
|
||||
);
|
||||
out center;` ;
|
||||
console.log(query);
|
||||
console.log('https://overpass-api.de/api/interpreter');
|
||||
const response = await fetch('https://overpass-api.de/api/interpreter', {
|
||||
method: 'POST',
|
||||
body: query
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
console.log(data);
|
||||
console.log('data',data);
|
||||
|
||||
// Ajouter un marqueur pour chaque point de la réponse
|
||||
const bounds = new maplibregl.LngLatBounds();
|
||||
|
@ -111,15 +111,6 @@ const postalCodes = [{% for stat in stats %}'{{ stat.zone }}'{% if not loop.last
|
|||
padding: 50
|
||||
});
|
||||
}
|
||||
|
||||
return data.elements.reduce((acc, element) => {
|
||||
if (element.tags?.['postal_code']) {
|
||||
acc[element.tags['postal_code']] = [element.lon, element.lat];
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue