views:

846

answers:

2

I want to draw a tile-based overlay on top of a MKMapView, but there's no obvious way to do this.

This appears to be tricky since you can zoom to any level with MKMapView (unlike Google Maps).

Has anyone attempted to do this?

A: 

I'm working on a game where I need to overlay objects on the map and have them scroll and zoom with the map.

Using annotation views I've been able to solve the first problem and partially solve the second problem. Annotations automatically move with the map. For scaling them, I use the mapView:regionDidChangeAnimated: delegate method to resize my annotations after a zoom event. The problem is that the annotations don't rescale until after the zoom gesture is complete.

I can think of two approaches other than filing a bug with Apple requesting that they provide an API for map overlays:

  1. Put a (mostly invisible) view over the top of the MKMapView that intercepts zoom and scroll events, handles them, and passes them on to the map view.

  2. Customize the open-source RouteMe library with tiles from Open Street Map or CloudMade (the former is slow, the latter costs money). But it's fully open source so you should be able to do overlays to your heart's content. You could also run your own tile server that does the tile overlays on the server.

Frank Schmitt
I appreciate the answer! Unfortunately while these are creative hacks, they aren't real solutions. Thanks for your help though...
Adam Ernst
If you're dealing with a limited amount of geography, route-me supports a local tile store. You could use MapNik to generate tiles with OpenStreetMap data (plus your own shapes) and ship them with your app. That would be a "real solution" but perhaps more work than is justified by your project.
Frank Schmitt
A: 

Something I discovered later:

http://www.gisnotes.com/wordpress/2009/10/iphone-devnote-14-drawing-a-point-line-polygon-on-top-of-mkmapview/

Not quite a tile-based solution, but interesting nonetheless.

Adam Ernst