2024-07-16 14:43:40 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
|
|
|
|
import type { Feature } from "geojson"
|
|
|
|
|
import { GeoOperations } from "../../Logic/GeoOperations"
|
|
|
|
|
import { MapLibreAdaptor } from "../Map/MapLibreAdaptor"
|
|
|
|
|
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
|
|
|
|
import ShowDataLayer from "../Map/ShowDataLayer"
|
|
|
|
|
import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeatureSource"
|
|
|
|
|
import MaplibreMap from "../Map/MaplibreMap.svelte"
|
2025-01-08 16:36:34 +01:00
|
|
|
import DelayedComponent from "../Base/DelayedComponent.svelte"
|
2025-08-01 03:07:37 +02:00
|
|
|
import { onDestroy } from "svelte"
|
2024-07-16 14:43:40 +02:00
|
|
|
|
|
|
|
|
export let state: SpecialVisualizationState
|
|
|
|
|
export let tagSource: UIEventSource<Record<string, string>>
|
2025-07-11 04:26:56 +02:00
|
|
|
export let defaultzoom: number
|
|
|
|
|
export let idkeys: string[]
|
2024-07-16 14:43:40 +02:00
|
|
|
export let feature: Feature
|
2025-07-11 04:26:56 +02:00
|
|
|
export let clss : string = "h-40 rounded"
|
|
|
|
|
const keys =idkeys
|
2024-07-16 14:43:40 +02:00
|
|
|
let featuresToShow: Store<Feature[]> = state.indexedFeatures.featuresById.map(
|
|
|
|
|
(featuresById) => {
|
|
|
|
|
if (featuresById === undefined) {
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
const properties = tagSource.data
|
|
|
|
|
const features: Feature[] = []
|
|
|
|
|
for (const key of keys) {
|
|
|
|
|
const value = properties[key]
|
|
|
|
|
if (value === undefined || value === null) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let idList = [value]
|
|
|
|
|
if (Array.isArray(value)) {
|
|
|
|
|
idList = value
|
2024-07-21 10:52:51 +02:00
|
|
|
} else if (key !== "id" && typeof value === "string" && value?.startsWith("[")) {
|
2024-07-16 14:43:40 +02:00
|
|
|
// This is a list of values
|
|
|
|
|
idList = JSON.parse(value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const id of idList) {
|
|
|
|
|
const feature = featuresById.get(id)
|
|
|
|
|
if (feature === undefined) {
|
|
|
|
|
console.warn("No feature found for id ", id)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
features.push(feature)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return features
|
|
|
|
|
},
|
2025-08-01 03:07:37 +02:00
|
|
|
[tagSource], onDestroy
|
2024-07-16 14:43:40 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
let mlmap = new UIEventSource(undefined)
|
|
|
|
|
let [lon, lat] = GeoOperations.centerpointCoordinates(feature)
|
|
|
|
|
let mla = new MapLibreAdaptor(mlmap, {
|
|
|
|
|
rasterLayer: state.mapProperties.rasterLayer,
|
|
|
|
|
zoom: new UIEventSource<number>(17),
|
2024-07-21 10:52:51 +02:00
|
|
|
maxzoom: new UIEventSource<number>(17),
|
2024-07-16 14:43:40 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
mla.allowMoving.setData(false)
|
|
|
|
|
mla.allowZooming.setData(false)
|
|
|
|
|
mla.location.setData({ lon, lat })
|
2025-07-11 04:26:56 +02:00
|
|
|
mla.zoom.setData(defaultzoom)
|
2024-07-16 14:43:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
ShowDataLayer.showMultipleLayers(
|
|
|
|
|
mlmap,
|
|
|
|
|
new StaticFeatureSource(featuresToShow),
|
2024-10-17 04:06:03 +02:00
|
|
|
state.theme.layers,
|
2025-01-18 00:30:06 +01:00
|
|
|
{ zoomToFeatures: true }
|
2024-07-16 14:43:40 +02:00
|
|
|
)
|
|
|
|
|
</script>
|
|
|
|
|
|
2025-07-11 04:26:56 +02:00
|
|
|
<div class={clss} style="overflow: hidden; pointer-events: none;">
|
2025-01-08 16:36:34 +01:00
|
|
|
<DelayedComponent>
|
|
|
|
|
<MaplibreMap interactive={false} map={mlmap} mapProperties={mla} />
|
|
|
|
|
</DelayedComponent>
|
2024-07-16 14:43:40 +02:00
|
|
|
</div>
|