大批量其他经纬度转换为百度地图经纬度

大批量其他经纬度转换为百度地图经纬度


<html>

<head>
    <script src="./jquery-3.4.1.min.js">script>
    <script>
    // 按格式把大批量经纬度字符串放入变量string
        var string = "118.79055,31.97043;118.79127,31.96962;118.79172,31.96917;118.7919,31.97061;118.79199,31.96971;118.79244,31.96926;";
        let l1 = string.split(';');
        let leng = l1.length;
        let flag = 0;
        resultFun();

        function threePoint(index) {
            let array = l1[index].split(',');
            if (leng >= flag) {
            	// 注意使用你自己的百度地图AK
                let url = 'http://api.map.baidu.com/geoconv/v1/?coords=' + array[0] + ',' + array[1] + '&from=1&to=5&ak=你的AK&callback=resultFun';
                jQuery.getScript(url);
            }
        }

        function resultFun(result) {
            if (flag > 0)
                $("#show").append(result['result'][0]['x'] + ',' + result['result'][0]['y'] + ';
'
) if (flag <= leng) threePoint(flag++); }
script> head> <body> <div id="show"> div> body> html>

你可能感兴趣的:(java-web)