实现定位点的功能

This commit is contained in:
叶志超
2022-04-08 00:22:07 +08:00
parent d24c9643ce
commit 4dc89128da
6 changed files with 68 additions and 17 deletions

24
src/stores/position.js Normal file
View File

@@ -0,0 +1,24 @@
import { defineStore } from 'pinia'
import { isLnglat } from '/@/api/util'
export const usePositionStore = defineStore({
id: 'position',
state: () => ({
lng: NaN,
lat: NaN,
}),
getters: {
value: (state) => { state.lng, state.lat }
},
actions: {
set(position) {
if ( !isLnglat(position) ) return false
this.lng = position.lng
this.lat = position.lat
return true
},
},
})