使用自定义图像作为地图(如 Google 地图)
我想使用自定义图像作为地图,其中每个像素都被视为坐标,就像 MKMapView 将 Google Maps 地图与 MKAnnotationView 一起使用一样。我正在搜索与 Apple 的示例代码 MapCallouts 类似的行为。即,我想将图钉固定到自定义图像上而不是 Google 地图上的某个像素坐标。
有谁对我应该如何做有一些很好的建议,或者我可以在哪里找到有关上述行为的一些提示?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你看过 WWDC 视频吗?他们有一个使用自定义图像作为地图图块的示例。您可以在此处下载源代码:http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?code=y&source=x&bundleID=20645(查找 TileMap代码)。
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).
在
WWDC 2010 示例代码
中,有一个名为Tiled Image
的示例项目,它使用CATiledLayer
。请点击以下链接:
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
希望这有帮助。
In the
WWDC 2010 sample code
, there is a Sample Project calledTiled Image
, that useCATiledLayer
.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.
您所绘制的内容实际上与地图或 MKMapView 有关吗?如果没有,请查看 Core Graphics,您可以在其中逐像素绘制图像,然后将该图像分流到屏幕上。
如果它与地图相关,那么 TileMap 示例仍然可以提供帮助。扔掉所有关于图块的东西,看看 TileOverlayView.m(我想,已经有一段时间了)。那里有一个函数,MKMapView 正在调用其所有 MKOverlays 来填充地图矩形,以便可以将其显示在屏幕上。 TileMap 通过在磁盘上查找文件并将其绘制到框架中来实现此目的,但您也可以通过绘制自己的像素来实现。
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.