How to draw a line on MKMapView showing the route the user has taken?

I looked on the Internet to try and find the best way to draw a line showing the route the user was traveling. I think I need to use MKOverlayView, and I think I need to collect a selection of data points for the graph (will these be GPS coordinates?). The question I have is based on how I will draw a line and continue to add it as user location updates?

I also want to clear the line when the user clicks a button. How would I implement this (don’t click a button, just a code to clear the line from the map view)?

Thanks in advance!

+5
source share
1 answer

You can do this using MKPolyline. First you need to get the coordinates of the route, and then draw polylines above it. You will find it here to draw a polyline over some coordinates.

+1
source

All Articles