This commit is contained in:
2026-03-30 14:47:09 +02:00
parent 83020dcb5b
commit 71773df0ee
6 changed files with 1312 additions and 713 deletions
+29 -3
View File
@@ -16,12 +16,17 @@
}).addTo(this.map)
this.markersLayer = L.layerGroup().addTo(this.map)
this.markersById = {}
this.refreshMarkers()
// important : Leaflet calcule parfois mal la taille au montage
setTimeout(() => {
this.map.invalidateSize()
}, 100)
// Exposer globalement pour que result-list puisse appeler
window.mapFocus = (id) => {
this.focusFormation(id)
}
},
onUpdated() {
@@ -39,6 +44,7 @@
this.map.remove()
this.map = null
}
window.mapFocus = null
},
refreshMarkers() {
@@ -47,6 +53,7 @@
}
this.markersLayer.clearLayers()
this.markersById = {}
const points = []
const results = this.props.results || []
@@ -56,9 +63,10 @@
if (f.latitude != null && f.longitude != null) {
const marker = L.marker([f.latitude, f.longitude])
marker.bindPopup(`<b>${f.nom}</b><br>${f.ville}`)
marker.bindPopup('<b>' + f.nom + '</b><br>' + f.ville)
marker.addTo(this.markersLayer)
this.markersById[f.id] = marker
points.push([f.latitude, f.longitude])
}
}
@@ -68,7 +76,25 @@
} else {
this.map.setView([46.8, 2.5], 6)
}
},
focusFormation(id) {
var marker = this.markersById[id]
if (marker && this.map) {
// Scroll vers la carte
var mapEl = this.$('div[ref="map"]')
if (mapEl) {
mapEl.scrollIntoView({ behavior: 'smooth', block: 'center' })
}
// Zoom sur le marqueur et ouvrir le popup
setTimeout(() => {
this.map.setView(marker.getLatLng(), 13, { animate: true })
marker.openPopup()
}, 400)
}
}
}
</script>
</map-view>
</map-view>