As of iOS 7, MapKit includes a MKTileOverlay
class that can be used to efficiently replace Apple Maps data with custom tiles. What’s more, MKTileOverlay
’s initializer accepts URL templates with x, y, and z parameters, which are implemented by many mapping services that use Mercator projection. This makes it trivial for third-party mapping software to leverage MapKit as a renderer for custom tile data.
That’s great, but custom tile overlays aren’t just useful for terrestrial imagery. Google Sky tiles can be accessed at URLs of format:
Sure enough, we can use MapKit to render Google Sky imagery in just 12 lines of code:
Under the hood, MapKit will now load Google Sky tiles on demand as the user pans and zooms.
The complete project can be found on GitHub.
Disclaimer: This project was created for experimental purposes. Google Sky data should not be used in shipping code.