更新定位

This commit is contained in:
wpf 2023-09-20 23:12:24 +08:00
parent 66d6ba723e
commit 4f5aa895a5
2 changed files with 30 additions and 26 deletions

View File

@ -1,5 +1,6 @@
{ {
"name" : "里海社区", "name" : "里海社区",
// "appid" : "__UNI__3A527D1",
"appid" : "__UNI__B5B1EDD", "appid" : "__UNI__B5B1EDD",
"description" : "", "description" : "",
"versionName" : "1.1.3", "versionName" : "1.1.3",
@ -74,10 +75,10 @@
// "appkey_android" : "0799f37420c0784f1e6cba230a68bdb1", // "appkey_android" : "0799f37420c0784f1e6cba230a68bdb1",
"appkey_ios" : "82af93ec51139c712c4118d84ba684ee", "appkey_ios" : "82af93ec51139c712c4118d84ba684ee",
"appkey_android" : "048d9f3f323eea894b49c3a7edbc8d87" "appkey_android" : "048d9f3f323eea894b49c3a7edbc8d87"
// "appkey_ios" : "4f8f55618010007147aab96fc72bb408",
// "appkey_android" : "4f8f55618010007147aab96fc72bb408"
} }
}, },
// "appkey_ios" : "4f8f55618010007147aab96fc72bb408",
// "appkey_android" : "4f8f55618010007147aab96fc72bb408"
"geolocation" : { "geolocation" : {
"amap" : { "amap" : {
"__platform__" : [ "ios", "android" ], "__platform__" : [ "ios", "android" ],

View File

@ -168,46 +168,6 @@
// uni.showLoading({ // uni.showLoading({
// title: '' // title: ''
// }) // })
uni.getLocation({
type: 'gcj02',
geocode: true,
isHighAccuracy: true,
success: function async (res) {
that.markers[1].latitude = res.latitude;
that.markers[1].longitude = res.longitude;
that.getDriverLine();
// uni.hideLoading();
uni.showModal({
title: '成功',
content: JSON.stringify(res)
})
},
fail(e) {
// uni.hideLoading();
Toast('获取位置失败');
console.log(e);
// uni.showModal({
// title: '',
// content: JSON.stringify(e)
// })
try {
plus.geolocation.getCurrentPosition(function(position) {
console.log('经度:' + position.coords.longitude);
console.log('纬度:' + position.coords.latitude);
that.markers[1].latitude = position.coords.longitude;
that.markers[1].longitude = position.coords.longitude;
that.getDriverLine();
uni.hideLoading();
uni.showModal({
title: 'plus成功',
content: JSON.parse(position)
})
}, function(error) {
console.error('获取位置失败:', error.message);
uni.showModal({
title: 'plus失败',
content: JSON.parse(error)
})
uni.sendHostEvent('getLocation', '获取位置', (ret) => { uni.sendHostEvent('getLocation', '获取位置', (ret) => {
uni.$on('uniMP_getLocation', (res) => { uni.$on('uniMP_getLocation', (res) => {
try { try {
@ -228,6 +188,49 @@
} }
}) })
}); });
return ;
uni.getLocation({
type: 'gcj02',
geocode: true,
isHighAccuracy: true,
success: function async (res) {
that.markers[1].latitude = res.latitude;
that.markers[1].longitude = res.longitude;
that.getDriverLine();
// uni.hideLoading();
console.log(res);
uni.showModal({
title: '成功',
content: JSON.stringify(res)
})
},
fail(e) {
// uni.hideLoading();
Toast('获取位置失败');
console.log(e);
uni.showModal({
title: '失败',
content: JSON.stringify(e)
})
try {
plus.geolocation.getCurrentPosition(function(position) {
console.log('经度:' + position.coords.longitude);
console.log('纬度:' + position.coords.latitude);
that.markers[1].latitude = position.coords.longitude;
that.markers[1].longitude = position.coords.longitude;
that.getDriverLine();
uni.hideLoading();
uni.showModal({
title: 'plus成功',
content: JSON.parse(position)
})
}, function(error) {
console.error('获取位置失败:', error.message);
uni.showModal({
title: 'plus失败',
content: JSON.parse(error)
})
}); });
} catch (e) { } catch (e) {
uni.showModal({ uni.showModal({