You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.0 KiB
57 lines
1.0 KiB
let location = {}
|
|
|
|
/**
|
|
* 打开内置地图
|
|
* @date 2022-09-21
|
|
*/
|
|
location.openLocation = function(lat, lng, name = '', address = '') {
|
|
return new Promise((resolve, reject) => {
|
|
uni.openLocation({
|
|
latitude: Number(lat),
|
|
longitude: Number(lng),
|
|
name: name,
|
|
address: address,
|
|
success: (res) => {
|
|
console.log('openLocationSuccess', res)
|
|
resolve(res)
|
|
},
|
|
fail: (res) => {
|
|
console.log('openLocationFail', res)
|
|
reject(res)
|
|
},
|
|
complete: (res) => {
|
|
console.log('openLocationComplete', res)
|
|
},
|
|
})
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 获取当前的地理位置、速度
|
|
* @date 2022-11-17
|
|
*/
|
|
location.getLocation = function() {
|
|
return new Promise((resolve, reject) => {
|
|
uni.getLocation({
|
|
type: 'wgs84',
|
|
success: (res) => {
|
|
console.log('getLocationSuccess', res)
|
|
resolve({
|
|
lng: res.longitude,
|
|
lat: res.latitude
|
|
})
|
|
},
|
|
fail: (res) => {
|
|
console.log('getLocationFail', res)
|
|
reject(res)
|
|
},
|
|
complete: (res) => {
|
|
// console.log('getLocationComplete', res)
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
|
|
export default location
|