0
点赞
收藏
分享

微信扫一扫

天地图API接口地址批量转换为经纬度的解决方案

青鸾惊鸿 2022-01-31 阅读 67


<table>
<tr>
<td>地址</td>
<td>经纬度</td>
</tr>
<tbody id="content"></tbody>
</table>

封装接口函数

function transAddress(address) {
var keyWord = {"keyWord": address};
var url = 'http://api.tianditu.gov.cn/geocoder?ds={"keyWord":"' + address + '"}&tk=1fceeaf80900c98780034dda6e38dcf3';
$.getJSON(url, function (res) {
var trHtml = "";
trHtml += "<tr><td>" + res.location.keyWord + "</td><td>" + res.location.lon + "," + res.location.lat + "</td></tr>"
$("#content").append(trHtml)
})
}

循环导出数据

//循环导出;
for (var i = 0; i < add.length; i++) {
console.log();
transAddress(add[i]);
}

lockdatav done!



举报

相关推荐

0 条评论