0

我在获取新的 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);

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

4

1 回答 1

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);
于 2016-09-09T10:33:02.273 回答