Putting an image into an MKOverlayView in the MapKit in Xcode
I want to make a mapkit overlay with a png, but i have no code for it and I cant find any tutorials on it. I am a novice coder, so lots of help would be greatly appreciated!
Tha开发者_如何转开发nksThere are a few things you need to do to get this going:
- Create a custom
MKOverlayViewsubclass that actually draws your image. - Add an overlay (an object that implements the
MKOverlayprotocol) to yourMKMapView. Apple provides a number of overlay classes—MKCircle,MKPolygon, etc.—one is likely to be suitable. - Implement the
mapView:viewForOverlay:method in yourMKMapView's delegate to return an instance of your custom overlay view.
The section Displaying Overlays on a Map in Apple's Location Awareness Programming Guide should help clarify all of these steps. As for drawing the image, have a look at CGContextDrawImage().
加载中,请稍侯......
精彩评论