0

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?

EDIT: enter image description here

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.

1 Answer 1

0

Can you please specify what you are trying to achieve?

The map data is OSM or something else. If yes, then Mapbox is going to use OSM data for routing. However, if this use case is only for bike riding, then I can presume the user will be offline.

Your application will download the DB on to the device. You can download the OSM DB and try to see if you can edit the DB itself. For off-road maps, you can check with cities' local forest office or tourism department. https://wiki.openstreetmap.org/wiki/Routing/online_routers and populate the data manually.

Once the data is populated can the user ask the route to redraw itself along some specific way-point on the map? This can be done in several ways one is described here for e.g. github.com/Turistforeningen/leaflet-routing.

However, without DB you will probably not be able to achieve this.

1
  • yes, users can add multiple directions point to generate route. I edited my post to clarify what I want to achieve.
    – radekdob
    Jan 3, 2021 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.