I'm making a map which enables routing over hiking trails. I have GeoJSON data containing my custom hiking trails and they are displayed as layer on the map. User can click on that layer and add LngLat as starting/destination point. Mapbox directions API gives me optimal route between those points.
The issue is when received path is not part of my layer.
I want to restrict routing to only my custom routes. I know that using Mapbox is not possible to exclude specified routes from being taken to calculating directions. But it's somehow made by many sites. Do you have idea how to achieve my concept?
I want to be able to generate route only using my custom trails (in the picture black colour, but route generated by mapbox is different due to algoritm which routing uses). I know, user can add another point on black line and then it will generate proper route, but I have seen some web apps where in this scenario they generate black route in the picture.