I have two questions which are somehow related.
- I have created a route on an open street map and I want to extract a list of points that correspond to the way points of the generated route (not just the start and the finish). How can this be achieved? For example I want to extract way points for the generated red route from the image bellow (of course I do not want to extract all the points from a route but from 10 in 10 meters).
How do I erase the generated route with red, and have the original map (without the red route) I have tried many function on the map item but non of them worked. For example I have tried the code below but the red route remains.
function clearMapDataForSession() { mapview.clearData(); routeModel.update() }
You can get a list of coordinates from the
Route
by using the properties path or segments. Thepath
property directly gives you a list ofcoordinates
on the givenRoute
, thesegments
property on the other hand gives you a list of RouteSegments which in turn contain a list ofcoordinates
given by itspath
property.Print the list of
Route
coordinates viasegments
:Print the list of
Route
coordinates viapath
:If you compare the list of coordinates given by the two options, they are the same. The benefit of
RouteSegments
is that you get thedistance
of the segment as a property. So if you want to generate a list of coordinates/points on theRoute
at the same distance, this would help you in writing some sort of an algorithm.In order to erase a generated
Route
you need to callreset()
on theRouteModel
. If you want to also clear the waypoints of aRouteQuery
you should callclearWaypoints()
as well.