腾讯地图逆地址解析

wx.getLocation({
                type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
                success: function (res) {
                    var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
                    var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
                    //由经纬度反解城市信息
                    $.ajax({
                        url: "https://apis.map.qq.com/ws/geocoder/v1/",
                        type: "get",
                        dataType: 'jsonp',
                        data: {
                            location: latitude + "," + longitude,
                            key: "OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77",
                            output: "jsonp"
                        },
                        success: function (res) {
                            console.log(res);
                        }
                    });
                }
            });
wx.getLocation({
type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success: function (res) {
var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
//由经纬度反解城市信息
$.ajax({
url: "https://apis.map.qq.com/ws/geocoder/v1/",
type: "get",
dataType: 'jsonp',
data: {
location: latitude + "," + longitude,
key: "OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77",
output: "jsonp"
},
success: function (res) {
console.log(res);
}
});
}
});

猜你喜欢

转载自www.cnblogs.com/yangyuhu/p/11672946.html