//获取经纬度信息
getlocaton() {
let _that = this
uni.getLocation({
type: 'wgs84',
success: function(res) {
_that.formeData.longitude = res.longitude
_that.formeData.latitude = res.latitude
_that.getAreaCode(res.longitude, res.latitude) //把获取到的经纬度转换为中文地址
},
fail() {}
});
},
//经纬度转化为中文地址方法
getAreaCode(longitude, latitude) {
let that = this;
let params = {
location: latitude + ',' + longitude, // 经纬度
key: that.jwdKey, //key值由后台接口获取// key: "LF4BZ-BTMK4-YEMUT-DQARW-WX3OZ-JAF3O","CWEBZ-CJALP-74XD2-VAHQ2-C5VLS-VWF2B " // 这个key值是腾讯位置申请的,后期需要换成项目组的.
output: "jsonp" // output必须jsonp 不然会超时
}
that.$jsonp("https://apis.map.qq.com/ws/geocoder/v1?&poi_options=address_format=short&get_poi=0", params).then(res => {
that.formeData.chineseAdress = res.result.address;
});
},
获取经纬度 +经纬度转换成中文地址
最新推荐文章于 2024-05-11 15:42:18 发布