Skip to content

Commit

Permalink
Center selected location marker when location is point geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
hvangeffen committed Sep 30, 2024
1 parent 3ef2bc7 commit e6ecbd0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/components/wms/LocationsLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
MglMarker,
useMap,
} from '@indoorequal/vue-maplibre-gl'
import { FeatureCollection, Geometry } from 'geojson'
import type { FeatureCollection, Geometry, Point } from 'geojson'
import { type Location } from '@deltares/fews-pi-requests'
import {
LngLat,
Expand Down Expand Up @@ -95,11 +95,20 @@ const selectedLocationCoordinates = computed(() => {
const selectedLocation = geojson.value.features.find(
(feature) => feature.properties.locationId === props.selectedLocationId,
)
const lat = selectedLocation?.properties.lat
const lng = selectedLocation?.properties.lon
if (!lat || !lng) return
return new LngLat(+lng, +lat)
if (selectedLocation?.geometry.type == 'Point') {
const geometry = selectedLocation.geometry as Point
const lng = geometry.coordinates[0]
const lat = geometry.coordinates[1]
return new LngLat(lng, lat)
} else {
const lat = selectedLocation?.properties.lat
const lng = selectedLocation?.properties.lon
if (!lat || !lng) return undefined
return new LngLat(+lng, +lat)
}
})
const layoutSymbolSpecification = {
Expand Down

0 comments on commit e6ecbd0

Please sign in to comment.