0

我可以使用云模式和传单找到两点之间的路线。 https://gis.stackexchange.com/questions/49608/cloudmade-routing-with-leaflet-route-is-not-displayed/

但我也想找到从第一点到最后一点的距离和时间。

4

2 回答 2

0

你参考这个函数...函数mapload(){

            var APIKEY = '63ea548e228e44efa4cbe2cc1d82b62d';
            var map = new CM.Map('innerContainer', new CM.Tiles.CloudMade.Web({key: APIKEY}));
            screenSize();
            window.onresize = function(event) {
            screenSize();
            var resize = new CM.Size(document.getElementById('innerContainer').style.width,document.getElementById('innerContainer').style.height);
                    map.checkResize();
        map.setCenter(new CM.LatLng(11.590423, 77.817961), 15);


            }
        map.setCenter(new CM.LatLng(11.590423, 77.817961), 15);
        var directions = new CM.Directions(map, 'panel', '63ea548e228e44efa4cbe2cc1d82b62d');

        var waypoints = [new CM.LatLng(11.590423, 77.817961), new CM.LatLng(11.570621,78.745298)];
        directions.loadFromWaypoints(waypoints);
                    var topRight = new CM.ControlPosition(CM.TOP_RIGHT, new CM.Size(50, 20));
                    map.addControl(new CM.SmallMapControl(), topRight);
                    map.addControl(new CM.LargeMapControl());
                    map.addControl(new CM.ScaleControl());
                    map.addControl(new CM.OverviewMapControl());

}

于 2013-03-20T11:09:35.937 回答
0

见回调getRoute参数response,有字段route_summary,有字段total_distance,但我认为它是直接距离。所以responce也有route_instructions字段,有length项目(id 1),等于子路由距离(总而言之,它必须是真实距离)。请参阅文档:http: //developers.cloudmade.com/wiki/routing-http-api/Response_structure

于 2013-03-18T15:52:48.243 回答