Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/plugins/pins/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { useCoreStore } from '@/core/stores/export'
export const usePinsStore = defineStore('plugins/pins', () => {
const coreStore = useCoreStore()

const coordinate = ref<Coordinate>([])
const coordinate = ref<Coordinate | null>(null)
const getsDragged = ref(false)

const configuration = computed<
Expand All @@ -49,6 +49,9 @@ export const usePinsStore = defineStore('plugins/pins', () => {
)
)
const latLon = computed(() => {
if (!coordinate.value) {
return null
}
const lonLat = toLonLat(coordinate.value, coreStore.configuration.epsg)
return [lonLat[1], lonLat[0]]
})
Expand Down Expand Up @@ -160,15 +163,17 @@ export const usePinsStore = defineStore('plugins/pins', () => {
feature.getGeometry() as Point
).getCoordinates()

addPin(
!(await isCoordinateInBoundaryLayer(
geometryCoordinates,
coreStore.map,
configuration.value.boundary
))
? coordinate.value
: geometryCoordinates
)
const newCoordinate = !(await isCoordinateInBoundaryLayer(
geometryCoordinates,
coreStore.map,
configuration.value.boundary
))
? coordinate.value
: geometryCoordinates

if (newCoordinate) {
addPin(newCoordinate)
}
})
})
coreStore.map.addInteraction(translate)
Expand Down
Loading