views:

774

answers:

2

Hi Guys, a general question, is it possible to have a custom overlay (or more than one overlays) above the Google Map using iPhone Map Kit? Thanks for any comments.

A: 

when you mean a drawing of Shapes like Polygon an Polyline and things like that you can use MKOverlay (realy good since iOS 4). there are two steps needed: - use "addOverlay" to add one (or more) Overlay(s) 2 use (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id )overlay to make clear wich way the Overlay is presented.

Thanks, that is helpful.
Lin
+1  A: 

If you’re interested in rendering images or image tile overlays rather than vector shapes, subclassing MKOverlayView and defining [-canDrawMapRect:zoomScale] and [drawMapRect:zoomScale:inContext:] can do it for you.

I’ve got an example that uses [-canDrawMapRect:zoomScale] to check the local cache and asynchronously handle tile loads (if a tile isn't cached), and then [drawMapRect:zoomScale:inContext:] to handle rendering the resulting UIImage into the CoreGraphics context.

http://github.com/mtigas/iOS-MapLayerDemo

Mike Tigas