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
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|