Open ghost opened 6 years ago
Hello,
At the end of the day I implemented a service that searches the MapBox Directions API. After obtaining the results, the service filters the JSON and returns me only the location directions, the intersections. That way I can use the addPolilyne
method to construct the route.
If someone searches for the same information, follow the steps in this link: Mapbox API - Directions
The endpoint I used to get the steps right was: https://api.mapbox.com/directions/v5/mapbox/{{ type }}/{{ startingLocation}};{{ finalLocation}}?steps=true&overview=false&access_token={{ token }}
According to the API, you can submit from 2 to 25 locations to get the results. The request return not only the locations, but too the name of intersections, geometry, etc.
NOTE:
By default, you enter the latitude first and then the longitude. For example: coordinate: [37.78, -122.42]
But in the Mapobox API, the longitude comes first. For example: coordinate: [-122.42, 37.78]
How did you add your encoded poly line or geoJSON coordinates? I can't get any lines to show, only markers so far. The lat/lon seems to be backwards as well in addPolyline...
@wyattp11 Also interested in this - trying to integrate a mapbox directions overlay on my map without having to display a separate native iOS direction screen. If it were possible to display polylines from geoJSON sources this would instantly expand to many use cases
Is there any way to draw a route from two reported points? If it is not possible yet, do you know any way I can implement this? Thank you.