标签功能
This commit is contained in:
+31
-10
@@ -153,6 +153,25 @@ export default {
|
||||
});
|
||||
});
|
||||
},
|
||||
unigetLocation(){
|
||||
var that = this
|
||||
uni.getLocation({
|
||||
type: 'wgs84', // 默认为 wgs84 坐标系,可选 gcj02
|
||||
success: function (res) {
|
||||
console.log('当前位置的经度:' + res.longitude);
|
||||
console.log('当前位置的纬度:' + res.latitude);
|
||||
that.addmapmarkfn(res.latitude,res.longitude)
|
||||
// 如果需要将经纬度转换为具体地址,可以使用逆地理编码
|
||||
// 这里调用 uni.chooseLocation 或第三方地图服务(如高德、腾讯地图)
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('获取位置失败:', err);
|
||||
},
|
||||
complete: function () {
|
||||
console.log('获取位置完成');
|
||||
}
|
||||
});
|
||||
},
|
||||
initMap() {
|
||||
var that = this
|
||||
loader
|
||||
@@ -171,11 +190,12 @@ export default {
|
||||
console.log("获取位置成功:", position);
|
||||
},
|
||||
(error) => {
|
||||
this.error = this.getErrorMessage(error);
|
||||
uni.showToast({
|
||||
title: this.error,
|
||||
icon: 'none'
|
||||
});
|
||||
that.unigetLocation()
|
||||
// this.error = this.getErrorMessage(error);
|
||||
// uni.showToast({
|
||||
// title: this.error,
|
||||
// icon: 'none'
|
||||
// });
|
||||
console.error("获取位置失败:", error);
|
||||
},
|
||||
{
|
||||
@@ -185,11 +205,12 @@ export default {
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.error = "浏览器不支持 Geolocation API";
|
||||
uni.showToast({
|
||||
title: this.error,
|
||||
icon: 'none'
|
||||
});
|
||||
that.unigetLocation()
|
||||
// this.error = "浏览器不支持 Geolocation API";
|
||||
// uni.showToast({
|
||||
// title: this.error,
|
||||
// icon: 'none'
|
||||
// });
|
||||
console.error("浏览器不支持 Geolocation API");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user