Use custom image as map (like Google Maps)
I want to use a custom image as a map where each pixel is considered the 开发者_运维问答coordinates, much as MKMapView uses a Google Maps map together with MKAnnotationView. I'm searching a similar behavior as the sample code from Apple, MapCallouts. I.e. I want to put a pin to a certain pixel coordinate on a custom image rather than on a Google Map.
Does anyone have some great tips of how I should do or where I could find some hints on above behavior?
Have you checked the WWDC videos? They have an example where they use custom images for map tiles. You can download the source code here: http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?code=y&source=x&bundleID=20645 (look for the TileMap code).
In the WWDC 2010 sample code
, there is a Sample Project called Tiled Image
, that use CATiledLayer
.
Follow these links:
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CATiledLayer_class/Introduction/Introduction.html
https://github.com/mtigas/iOS-MapLayerDemo
https://github.com/route-me/route-me
hope this helps.
Is what you're drawing actually related to a map or MKMapView? If not then look into Core Graphics where you can draw pixel by pixel into an image and then shunt that image on to screen. If it is map related then the TileMap example could still help. Throw away all the stuff about tiles and look at TileOverlayView.m (I think, it's been a while). There's a function there that MKMapView is calling on all its MKOverlays to fill in a map rect so it can show it on screen. TileMap does this by finding a file on disk and drawing it into the frame, but you could do it by drawing your own pixels instead.
精彩评论