Need help with iOS-MapLayerDemo?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

201 Stars 26 Forks BSD 2-Clause "Simplified" License 31 Commits 1 Opened issues


Demo of using MKOverlayView in iOS 4.0+ to render custom tile server overlays. (Last updated in 2012, you probably want to look elsewhere for modern code examples.)

Services available


Need anything else?

Contributors list

# 31,544
27 commits

iOS Custom Map Layer Example

A barebones demo app that demonstrates the use of some new MapKit functionality in iOS 4.0.:

The MKOverlay protocol and MKOverlayView class and how to use these to render custom tile layers a la Google Maps API. (i.e. Google Maps-compatible tile layers from Mapnik/Tilecache, gheat, etc.) Examples include tilesets from OpenStreetMap and MapBox.

(Caveat: the OpenStreetMap renders opaquely over the default Google layer, it does not replace it.)

Comments and feedback are welcome.



I refactored django-gheat as a side project and I’ve been working on iOS development a bit lately and was seeking a slick way to plug the django-gheat demo tileserver into the iPhone. The Google Maps API just doesn’t have enough performance in the browser to make for a decent user experience.

Some conversation threads recommended combining a UIScrollView with CATiledLayer, but this seemed unwieldy to couple with the existing MapKit framework.

Lo and behold, iOS 4.0 added custom overlay functionality to MapKit, though I have not seen any mention or example of it’s use to date.


The code is generally commented thoroughly. I am not an expert in cartography, so my knowledge of map projections and some of the calculations within the code are to be taken with a grain of salt.

compensates for
[[UIScreen mainScreen] scale]
, or the iPhone 4’s pixel doubling. The view applies the screen scale factor, creating a situation as if the screen were twice as large. Because MapKit loads pixel-doubled tiles but maintains the same viewport,
renders tiles of the next (or scale-appropriate) zoom level to maintain a one-to-one mapping with MapKit’s own tiles.


[MKOverlayView -canDrawMapRect…]
[MKOverlayView -drawMapRect…]
methods rely on asynchronously downloading tiles as requested (by
) into cache, and then using that cache in the
method after the success callback notifies MapKit to try the tile again.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.