Search code examples
google-maps-sdk-ios

Use google maps objects in background thread IOS


I have to parse a very large geoJSON file into an array of objects which contain GMS objects to display on a map. I don't need to display them right away, so I was trying to use Grand Dispatch to kick of a thread to go get the geoJSON and do the parsing. However google seems not to want me to be able to even create GMS objects outside the main UI thread even if I'm not associating them with a map yet.

Any workarounds or alternative suggestions?


Solution

  • The issue turned out to be parsing the geoJSON and downloading an icon image for each marker immediately. Changing the code to store just the icon URL and then kick off a separate thread at the end to go retrieve images works fine.

    At the point where I display the markers on the map I can check to see if the icon image was downloaded and use it instead of the default.