2023-04-26 18:04:42 +02:00
|
|
|
<script lang="ts">
|
|
|
|
/**
|
|
|
|
* Shows a 'floorSelector' and maps the selected floor onto a global filter
|
|
|
|
*/
|
2023-06-14 20:39:36 +02:00
|
|
|
import LayerState from "../../Logic/State/LayerState"
|
|
|
|
import FloorSelector from "../InputElement/Helpers/FloorSelector.svelte"
|
|
|
|
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
2023-04-26 18:04:42 +02:00
|
|
|
|
2023-06-14 20:39:36 +02:00
|
|
|
export let layerState: LayerState
|
|
|
|
export let floors: Store<string[]>
|
|
|
|
export let zoom: Store<number>
|
2023-04-26 18:04:42 +02:00
|
|
|
const maxZoom = 16
|
|
|
|
|
2023-06-14 20:39:36 +02:00
|
|
|
let selectedFloor: UIEventSource<string> = new UIEventSource<string>(undefined)
|
|
|
|
|
|
|
|
selectedFloor.stabilized(5).map(
|
|
|
|
(floor) => {
|
|
|
|
if (floors.data === undefined || floors.data.length <= 1 || zoom.data < maxZoom) {
|
|
|
|
// Only a single floor is visible -> disable the 'level' global filter
|
|
|
|
// OR we might have zoomed out to much ant want to show all
|
|
|
|
layerState.setLevelFilter(undefined)
|
|
|
|
} else {
|
|
|
|
layerState.setLevelFilter(floor)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
[floors, zoom]
|
|
|
|
)
|
2023-04-26 18:04:42 +02:00
|
|
|
</script>
|
2023-06-14 20:39:36 +02:00
|
|
|
|
2023-04-26 18:04:42 +02:00
|
|
|
{#if $zoom >= maxZoom}
|
2023-06-14 20:39:36 +02:00
|
|
|
<FloorSelector {floors} value={selectedFloor} />
|
|
|
|
{/if}
|