Determine when MKRoutestep ends

I am trying to implement a turn-by-turn navigation system in iOS using the MKDirections API. I can get the direction of the route and draw a polyline on the map, and when navigation starts, the application starts showing instructions using the MKRouteStep object in the Steps array. Now the problem is , since the distance in the MKRouteStep object is the distance that the user travels while walking the path to the step, I cannot figure out how to calculate this distance. Is there a way to calculate this distance ? I am currently calculating the distancebetween two coordinates, i.e. coordinate when the last instruction was shown with the user's current location, and if that distance is equal to the distance specified in MKRouteStep, I show the next instruction to which it delays the transmission of the instruction to the user.

If there is any way to identify the coordinate or region where this MKRouteStep ends, I can calculate if the user is in that region or not and then show the next instruction. Maybe this could work, what are your thoughts, but for this, how do I know the coordinate or area where this MKRouteStep ends from the MKRouteStep polylines array?

Please suggest if there is another good solution for this. Any help is appreciated.

Thank.

+3


source to share


1 answer


Since no one has answered my question, I am answering it myself so that it helps someone else look for the same.

So instead of using the MKRouteStep distance value to calculate when to show the next command, we can use the last coordinate of the polyline array provided by MKRouteStep. For example:



MKMapPoint mapPointForEndOfRouteStep = routeStep.polyline [routeStep.polyline.pointCount - 1];

Now you can create a region around it and check if your current location is in that region or not.

+5


source







All Articles