refactor part 1
This commit is contained in:
@@ -177,8 +177,8 @@ function buildStationLayer(lat: number, lon: number, dark: boolean): VectorLayer
|
||||
onMounted(async () => {
|
||||
await fetchRadarFrames()
|
||||
|
||||
const lat = (current.value.gps_lat as number) || 0
|
||||
const lon = (current.value.gps_lon as number) || 0
|
||||
const lat = (current.value.latitude as number) || 0
|
||||
const lon = (current.value.longitude as number) || 0
|
||||
|
||||
stationLayer = buildStationLayer(lat, lon, props.dark)
|
||||
|
||||
@@ -221,16 +221,16 @@ onUnmounted(() => {
|
||||
watch(() => props.dark, dark => {
|
||||
map.getLayers().setAt(0, buildBaseLayer(dark))
|
||||
map.removeLayer(stationLayer)
|
||||
const lat = (current.value.gps_lat as number) || 0
|
||||
const lon = (current.value.gps_lon as number) || 0
|
||||
const lat = (current.value.latitude as number) || 0
|
||||
const lon = (current.value.longitude as number) || 0
|
||||
stationLayer = buildStationLayer(lat, lon, dark)
|
||||
map.addLayer(stationLayer)
|
||||
})
|
||||
|
||||
let positioned = false
|
||||
watch(() => current.value, () => {
|
||||
const lat = (current.value.gps_lat as number) || 0
|
||||
const lon = (current.value.gps_lon as number) || 0
|
||||
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 })
|
||||
|
||||
Reference in New Issue
Block a user