0

I'm working on an iOS App which draws the path on a map using Polyline options, between source to destination.

This works fine.

What I need is, if the user starts from source, and instead of taking drawn route towards the destination, the user takes another route, the path on the map should be redrawn for user's current path.

I'm using Directions API for drawing the path.

How can I do that?

Thanks in advance.

Chetan Lodhi
  • 353
  • 1
  • 3
  • 21

1 Answers1

1

Yes, you can do that by detecting the change in location. Use didUpdateLocations method of CLLocationManagerDelegate Protocol to detect the change of location. If user location is changed significant then check that if user is still on route or not by using GMSGeometryContainsLocation function.

Shahbaz Saleem
  • 317
  • 2
  • 14
  • Thanks, @Chaudhary Shahbaz Saleem. I did the same what u suggest. Firstly I check if the path is outside of polyline than I redraw the path from current location to Destination and tremendously this is working awesome. – Chetan Lodhi Dec 03 '18 at 10:52
  • @ChetanLodhi can you add that code how you do that. – balkaran singh Sep 07 '22 at 04:16