Skip to content

Commit

Permalink
chore: inform users how many points are displayed on the map
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviareichl committed Jun 6, 2024
1 parent 752d3cc commit 6cf63d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
17 changes: 15 additions & 2 deletions components/data-map-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<EntityFeature> } | null>(null);
function onLayerClick(features: Array<MapGeoJSONFeature & Pick<GeoJsonFeature, "properties">>) {
Expand Down Expand Up @@ -154,14 +167,14 @@ watch(data, () => {
class="m-1.5 size-2 rounded-full"
:style="`background-color: ${project.colors.geojsonPoints}`"
></span>
{{ $t("DataMapView.point") }}
{{ $t("DataMapView.point") }} ({{ points.length }})
</div>
<div class="grid grid-cols-[auto_1fr] gap-1">
<span
class="m-1.5 size-2 rounded-full"
:style="`background-color: ${project.colors.geojsonAreaCenterPoints}`"
></span>
{{ $t("DataMapView.centerpoint") }}
{{ $t("DataMapView.centerpoint") }} ({{ centerpoints.length }})
</div>
</div>
</div>
Expand Down
16 changes: 3 additions & 13 deletions components/geo-map.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ watch(() => {
}, updateScope);
watch(() => {
console.log(props.polygons);
return props.polygons;
}, updatePolygons);
Expand All @@ -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);
Expand Down

0 comments on commit 6cf63d2

Please sign in to comment.