wip: working on trips
This commit is contained in:
@@ -3,27 +3,25 @@
|
||||
<MglMap :map-style="style" :center="center" :zoom="zoom" map-key="main">
|
||||
<MglNavigationControl />
|
||||
<MglImage id="cluster" :image="image" />
|
||||
<template v-for="r of shownLines" :key="r.route.id">
|
||||
<MapLines :route-with-line="r" />
|
||||
<template v-for="r of store.selectedLines">
|
||||
<MapLines :line="r" />
|
||||
<MapClusters
|
||||
v-if="shownClusters"
|
||||
v-if="shownClusters && r.properties?.route"
|
||||
:clusters="shownClusters"
|
||||
:route="r.route"
|
||||
:route="r.properties.route"
|
||||
/></template>
|
||||
|
||||
<mgl-geo-json-source
|
||||
:source-id="`trip_leg_${index}`"
|
||||
:data="line"
|
||||
v-for="(line, index) in store.selectedTrips"
|
||||
v-for="(line, index) in store.selectedLines"
|
||||
>
|
||||
<mgl-line-layer
|
||||
:layer-id="`trip_line_leg_${index}`"
|
||||
:paint="{
|
||||
'line-width': 4,
|
||||
'line-color':
|
||||
'#' +
|
||||
(store.routesById[line.properties?.routeId]
|
||||
?.color || '000000'),
|
||||
'#' + (line.properties?.route?.color || '000000'),
|
||||
'line-dasharray': [
|
||||
2,
|
||||
line.properties?.mode == 'WALK' ? 1 : 0,
|
||||
@@ -36,17 +34,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type {
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
MultiLineString,
|
||||
Point,
|
||||
} from "geojson";
|
||||
|
||||
const paint = {
|
||||
"line-color": "#FF0000",
|
||||
"line-width": 4,
|
||||
};
|
||||
import type { FeatureCollection, Point } from "geojson";
|
||||
|
||||
import { useMap } from "@indoorequal/vue-maplibre-gl";
|
||||
import { LngLat, LngLatBounds } from "maplibre-gl";
|
||||
@@ -66,10 +54,6 @@ const shownClusters = ref<FeatureCollection<Point> | null>(null);
|
||||
const image = useSvgImage();
|
||||
const map = useMap("main");
|
||||
|
||||
watchEffect(() => {
|
||||
console.log(store.selectedTrip);
|
||||
});
|
||||
|
||||
watch(map, () => {
|
||||
if (map.isLoaded) {
|
||||
emit("loaded");
|
||||
@@ -77,12 +61,12 @@ watch(map, () => {
|
||||
});
|
||||
watchEffect(async () => {
|
||||
const allClusters = [];
|
||||
for (const routeId of store.selectedRouteIds) {
|
||||
if (routeId === undefined) {
|
||||
for (const line of store.selectedLines) {
|
||||
if (line.properties.route === undefined) {
|
||||
continue;
|
||||
}
|
||||
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/${line.properties.route.id}/clusters`,
|
||||
);
|
||||
allClusters.push(...apiClusters);
|
||||
}
|
||||
@@ -102,15 +86,13 @@ watchEffect(async () => {
|
||||
...shownClusters.value.features.map(
|
||||
(point) => point.geometry.coordinates,
|
||||
),
|
||||
...shownLines.value
|
||||
.map((line) => line.line.geometry.coordinates)
|
||||
.flat(2),
|
||||
...store.selectedLines.map((line) => line.geometry.coordinates).flat(2),
|
||||
];
|
||||
const bounds = coordinates
|
||||
// .filter((c) => stops.includes(c.properties?.id))
|
||||
.reduce(
|
||||
(bounds, coords) => {
|
||||
return bounds.extend(new LngLat(coords[0]!, coords[1]!));
|
||||
return bounds.extend(new LngLat(coords[0], coords[1]));
|
||||
},
|
||||
new LngLatBounds([
|
||||
firstPoint.geometry.coordinates[0]!,
|
||||
@@ -123,25 +105,6 @@ watchEffect(async () => {
|
||||
padding: 20,
|
||||
});
|
||||
});
|
||||
|
||||
const shownLines = computed(() => {
|
||||
const l: { route: Route; line: Feature<MultiLineString> }[] = [];
|
||||
for (const routeId of store.selectedRouteIds) {
|
||||
const route = store.routesById[routeId];
|
||||
if (!route) {
|
||||
continue;
|
||||
}
|
||||
const line = store.linesById[routeId.replace(":", "_")];
|
||||
if (!line) {
|
||||
continue;
|
||||
}
|
||||
l.push({
|
||||
route,
|
||||
line,
|
||||
});
|
||||
}
|
||||
return l;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="css">
|
||||
|
||||
Reference in New Issue
Block a user