如何将航点转换为纬度和经度?

时间:2014-11-06 11:27:35

标签: javascript asp.net google-maps

var w = [], wp;
            var rleg = directionsDisplay.directions.routes[0].legs[0];
            data.start = {'lat': rleg.start_location.lat(), 'lng': rleg.start_location.lng()}
            data.end = {'lat': rleg.end_location.lat(), 'lng': rleg.end_location.lng()}


            var items = new Array();
            for (var i = 1; i <= textboxes; i++) {
                items[(i - 1)] = document.getElementById(i.toString()).value;
            }

            wp = document.getElementById('toAddress').value;
            if (items.length > 0) {
                w.push(wp)
            }



            for (var i = 0; i < items.length - 1; i++) {
                wp = items[i];
                if (wp !== "") {

                    w.push(wp);
                }
            }
            data.waypoints = w;

            var str = JSON.stringify(data)
            locationroot.value = str;
            return false;

以上代码输出:

{ “开始”:{ “LAT”:22.3038548, “LNG”:70.80213219999996}, “结束”:{ “LAT”:22.470967, “LNG”:70.05772219999994}, “航点”:[ “贾姆讷格尔”,”卡拉瓦德“]}

但我希望输出如下:

{ “开始”:{ “LAT”:22.3038548, “LNG”:70.80213219999996}, “结束”:{ “LAT”:22.470967, “LNG”:70.05772219999994}, “航点”:[[22.224905,70.62623409999992] [22.509108,70.22394120000001]]}

那么如何将航点的位置名称转换为航点的位置纬度和经度????

1 个答案:

答案 0 :(得分:0)