解決方法其實 騰訊已經在接口說明了,,
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 () { } });