【腾讯地图】 webservice api get 请求 返回值 跨域

解决方法其实 腾讯已经在接口说明了,,

1 get URL地址 增加 outpt参数,output=jsonp

2 ajax dataType:"jsonp" 

 

 

请求URL

该请求为GET请求

https://apis.map.qq.com/ws/coord/v1/translate

请求参数

参数必填说明示例
locations 预转换的坐标,支持批量转换, 格式:纬度前,经度后,纬度和经度之间用","分隔,每组坐标之间使用";"分隔; 批量支持坐标个数以HTTP GET方法请求上限为准 locations=39.12,116.83;30.21,115.43
type 输入的locations的坐标类型 可选值为[1,6]之间的整数,每个数字代表的类型说明: 1 GPS坐标 2 sogou经纬度 3 baidu经纬度 4 mapbar经纬度 5 [默认]腾讯、google、高德坐标 6 sogou墨卡托 type=3
key 开发密钥(Key) key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77
output 返回格式:支持JSON/JSONP,默认JSON output=json
callback JSONP方式回调函数 callback=function1

 

复制代码
        var data = {
            locations: "39.12,116.83",
            type: "3",
            key: "<%=qqmap.Key%>",
            output: "jsonp"
        }

        $.ajax({
            type: "GET",
            url: "https://apis.map.qq.com/ws/coord/v1/translate",
            async: false,
            data: data,
            dataType: "jsonp",
            success: function (result) {

                console.log(result);
            },
            error: function (xhr, errorType, error) {

                $.alert(error);

            },
            complete: function () {

            }

        });
复制代码
原文地址:https://www.cnblogs.com/sangwl/p/12965781.html