Search code examples
iosmapkitswift2mkpointannotation

100,000+ Annotations with MapKit


I'm writing a simple iOS App to map about 130,000 items.

I took the raw data file and massaged each line to look like:

array.append(class(latitude:46.222813, longitude:6.138866))

But when I try to copy 130,000 lines or even 25,000 at a time, Xcode just hangs.

Now, I'm happy to copy/paste 1000 at a time, but was wondering if I should be dealing with a sqlite database? Or just a .CSV text file in my project...

Thoughts? Suggestions? Admonitions? ;)


Solution

  • Put the data in a file or database. Then you have code that loads the file/data and iterates over each entry.

    Now your code is now about a dozen lines of code instead of 130,000 and the coordinates are not hardcoded in your app.