feat: add icon instead of red circle
This commit is contained in:
@@ -8,6 +8,19 @@
|
|||||||
@mouseenter="clusterEnter"
|
@mouseenter="clusterEnter"
|
||||||
@mouseleave="clusterLeave"
|
@mouseleave="clusterLeave"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<MglSymbolLayer
|
||||||
|
layer-id="cluster_icon"
|
||||||
|
:layout="{
|
||||||
|
'icon-image': 'cluster',
|
||||||
|
'icon-size': 0.1,
|
||||||
|
'icon-overlap': 'always',
|
||||||
|
'text-overlap': 'always',
|
||||||
|
}"
|
||||||
|
@click="clusterClick"
|
||||||
|
@mouseenter="clusterEnter"
|
||||||
|
@mouseleave="clusterLeave"
|
||||||
|
/>
|
||||||
<MglSymbolLayer
|
<MglSymbolLayer
|
||||||
layer-id="clusters_labels"
|
layer-id="clusters_labels"
|
||||||
:layout="cluster_label"
|
:layout="cluster_label"
|
||||||
@@ -33,10 +46,7 @@
|
|||||||
import type { FeatureCollection, Point } from "geojson";
|
import type { FeatureCollection, Point } from "geojson";
|
||||||
import { useMap } from "@indoorequal/vue-maplibre-gl";
|
import { useMap } from "@indoorequal/vue-maplibre-gl";
|
||||||
import { Popup } from "maplibre-gl";
|
import { Popup } from "maplibre-gl";
|
||||||
const cluster_paint = {
|
|
||||||
"circle-radius": 5,
|
|
||||||
"circle-color": "#FF0000",
|
|
||||||
};
|
|
||||||
const cluster_label = {
|
const cluster_label = {
|
||||||
"text-field": ["get", "id"],
|
"text-field": ["get", "id"],
|
||||||
};
|
};
|
||||||
@@ -48,6 +58,11 @@ const { clusters, route } = defineProps<{
|
|||||||
route: Route;
|
route: Route;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const cluster_paint = {
|
||||||
|
"circle-radius": 18,
|
||||||
|
"circle-color": "#" + route.color,
|
||||||
|
};
|
||||||
|
|
||||||
const popupData = ref<StopTimesPattern[]>([]);
|
const popupData = ref<StopTimesPattern[]>([]);
|
||||||
const popup = new Popup().setMaxWidth("500px").addTo(map.map!);
|
const popup = new Popup().setMaxWidth("500px").addTo(map.map!);
|
||||||
|
|
||||||
@@ -65,21 +80,23 @@ async function clusterClick(e: FeatureCollection) {
|
|||||||
if (!code) {
|
if (!code) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let data;
|
// let data;
|
||||||
const coordinates = feature.geometry.coordinates.slice();
|
const coordinates = feature.geometry.coordinates.slice();
|
||||||
[data, popupData.value] = await Promise.all([
|
// [data, popupData.value] = await Promise.all([
|
||||||
$fetch<FeatureCollection<Point>>(
|
// $fetch<FeatureCollection<Point>>(
|
||||||
`https://data.mobilites-m.fr/api/clusters/${code}/stops`,
|
// `https://data.mobilites-m.fr/api/clusters/${code}/stops`,
|
||||||
),
|
// ),
|
||||||
$fetch<StopTimesPattern[]>(
|
|
||||||
`https://data.mobilites-m.fr/api/routers/default/index/clusters/${feature.properties.code}/stoptimes?showCancelledTrips=false&route=${route.id}`,
|
// ]);
|
||||||
{
|
|
||||||
headers: {
|
popupData.value = await $fetch<StopTimesPattern[]>(
|
||||||
origin: "PersonalProjectMreso",
|
`https://data.mobilites-m.fr/api/routers/default/index/clusters/${feature.properties.code}/stoptimes?showCancelledTrips=false&route=${route.id}`,
|
||||||
},
|
{
|
||||||
|
headers: {
|
||||||
|
origin: "PersonalProjectMreso",
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
]);
|
);
|
||||||
popup.setDOMContent(popupDiv.value).setLngLat(coordinates).addTo(map.map!);
|
popup.setDOMContent(popupDiv.value).setLngLat(coordinates).addTo(map.map!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<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 />
|
||||||
|
<MglImage id="cluster" :image="image" />
|
||||||
<template v-for="r of shownLines" :key="r.route.id">
|
<template v-for="r of shownLines" :key="r.route.id">
|
||||||
<MapLines :route-with-line="r" />
|
<MapLines :route-with-line="r" />
|
||||||
<MapClusters
|
<MapClusters
|
||||||
@@ -20,6 +21,7 @@ import type {
|
|||||||
MultiLineString,
|
MultiLineString,
|
||||||
Point,
|
Point,
|
||||||
} from "geojson";
|
} from "geojson";
|
||||||
|
|
||||||
import { useMap } from "@indoorequal/vue-maplibre-gl";
|
import { useMap } from "@indoorequal/vue-maplibre-gl";
|
||||||
import { LngLat, LngLatBounds } from "maplibre-gl";
|
import { LngLat, LngLatBounds } from "maplibre-gl";
|
||||||
const style = "https://tiles.versatiles.org/assets/styles/colorful/style.json";
|
const style = "https://tiles.versatiles.org/assets/styles/colorful/style.json";
|
||||||
@@ -29,7 +31,7 @@ const zoom = 12;
|
|||||||
const store = useMresoStore();
|
const store = useMresoStore();
|
||||||
await store.fetchData();
|
await store.fetchData();
|
||||||
const shownClusters = ref<FeatureCollection<Point> | null>(null);
|
const shownClusters = ref<FeatureCollection<Point> | null>(null);
|
||||||
|
const image = useSvgImage();
|
||||||
const map = useMap("main");
|
const map = useMap("main");
|
||||||
watchEffect(async () => {
|
watchEffect(async () => {
|
||||||
const allClusters = [];
|
const allClusters = [];
|
||||||
@@ -61,7 +63,7 @@ watchEffect(async () => {
|
|||||||
// .filter((c) => stops.includes(c.properties?.id))
|
// .filter((c) => stops.includes(c.properties?.id))
|
||||||
.reduce(
|
.reduce(
|
||||||
(bounds, coords) => {
|
(bounds, coords) => {
|
||||||
return bounds.extend(new LngLat(coords[0], coords[1]));
|
return bounds.extend(new LngLat(coords[0]!, coords[1]!));
|
||||||
},
|
},
|
||||||
new LngLatBounds([
|
new LngLatBounds([
|
||||||
firstPoint.geometry.coordinates[0]!,
|
firstPoint.geometry.coordinates[0]!,
|
||||||
|
|||||||
Reference in New Issue
Block a user