perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.08k stars 350 forks source link

Как получить массив рассчитанных точек для передачи в переменную? #453

Closed sanyby closed 6 years ago

sanyby commented 6 years ago

Приветствую. Я новичок. Использую в проекте leaflet.polylineDecorator.js для оформления направления движения. Как с помощью вашего плагина получить массив координат для маршрута для записи в БД и передачи в leaflet.polylineDecorator.js. P.S: в leaflet-routing-machine передаю от 5 до 15 координат по одному маршруту

perliedman commented 6 years ago

Hi, I don't speak what I assume is russian.

From a quick google translate, it looks like you want the coordinates of a route. A route has a coordinates property you can use for this, so something like this would probably work:

var control = L.routing.control(...);

control.on('routeselected', function(e) {
    console.log(e.route.coordinates);
});
sanyby commented 6 years ago

You are using OSRM's demo server. Please note that it is NOT SUITABLE FOR PRODUCTION USE. Refer to the demo server's usage policy: https://github.com/Project-OSRM/osrm-backend/wiki/Api-usage-policy

To change, set the serviceUrl option.

Please do not report issues with this server to neither Leaflet Routing Machine or OSRM - it's for demo only, and will sometimes not be available, or work in unexpected ways.

Please set up your own OSRM server, or use a paid service provider for production.

Can I use this only with my server?

I have several requests per month will be

perliedman commented 6 years ago

As the message says, you can either set up your own server, or you can pay someone who delivers OSRM as a service.

For example, Mapbox offers routing with OSRM. You can read about how to use it here: http://www.liedman.net/leaflet-routing-machine/tutorials/alternative-routers/