<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!