wip
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
GTFS : le C6 c'est pas présent
|
||||||
+18
-3
@@ -1,13 +1,28 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="main">
|
<NuxtLayout>
|
||||||
<NuxtRouteAnnouncer />
|
<NuxtRouteAnnouncer />
|
||||||
<NuxtPage page-key="main" />
|
<NuxtPage />
|
||||||
</div>
|
</NuxtLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const router = useRoute();
|
||||||
|
const store = useMresoStore();
|
||||||
|
watchEffect(() => {
|
||||||
|
if (router.params.line_id === undefined) {
|
||||||
|
store.selectedRouteIds = [];
|
||||||
|
}
|
||||||
|
if (typeof router.params.line_id !== "string") {
|
||||||
|
store.selectedRouteIds = [];
|
||||||
|
}
|
||||||
|
store.selectedRouteIds = [router.params.line_id];
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<style lang="css">
|
<style lang="css">
|
||||||
body,
|
body,
|
||||||
#main,
|
#main,
|
||||||
|
#__nuxt,
|
||||||
main {
|
main {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
/>
|
/>
|
||||||
</mgl-geo-json-source>
|
</mgl-geo-json-source>
|
||||||
|
|
||||||
<div ref="popup">
|
<div ref="popup-div">
|
||||||
<div v-for="data in popupData" :key="data.pattern.id">
|
<div v-for="data in popupData" :key="data.pattern.id">
|
||||||
Direction {{ data.pattern.lastStopName }}
|
Direction {{ data.pattern.lastStopName }}
|
||||||
<div v-for="time in data.times" :key="time.tripId">
|
<div v-for="time in data.times" :key="time.tripId">
|
||||||
@@ -41,13 +41,19 @@ const cluster_label = {
|
|||||||
"text-field": ["get", "id"],
|
"text-field": ["get", "id"],
|
||||||
};
|
};
|
||||||
const map = useMap("main");
|
const map = useMap("main");
|
||||||
const popup = useTemplateRef("popup");
|
const popupDiv = useTemplateRef("popup-div");
|
||||||
|
|
||||||
const { clusters } = defineProps<{
|
const { clusters, route } = defineProps<{
|
||||||
clusters: FeatureCollection<Point>;
|
clusters: FeatureCollection<Point>;
|
||||||
|
route: Route;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const popupData = ref<StopTimesPattern[]>([]);
|
const popupData = ref<StopTimesPattern[]>([]);
|
||||||
|
const popup = new Popup().setMaxWidth("500px").addTo(map.map!);
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
popup.remove();
|
||||||
|
});
|
||||||
|
|
||||||
async function clusterClick(e: FeatureCollection) {
|
async function clusterClick(e: FeatureCollection) {
|
||||||
popupData.value = [];
|
popupData.value = [];
|
||||||
@@ -59,28 +65,22 @@ async function clusterClick(e: FeatureCollection) {
|
|||||||
if (!code) {
|
if (!code) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let data;
|
||||||
const coordinates = feature.geometry.coordinates.slice();
|
const coordinates = feature.geometry.coordinates.slice();
|
||||||
const data = await $fetch<FeatureCollection<Point>>(
|
[data, popupData.value] = await Promise.all([
|
||||||
|
$fetch<FeatureCollection<Point>>(
|
||||||
`https://data.mobilites-m.fr/api/clusters/${code}/stops`,
|
`https://data.mobilites-m.fr/api/clusters/${code}/stops`,
|
||||||
);
|
),
|
||||||
new Popup()
|
$fetch<StopTimesPattern[]>(
|
||||||
.setLngLat(coordinates)
|
`https://data.mobilites-m.fr/api/routers/default/index/clusters/${feature.properties.code}/stoptimes?showCancelledTrips=false&route=${route.id}`,
|
||||||
.setHTML(
|
|
||||||
`Cluster code : ${feature.properties.code}<br/>This cluster contains ${data.features.length} stops`,
|
|
||||||
)
|
|
||||||
.setDOMContent(popup.value)
|
|
||||||
.setMaxWidth("500px")
|
|
||||||
.addTo(map.map!);
|
|
||||||
|
|
||||||
popupData.value = await $fetch<StopTimesPattern[]>(
|
|
||||||
`https://data.mobilites-m.fr/api/routers/default/index/clusters/${feature.properties.code}/stoptimes?showCancelledTrips=false`,
|
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
origin: "PersonalProjectMreso",
|
origin: "PersonalProjectMreso",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
),
|
||||||
console.log(popupData.value);
|
]);
|
||||||
|
popup.setDOMContent(popupDiv.value).setLngLat(coordinates).addTo(map.map!);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clusterEnter() {
|
function clusterEnter() {
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
<ClientOnly>
|
<ClientOnly>
|
||||||
<MglMap :map-style="style" :center="center" :zoom="zoom" map-key="main">
|
<MglMap :map-style="style" :center="center" :zoom="zoom" map-key="main">
|
||||||
<MglNavigationControl />
|
<MglNavigationControl />
|
||||||
<MapLines
|
<template v-for="r of shownLines" :key="r.route.id">
|
||||||
v-for="r of shownLines"
|
<MapLines :route-with-line="r" />
|
||||||
:key="r.route.id"
|
<MapClusters
|
||||||
:route-with-line="r"
|
v-if="shownClusters"
|
||||||
/>
|
:clusters="shownClusters"
|
||||||
<MapClusters v-if="shownClusters" :clusters="shownClusters" />
|
:route="r.route"
|
||||||
|
/></template>
|
||||||
</MglMap>
|
</MglMap>
|
||||||
</ClientOnly>
|
</ClientOnly>
|
||||||
</template>
|
</template>
|
||||||
@@ -29,14 +30,10 @@ const store = useMresoStore();
|
|||||||
await store.fetchData();
|
await store.fetchData();
|
||||||
const shownClusters = ref<FeatureCollection<Point> | null>(null);
|
const shownClusters = ref<FeatureCollection<Point> | null>(null);
|
||||||
|
|
||||||
const { selectedRoutesId } = defineProps<{
|
|
||||||
selectedRoutesId: string[];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const map = useMap("main");
|
const map = useMap("main");
|
||||||
watchEffect(async () => {
|
watchEffect(async () => {
|
||||||
const allClusters = [];
|
const allClusters = [];
|
||||||
for (const routeId of selectedRoutesId) {
|
for (const routeId of store.selectedRouteIds) {
|
||||||
const apiClusters = await $fetch<Cluster[]>(
|
const apiClusters = await $fetch<Cluster[]>(
|
||||||
`https://data.mobilites-m.fr/api/routers/default/index/routes/${routeId}/clusters`,
|
`https://data.mobilites-m.fr/api/routers/default/index/routes/${routeId}/clusters`,
|
||||||
);
|
);
|
||||||
@@ -80,7 +77,7 @@ watchEffect(async () => {
|
|||||||
|
|
||||||
const shownLines = computed(() => {
|
const shownLines = computed(() => {
|
||||||
const l: { route: Route; line: Feature<MultiLineString> }[] = [];
|
const l: { route: Route; line: Feature<MultiLineString> }[] = [];
|
||||||
for (const routeId of selectedRoutesId) {
|
for (const routeId of store.selectedRouteIds) {
|
||||||
const route = store.routesById[routeId];
|
const route = store.routesById[routeId];
|
||||||
if (!route) {
|
if (!route) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
v-for="route of store.routes"
|
v-for="route of store.routes"
|
||||||
:key="route.id"
|
:key="route.id"
|
||||||
:class="{
|
:class="{
|
||||||
selected: selectedRoutesId.includes(route.id),
|
selected: store.selectedRouteIds.includes(route.id),
|
||||||
lineLabel: true,
|
lineLabel: true,
|
||||||
}"
|
}"
|
||||||
:style="{
|
:style="{
|
||||||
@@ -21,10 +21,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const store = useMresoStore();
|
const store = useMresoStore();
|
||||||
|
|
||||||
const { selectedRoutesId } = defineProps<{
|
|
||||||
selectedRoutesId: string[];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
function selectRoute(routeId: string) {
|
function selectRoute(routeId: string) {
|
||||||
navigateTo(`/lines/${routeId}`);
|
navigateTo(`/lines/${routeId}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<template>
|
||||||
|
<main>
|
||||||
|
<Map map-key="main" />
|
||||||
|
<slot />
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<main>
|
||||||
|
<SidebarContainer />
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<template>
|
|
||||||
<main>
|
|
||||||
<Transition>
|
|
||||||
<KeepAlive>
|
|
||||||
<Map map-key="main" :selectedRoutesId="[router.params.id]" />
|
|
||||||
</KeepAlive>
|
|
||||||
</Transition>
|
|
||||||
|
|
||||||
<SidebarContainer :selectedRoutesId="[router.params.id]" />
|
|
||||||
</main>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
const router = useRoute();
|
|
||||||
</script>
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<main>
|
||||||
|
<SidebarContainer />
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<SidebarContainer />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -11,6 +11,7 @@ export const useMresoStore = defineStore("mresoStore", {
|
|||||||
lines: {} as FeatureCollection<MultiLineString>,
|
lines: {} as FeatureCollection<MultiLineString>,
|
||||||
clusters: {} as FeatureCollection<Point>,
|
clusters: {} as FeatureCollection<Point>,
|
||||||
stops: {} as FeatureCollection<Point>,
|
stops: {} as FeatureCollection<Point>,
|
||||||
|
selectedRouteIds: [] as string[],
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
async fetchData(options: { signal?: AbortSignal } = {}) {
|
async fetchData(options: { signal?: AbortSignal } = {}) {
|
||||||
|
|||||||
@@ -9,4 +9,19 @@ export default defineNuxtConfig({
|
|||||||
// include: ["maplibre-gl"],
|
// include: ["maplibre-gl"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// hooks: {
|
||||||
|
// "pages:extend"(pages) {
|
||||||
|
// pages.push({
|
||||||
|
// name: "lines",
|
||||||
|
// path: "/lines/",
|
||||||
|
// file: "~/pages/lines/[line_id]/cluster/[cluster_id]/index.vue",
|
||||||
|
// });
|
||||||
|
// pages.push({
|
||||||
|
// name: "line_id",
|
||||||
|
// path: "/lines/:id()",
|
||||||
|
|
||||||
|
// file: "~/pages/lines/[line_id]/cluster/[cluster_id]/index.vue",
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// },
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user