diff --git a/components/data-graph.vue b/components/data-graph.vue index b07a35b3..7681e291 100644 --- a/components/data-graph.vue +++ b/components/data-graph.vue @@ -8,6 +8,7 @@ import { colors } from "../project.config.json"; const props = defineProps<{ networkData: NetworkEntity; searchNode: string; + detailNode?: string; }>(); const graph = new Graph(); @@ -62,5 +63,10 @@ function getNodeColor(nodeClass: string) { diff --git a/components/data-map-view.vue b/components/data-map-view.vue index 2cab6c7e..8bd21b68 100644 --- a/components/data-map-view.vue +++ b/components/data-map-view.vue @@ -16,12 +16,17 @@ const route = useRoute(); const t = useTranslations(); const currentView = useGetCurrentView(); +const { getUnprefixedId } = useIdPrefix(); const searchFiltersSchema = v.object({ category: v.fallback(v.picklist(categories), "entityName"), search: v.fallback(v.string(), ""), }); +const detailEntityId = computed(() => { + return route.params.id as string; +}); + const searchFilters = computed(() => { return v.parse(searchFiltersSchema, route.query); }); @@ -48,7 +53,7 @@ const { data, isPending, isPlaceholderData } = useGetSearchResults( : [], show: ["geometry", "when"], centroid: true, - system_classes: ["place", "object_location"], + system_classes: ["place"], limit: 0, }; }), @@ -141,6 +146,34 @@ watch(data, () => { */ popover.value = null; }); + +watchEffect(() => { + const entity = entities.value.find((feature) => { + const id = getUnprefixedId(feature["@id"]); + return id === detailEntityId.value; + }); + + if (entity) { + let coordinates = null; + + if (entity.geometry.type === "GeometryCollection") { + coordinates = entity.geometry.geometries.find((g) => { + return g.type === "Point"; + })?.coordinates as [number, number] | undefined; + } + + if (entity.geometry.type === "Point") { + coordinates = entity.geometry.coordinates as unknown as [number, number]; + } + + popover.value = { + coordinates: + coordinates ?? + (turf.center(createFeatureCollection([entity])).geometry.coordinates as [number, number]), + entities: [entity], + }; + } +});