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

35 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 经纬度逆解析成地址
//lat = 30.65805;
//lng = 104.136153;
function getAddress(lat,lng,obj){
$.ajax({
type: 'get',
url: 'https://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 {
console.log(data)
alert("位置获取错误,可能用户信息不完整")
}
},
error: function (e) {
console.log(e)
alert("位置获取错误,map服务出错")
}
});
}