waypoint in the coordinate system


I’m new to map routing and have a basic question.
is it possible to find out the longitude and latitude of a waypoint?

so that I can display the instruction to the user in relation to his current position.

greeting john

Hi John,

Yes, that is fairly easy using splice. I am assuming you use javascript and Openlayers (that’s what I use). I use the following (pseudo-) code to highlight a route segment on the map (when the end user hovers over a description, the rout segment highlights).

zoomTo(steps[i].way_points[0] , steps[i].way_points[1])

and the function zoomTo gets the segment from the route (feature is the feature object received from the API):

var allcoords = feature.getGeometry().getCoordinates();
var slicecoords = allcoords.slice(start, end);
return new ol.Feature({geometry: new ol.geom.LineString(slicecoords)});

there’s a bit more checks and stuff in there, but this is the basics. If you only want the point, you can either get the start or the end of the segment.

1 Like

Thank you for your answer. i will try that. I’m writing an app for KaiOs(dumbphone OS) which limits certain user interactions on elements :wink: