perliedman / leaflet-routing-machine

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

How to set limit find route only in one country? #677

Open Heaty566 opened 1 year ago

Heaty566 commented 1 year ago

Hi there,

Is there any feature that I use to limit the find route function to search the route only in my country? For example, I search the route from Ha Noi, Viet Nam to Ho Chi Minh, Viet Nam, but the function returns the shortest route that I have to go to Lao and Cambodia.

Thank you so much

curtisy1 commented 1 year ago

That's a tricky question. The answer I can give you is, I'm not sure. It probably depends on the routing provider you use whether this is possible or not. Mapbox offers exclusions by coordinates in their API, which you could use for certain roads that lead outside the country.

OSRM might need a custom profile or some other hacks

HERE offers this as far as I remember, but since it's a paid service, it probably won't be of much use.

In any of those cases, you probably need to adjust the router to provide the parameter to the api