Client fixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { AirTrafficLayer } from '@/services/airtraffic.ts'
|
||||
import {api} from '@/services/api.ts';
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import Map from 'ol/Map'
|
||||
import View from 'ol/View'
|
||||
@@ -176,9 +177,10 @@ function buildStationLayer(lat: number, lon: number, dark: boolean): VectorLayer
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchRadarFrames()
|
||||
const position = await api.position();
|
||||
|
||||
const lat = (current.value.latitude as number) || 0
|
||||
const lon = (current.value.longitude as number) || 0
|
||||
const lat = position?.latitude || 0
|
||||
const lon = position?.longitude || 0
|
||||
|
||||
stationLayer = buildStationLayer(lat, lon, props.dark)
|
||||
|
||||
@@ -226,19 +228,6 @@ watch(() => props.dark, dark => {
|
||||
stationLayer = buildStationLayer(lat, lon, dark)
|
||||
map.addLayer(stationLayer)
|
||||
})
|
||||
|
||||
let positioned = false
|
||||
watch(() => current.value, () => {
|
||||
const lat = (current.value.latitude as number) || 0
|
||||
const lon = (current.value.longitude as number) || 0
|
||||
if (!positioned) {
|
||||
positioned = true
|
||||
map.getView().animate({ center: fromLonLat([lon, lat]), duration: 500 })
|
||||
map.removeLayer(stationLayer)
|
||||
stationLayer = buildStationLayer(lat, lon, props.dark)
|
||||
map.addLayer(stationLayer)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user