Use pinia

This commit is contained in:
2026-07-06 19:49:28 +02:00
parent d345ea9ec3
commit 9324a08cf9
12 changed files with 160 additions and 151 deletions
+5 -10
View File
@@ -1,10 +1,6 @@
<template>
<ClientOnly>
<mgl-geo-json-source
v-if="clusters"
source-id="clusters"
:data="clusters"
>
<mgl-geo-json-source source-id="clusters" :data="clusters">
<mgl-circle-layer
layer-id="clusters_dots"
:paint="cluster_paint"
@@ -31,12 +27,14 @@ const cluster_paint = {
const cluster_label = {
"text-field": ["get", "id"],
};
const map = useMap();
const map = useMap("main");
const { clusters } = defineProps<{
clusters: FeatureCollection<Point>;
}>();
console.log(clusters);
async function clusterClick(e: FeatureCollection) {
const feature = e.features[0];
if (!feature || !feature.properties) {
@@ -50,15 +48,12 @@ async function clusterClick(e: FeatureCollection) {
const data = await $fetch<FeatureCollection<Point>>(
`https://data.mobilites-m.fr/api/clusters/${code}/stops`,
);
if (!map.map) {
return;
}
new Popup()
.setLngLat(coordinates)
.setHTML(
`Cluster code : ${feature.properties.code}<br/>This cluster contains ${data.features.length} stops`,
)
.addTo(map.map);
.addTo(map.map!);
}
function clusterEnter() {