2

In Mapbox Android SDK, we can able to set/customize the StepMilestone ie we can able to get callbacks before reaching Maneuver of the current step.

Is there any equivalent options available in iOS Mapbox sdk for listening the StepMilestone progress?

Sridhar
  • 2,228
  • 10
  • 48
  • 79
  • Using a Step Milestone will result in MilestoneEventListener.onMilestoneEvent(RouteProgress, String, Milestone) being invoked every step if the condition validation returns true. https://docs.mapbox.com/android/api/navigation-sdk/navigation/0.24.0/com/mapbox/services/android/navigation/v5/milestone/StepMilestone.html – Sridhar Jun 04 '19 at 05:36

1 Answers1

2

Currently on iOS there isn't a direct equivalent, so this is not nearly as straightforward as it is on Android. (disclaimer: I currently work for Mapbox)

The best way to do this on iOS would be to use turf-swift's LineString.distance(from:to:)​ (which is bundled in the Navigation SDK) to find the closest coordinate on the route based on a given POI.

Then you can respond to NotificationName.routeControllerProgressDidChange by comparing that distance to RouteProgress.distanceTraveled. If the user has crossed you specified threshold, create a SpokenInstruction and tell the NavigationViewController’s voiceController to speak(_:) it. You can see a somewhat similar example of this last piece in this example: https://docs.mapbox.com/ios/navigation/examples/custom-voice-controller/

I hope that helps.

Brandi H
  • 91
  • 3
  • Could you give ur thoughts for fixing this issue **MapboxNavigationNative was compiled with optimization - stepping may behave oddly; variables may not be available.** – Sridhar Jun 07 '19 at 11:23
  • Would you mind posting that as a new question with some more details? – Brandi H Jun 12 '19 at 21:03