Display route from "calculate route" API into a web map

Hi,
What is the correct way to display a route received from the /routing/1/calculateRoute
into a web map.
In sample i see that I can use

map.addLayer(...)

But sample use tt.services.calculateRoute to got the route and than transform it to geojson with

response.toGeoJson()

So… How can I convert a route from /routing/1/calculateRoute to geojson format to display in webmap?

Thank you

Are you querying this endpoint with fetch or Axios?

I’m using fetch for /routing/1/calculateRoute, why?

Is there a reason that you don’t want to use SDK for this?

I’m considering on calculate routes server side but I want to display the result on a web map client side, mixed with other additional app specific data

and the backend is not Node?

Yes is node. (…I have to put here some useless char to reach 20)

You could use Services part of the SDK in the node to obtain route and convert it to GeoJSON, that could be easily displayed on a map.

Ok, I’ll try to go with the services SDK even on server

1 Like