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

33 lines
1.2 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',
url: 'http://apis.map.qq.com/ws/geocoder/v1',
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 {
alert("位置获取错误,请联系管理员!")
}
},
error: function () {
alert("位置获取错误,请联系管理员!")
}
});
}