OSRM 5如何获得概述=完整

时间:2016-09-08 14:16:45

标签: osrm

我遇到一些新的OSRM问题,我无法使用overview = full发送请求,你能帮助我。

我的代码:

var map = L.map('map');

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

var control = L.Routing.control(L.extend(window.lrmConfig, {
    //router: routera
    waypoints: [
        L.latLng(52.4, 11.44),
        L.latLng(52.92, 11.65)
    ],
    geocoder: L.Control.Geocoder.nominatim(),
    routeWhileDragging: true,
    reverseWaypoints: false,
    showAlternatives: true,
    altLineOptions: {
        styles: [
            {color: 'black', opacity: 0.15, weight: 9},
            {color: 'white', opacity: 0.8, weight: 6},
            {color: 'blue', opacity: 0.5, weight: 2}
        ]
    }
})).addTo(map);

我尝试定义路线,但不起作用。现在代码是正确的。

1 个答案:

答案 0 :(得分:1)

我有一个解决方案。

    router: L.Routing.osrmv1({
        routingOptions: {
            alternatives: true,
            steps: true,
            geometryOnly: true
        }

完整代码。

var map = L.map('map');

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

L.Routing.control({
    waypoints: [
        L.latLng(57.74, 11.94),
        L.latLng(57.6792, 11.949)
    ],
    router: L.Routing.osrmv1({
        routingOptions: {
            alternatives: true,
            steps: true,
            geometryOnly: true
        }
    }),
    showAlternatives: true,
    routeWhileDragging: true,
    altLineOptions: {
        styles: [
            {color: 'black', opacity: 0.15, weight: 9},
            {color: 'white', opacity: 0.8, weight: 6},
            {color: 'blue', opacity: 0.5, weight: 2}
        ]
    }

}).addTo(map);