mapbox / mapbox-gl-directions

Directions plugin for mapbox-gl-js using Mapbox Directions API.
https://mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/
ISC License
235 stars 124 forks source link

Get more annotations #306

Open G-ilian opened 9 months ago

G-ilian commented 9 months ago

Hey guys,

I've been taking a look at the Directions API docs and some annotation params caught my attention, but I'm not able to return some of them using the mapbox-gl-directions plugin in a React application. So I came here and spend some time to study the plugin docs, I use this reference: https://github.com/mapbox/mapbox-gl-directions/blob/master/API.md#mapboxdirections .

From what I understand the only params that can be returned using the mapbox-gl-directions plugin is the congestion, is that right? Do I have any other params that I can get, how do I do that?

The way I'm doing it is this:

    ` const directions = new MapboxDirections({
      accessToken: process.env.REACT_APP_TOKEN_MAP_BOX,
      unit: 'metric',
      profile: 'mapbox/driving',
      geometries: 'linestring',
      controls: {
        inputs: false,
        instructions: false,
        profileSwitcher: false
      },
      congestion: true,
      annotations: 'congestion,distance,duration,speed'
    })`

If you have any tips for me to get the congestion, distance, duration and speed params from the route please tell me!