https://uniapp.dcloud.net.cn/api/location/location.html
https://ask.dcloud.net.cn/article/35070
uni.getLocation({
type: 'wgs84',
success: function (res) {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
}
});
data[0].name对应中文地址,比如武汉市江汉区xx路xx号 import amap from '../../common/amap-wx.130.js';
export default {
data() {
return {
amapPlugin: null,
key: '你自己申请的key'
}
},
onLoad() {
this.amapPlugin = new amap.AMapWX({
key: this.key
});
},
methods: {
getLocation() {
uni.showLoading({
title: '获取信息中'
});
this.amapPlugin.getRegeo({
success: (data) => {
console.log(data[0].name)
uni.hideLoading();
}
});
}
}