Waypoints coordinates

Hello, i’m making an map app and I want to show de instructions in every step (for example, it has to tell me “turn to left on street …” when i arrive there) but i don’t know how to get the coordinates of every waypoint/step. Is there any way I can get them? Thank you.

each step contains start and end indices to the route geometry path.
so just check the coordinate of those indices.

2 Likes

Hello,

thanks for this information.
I have another question about that.
How can we get coordinates with those indices.
Which is the relation between indices and coordinates ?

thanks in advance for your answer.

Hi @Raspinaute,

indices as in index of geometry array [Pos1, Pos2, Pos3,...]
where Pos1 would have Index 0.
to get the coordinates of indice you use basic array accessing.

e.g. for the /v2/directions/{profile}/geojson response:
the geometry array is in features.geometry
to get position x you access features.geometry[x] which is itself an array of [lon,lat]

depending on the programming language you are using the access might be a bit different.

Edit:
for the default endpoint /v2/directions/{profile} as well as for /v2/directions/{profile}/json the geometry is an encoded polyline and needs to be decoded before usage.

Best regards

Thanks of lot for all your informations.
I was able to get coordinates of specifc waypoint in the route, in python.

Best regards

1 Like