-1

response snapshot

I am getting the geometry of directions but the format is unknown the above images shows the response which i am getting, I want response in these format

                        "coordinates": [
                              [
                                    -73.917114,
                                    40.770058
                              ]
                                                      
                         ],
                        "type": "LineString"
                  } ```
my code for map & direction initialization : 
        ``` var map = new mapboxgl.Map({
      container: "map", // Specify the container ID
      style: "mapbox://styles/mapbox/light-v10", // Specify which map style to use
      center: [-84.5, 38.05], // Specify the starting position [lng, lat]
      zoom: 11 ,// Specify the starting zoom
      geometries: "geojson"
    });
    
    var directions = new MapboxDirections({
      accessToken: mapboxgl.accessToken,
      unit: "metric",
      profile: "mapbox/driving",
      alternatives: false,
      geometries: "geojson",
      controls: { instructions: false },
      flyTo: false
    });```

1 Answers1

-1

Though it's never explicitly stated in the documentation the geometry is encoded. It can be decoded using this library

Anatolii Suhanov
  • 2,524
  • 1
  • 12
  • 14