View Full Version : Rerouting while navigating a Route with ViaPoints

31.10.2015, 01:11
I'm working on an app that will support Routes with ViaPoints. (iOS9 / Xcode 7.1 / SKMaps 2.5.0)

What I would like to achieve is that when a user deviates from the route between e.g. viaPoint5 and viaPoint6 than the recalculated route guides the user to viaPoint6.

So, what happens if a user deviates from the route while in the middle of a route, for example between viaPoint 5 and viaPoint 6. Let's say the current deviated location of user is X (which is not on the route). How will the user be guided? From X to the original route start point or from X to the next viaPoint (viaPoint6 in my example)? In my situation ideally the user would be guided from X to the first viaPoint he didn't reach (viaPoint6).

I'm guessing this could be achieved by utilising didReachViaPointArea (callback of the SKNavigationDelegate) and removeViaPoint (method of the SKRoutingService) and delete the previous viaPoint from the route after reaching a new viaPoint. (Thus making sure that the route does not contain any previous viaPoints and will be calculated to the first available via point). However the removeViaPoint method will also start a recalculation if I understand correctly, which would mean recalculation even if the user did not deviate. And, what to do if the user deviates from the route between the startpoint and the 1st viaPoint? As far as i can tell it's not possible to delete/replace the route start point during navigation.

I understand from the documentation that rerouting "...happens when the device doesn't follow the calculated route. When this is done, a new route is automatically calculated and will send success/failure callbacks via the SKRoutingDelegate...."
and routingServiceDidStartRerouting is called.

This doesn't really answer the questions/concerns I have, so was hoping you could provide a bit more insight in this and perhaps provide a way (or workaround) to achieve what I've intended.

Thanks for the info and best regards,

02.11.2015, 20:55
The route calculated during rerouting will have as arguments:
- your current location
- the destination
- any viaPoint that has not yet been reached (i.e. assuming that viaPoint5 in your example has been reached, then viaPoint6)

The callback to search for is onViaPointReached (http://developer.skobbler.com/docs/android/2.5.1/com/skobbler/ngx/navigation/SKNavigationListener.html#onViaPointReached(int)) - once this callback is triggered then that specific via point will be removed for "the list of viaPoints that have not been reached")

So I guess the current behaviour is exactly the behaviour you are looking for - if not then I'm looking forward to your follow up questions.