From 6cf63d2d8ab2803ffbbc2ce66f2afeae9e4e15cd Mon Sep 17 00:00:00 2001 From: oliviareichl Date: Thu, 6 Jun 2024 13:59:01 +0200 Subject: [PATCH] chore: inform users how many points are displayed on the map --- components/data-map-view.vue | 17 +++++++++++++++-- components/geo-map.client.vue | 16 +++------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/components/data-map-view.vue b/components/data-map-view.vue index e6a84be9..ce8db49c 100644 --- a/components/data-map-view.vue +++ b/components/data-map-view.vue @@ -2,6 +2,7 @@ import { keyByToMap } from "@acdh-oeaw/lib"; import * as turf from "@turf/turf"; import type { MapGeoJSONFeature } from "maplibre-gl"; +import { createSolutionBuilder } from "typescript"; import { z } from "zod"; import type { SearchFormData } from "@/components/search-form.vue"; @@ -86,6 +87,18 @@ const features = computed(() => { }); }); +const centerpoints = computed(() => { + return features.value.filter((centerpoint) => { + return centerpoint.geometry.type === "GeometryCollection"; + }); +}); + +const points = computed(() => { + return features.value.filter((point) => { + return point.geometry.type === "Point"; + }); +}); + const popover = ref<{ coordinates: [number, number]; entities: Array } | null>(null); function onLayerClick(features: Array>) { @@ -154,14 +167,14 @@ watch(data, () => { class="m-1.5 size-2 rounded-full" :style="`background-color: ${project.colors.geojsonPoints}`" > - {{ $t("DataMapView.point") }} + {{ $t("DataMapView.point") }} ({{ points.length }})
- {{ $t("DataMapView.centerpoint") }} + {{ $t("DataMapView.centerpoint") }} ({{ centerpoints.length }})
diff --git a/components/geo-map.client.vue b/components/geo-map.client.vue index 3b8aec8a..6dd9eaaa 100644 --- a/components/geo-map.client.vue +++ b/components/geo-map.client.vue @@ -183,7 +183,6 @@ watch(() => { }, updateScope); watch(() => { - console.log(props.polygons); return props.polygons; }, updatePolygons); @@ -199,24 +198,15 @@ function updateScope() { const sourceCenterpoints = map.getSource(sourceCenterPointsId) as GeoJSONSource | undefined; const points = props.features.filter((point) => { - if (point.geometry.type !== "Point") { - return false; - } - return point; + return point.geometry.type === "Point"; }); const polygons = props.features.filter((polygon) => { - if (polygon.geometry.type !== "GeometryCollection") { - return false; - } - return polygon; + return polygon.geometry.type === "GeometryCollection"; }); const centerpoints = props.features.filter((centerpoint) => { - if (centerpoint.geometry.type !== "GeometryCollection") { - return false; - } - return centerpoint; + return centerpoint.geometry.type === "GeometryCollection"; }); const geojsonPoints = createFeatureCollection(points);