Search code examples
iosobjective-cmapkitdirectionmkoverlay

iOS mapKit refresh direction when the user's current location is updated


I am developing an application that allows the user to show the itinerary from the current location to the destination. The itinerary must be refreshed when the user's current location changes. I am using the LocationManager to detect the current location. When the current location changes, i re-fetch the directions and display a new itinerary that starts from the new current location. Is there a better and cleaner solution to achieve this ? Thanks.


Solution

  • What you are doing is correct way. Use following method of CLLocationManagerDelegate

    -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
    {
    
    }
    

    to get location update and chage the display accordingly.