1
votes

Ok, so this is kind of a hard problem to describe and there is a ton of code so I'm sorry for not posting it (as it is also proprietary), but its almost irrelevant anyways, as I am merely looking for suggestions and/or ideas on how to accomplish this problem and I appreciate any advice.

Working with Mapbox-gl.js and the directions API v3.0.3 that mapbox has available for it. I am writing an application using Mapbox-directions API to get directions and a polyline on my map. What I am in need of is a way to get directions based upon the heading of the device. (I already have heading available)

ex: User is heading East but nearest route starts heading West, how to force Eastbound directions or access hook to determine if U-turn is necessary.

Currently the only way directions are supplied are merely based upon your location and not heading direction. Is there a way to fake this or force the heading upon the directions API?

Thanks all and I greatly appreciate it!

1
I don't know, but I doubt it. Also noting that this question is just about the Mapbox Directions API, not the Mapbox-GL-JS library. - Steve Bennett
Thank you for your response and thanks for pointing that out, I have updated the question accordingly. - Caleb Swank

1 Answers

0
votes

For anyone else looking for a similar result as stated above, the only way to currently do it before directions-v5 for mapbox-gl.js is released is to use a different method for calling bearing. Check out the mapbox documentation here to use a curl call to get optimized directions. The only caveat with this is you basically don't use their gl-js directions api and have to draw the line, display directions and add markers yourself. But its a valid option if you need more in depth directions available.