mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-06-20 01:44:42 +02:00
list notes
This commit is contained in:
parent
0f5ff6ed45
commit
cb90be8ff2
10 changed files with 119 additions and 36 deletions
|
@ -36,10 +36,12 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Nom ({{ stats.getPlacesCount() }})</th>
|
||||
<th>Type</th>
|
||||
<th>Adresse ({{ stats.getAvecAdresse() }} / {{ stats.getPlacesCount() }})</th>
|
||||
<th>Site web ({{ stats.getAvecSite() }} / {{ stats.getPlacesCount() }})</th>
|
||||
<th>Accessibilité ({{ stats.getAvecAccessibilite() }} / {{ stats.getPlacesCount() }})</th>
|
||||
<th>Note ({{ stats.getAvecNote() }} / {{ stats.getPlacesCount() }})</th>
|
||||
<th>Note ({{ stats.getAvecNote() }} / {{ stats.getPlacesCount() }})</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -48,10 +50,12 @@
|
|||
<td style="background-color: {{ commerce.hasAddress() ? 'yellowgreen' : 'transparent' }};">
|
||||
<a href="{{ path('app_admin_commerce', {'id': commerce.id}) }}">{{ commerce.name }}</a>
|
||||
</td>
|
||||
<td style="background-color: {{ commerce.mainTag ? 'yellowgreen' : 'transparent' }};">{{ commerce.mainTag }}</td>
|
||||
<td style="background-color: {{ commerce.hasAddress() ? 'yellowgreen' : 'transparent' }};">{{ commerce.address }}</td>
|
||||
<td style="background-color: {{ commerce.hasWebsite() ? 'yellowgreen' : 'transparent' }};">{{ commerce.website }}</td>
|
||||
<td style="background-color: {{ commerce.hasWheelchair() ? 'yellowgreen' : 'transparent' }};">{{ commerce.wheelchair }}</td>
|
||||
<td style="background-color: {{ commerce.hasNote() ? 'yellowgreen' : 'transparent' }};">{{ commerce.note }}</td>
|
||||
<td style="background-color: {{ commerce.hasNote() ? 'yellowgreen' : 'transparent' }};">{{ commerce.note }}</td>
|
||||
<td style="background-color: {{ commerce.hasNote() ? 'yellowgreen' : 'transparent' }};">{{ commerce.noteContent }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
@ -88,9 +92,15 @@
|
|||
});
|
||||
|
||||
map.on('load', () => {
|
||||
console.log(data.elements);
|
||||
console.log('map chargé',data.elements);
|
||||
data.elements.forEach(element => {
|
||||
if (element.lat && element.lon) {
|
||||
if(element.tags){
|
||||
|
||||
console.log('element', element.tags['name'] , element);
|
||||
}
|
||||
|
||||
if (element.lat && element.lon && element.tags && element.tags['name']) {
|
||||
|
||||
const el = document.createElement('div');
|
||||
el.className = 'marker';
|
||||
el.style.width = '20px';
|
||||
|
@ -105,10 +115,26 @@
|
|||
}
|
||||
tagstable += '</table>';
|
||||
|
||||
// Créer un élément div pour le texte du nom
|
||||
const nameDiv = document.createElement('div');
|
||||
nameDiv.className = 'marker-name';
|
||||
nameDiv.style.position = 'absolute';
|
||||
nameDiv.style.backgroundColor = 'white';
|
||||
nameDiv.style.padding = '2px 5px';
|
||||
nameDiv.style.borderRadius = '3px';
|
||||
nameDiv.style.fontSize = '12px';
|
||||
nameDiv.style.whiteSpace = 'nowrap';
|
||||
nameDiv.style.transform = 'translate(-50%, -150%)';
|
||||
nameDiv.textContent = element.tags?.name || 'Sans nom';
|
||||
el.appendChild(nameDiv);
|
||||
|
||||
new maplibregl.Marker(el)
|
||||
.setLngLat([element.lon, element.lat])
|
||||
.setPopup(new maplibregl.Popup({ offset: 25 })
|
||||
.setHTML(`<a href="https://openstreetmap.org/${element.type}/${element.id}" target="_blank"><h3>${element.tags?.name || 'Sans nom'}</h3></a> <br> ${tagstable}`))
|
||||
.setHTML(
|
||||
`<a href="/admin/placeType/${element.type}/${element.id}" ><h3>${element.tags?.name || 'Sans nom'}</h3></a> <br><a href="https://openstreetmap.org/${element.type}/${element.id}" target="_blank">OSM</a> ${tagstable}`
|
||||
)
|
||||
)
|
||||
.addTo(map);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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