增加获取场馆、字典
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
export interface Location {
|
||||
latitude: number
|
||||
longitude: number
|
||||
speed?: number
|
||||
accuracy?: number
|
||||
}
|
||||
|
||||
export interface LocationInfo {
|
||||
latitude: number
|
||||
longitude: number
|
||||
@@ -56,6 +63,24 @@ export const chooseLocation = (): Promise<LocationInfo> => {
|
||||
})
|
||||
}
|
||||
|
||||
export const getLocation = (): Promise<Location> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Taro.getLocation({
|
||||
success: (res) => {
|
||||
resolve({
|
||||
latitude: res.latitude,
|
||||
longitude: res.longitude,
|
||||
speed: res.speed,
|
||||
accuracy: res.accuracy
|
||||
})
|
||||
},
|
||||
fail: (error) => {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 逆地理编码(简化版本,实际项目中应该调用真实的地图服务API)
|
||||
export const reverseGeocode = (latitude: number, longitude: number): Promise<string> => {
|
||||
return new Promise((resolve) => {
|
||||
|
||||
Reference in New Issue
Block a user