coupon-admin/public/static/manager/js/get_addredss.js

35 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-12-20 08:28:03 +00:00
// 经纬度逆解析成地址
//lat = 30.65805;
//lng = 104.136153;
function getAddress(lat,lng,obj){
$.ajax({
type: 'get',
2022-01-17 03:24:24 +00:00
url: 'https://apis.map.qq.com/ws/geocoder/v1',
2021-12-20 08:28:03 +00:00
dataType: 'jsonp',
data: {
key: "XJXBZ-7EBCD-2MB45-HB73N-R362T-WRFJR",//开发密钥
location: lat + "," + lng,//位置坐标
get_poi: "0",//是否返回周边POI列表1.返回0不返回(默认)
coord_type: "1",//输入的locations的坐标类型,1 GPS坐标
parameter: { "scene_type": "tohome", "poi_num": 20 },//附加控制功能
output: "jsonp"
},
success: function (data, textStatus) {
if (data.status == 0) {
var address = data.result.formatted_addresses.recommend;
//$("#address").html(address);
// console.log(data.result.address)
// console.log(address)
$(obj).text(data.result.address + address);
} else {
2022-01-14 10:21:18 +00:00
console.log(data)
alert("位置获取错误,可能用户信息不完整")
2021-12-20 08:28:03 +00:00
}
},
2022-01-14 10:21:18 +00:00
error: function (e) {
console.log(e)
alert("位置获取错误,map服务出错")
2021-12-20 08:28:03 +00:00
}
});
}