mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-10-09 17:02:46 +02:00
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 %}
|
||||
|
|
|
@ -147,7 +147,7 @@
|
|||
|
||||
|
||||
|
||||
<a href="{{ path('app_admin_stats', {'zip_code': commerce_overpass['tags_converted']['addr:postcode'] ?? '-1'}) }}" class="btn btn-outline-secondary">
|
||||
<a href="{{ path('app_admin_stats', {'zip_code': zone ?? '-1'}) }}" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-bar-chart"></i>
|
||||
{{ 'display.view_stats'|trans }}
|
||||
</a>
|
||||
|
@ -225,7 +225,7 @@
|
|||
|
||||
new mapboxgl.Marker()
|
||||
.setLngLat([{{ commerce_overpass['@attributes'].lon }}, {{ commerce_overpass['@attributes'].lat }}])
|
||||
.setPopup(new mapboxgl.Popup({ offset: 25 }).setHTML('<h1>{{ commerce_overpass.tags_converted.name }}</h1><p>Completion:{{completion_percentage}}%</p>'))
|
||||
.setPopup(new mapboxgl.Popup({ offset: 25 }).setHTML('<h1>{{ commerce_overpass.tags_converted.name }}</h1>'))
|
||||
.addTo(map);
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<td>
|
||||
{{place.zipcode}}
|
||||
</td>
|
||||
<td>{{ place.note }}</td>
|
||||
<td>{{ place.noteContent }}</td>
|
||||
<td><a class="btn btn-primary" href="{{ path('app_admin_commerce', {'id': place.id}) }}">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a></td>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue