Group Group Group Group Group Group Group Group Group Forums

MapKit Tutorial: Overlay Views

Go beyond standard maps in MapKit with overlay views. Learn how to use polylines, polygons and overlay images to keep your users better informed!

This is a companion discussion topic for the original entry at

In my app , I need to paint a few streets of a city I did was go to googlemaps , took the few street coordinates and used the overlay , however the coordinates do not fit on the street , how can I overcome this problem ? Great tutorial :slight_smile:

How should I manage a large number of overlays I have (e.g. ~8000 across the country) noting there will be only a small number in a given view typically as the users typically zoom in a bit. Also noting I want to have direction arrows out from the current user location to the currently “visible” overlays (i.e. on the screen) at a given time? There are Overlays and NOT Annotations keep in mind. Specifically:

Q1 - Should I load up all the overlays into the app upfront? Or should I be manually managing myself which ones need to be displays at the given time and load them, remove them?

If I should load them all up up front then:

Q2 - Does MKMapView actually intelligently render them when visible only? It doesn’t seem like this???

Q3 - How do I get a list of currently “visible” overlays from my MapView to create the direction pointers from the current user location? I can’t see any function in Mapview to allow this? So does this imply I would need to manually check through all overlays (i.e. whole 8000) continually to see which ones are visible manually?


after run in

Downcast from ‘UITableViewCell?’ to ‘UITableViewCell’ only unwraps optionals; did you mean to use ‘!’?

any tips how to solve?

change the error line to this:

let cell = tableView.dequeueReusableCellWithIdentifier(“OptionCell”) as UITableViewCell!

let me know if it does not work!

Hi, this is really good, and this is exactly what i need.
but i can’t get it to work in xcode 8 and swift 3.
i’m new to this programming, so if you could translate it to swift 3, i
would be really happy.
thanks henrik

Here is a version for swift 3