Google 地图上的自定义叠加层?
一个普遍的问题是,是否可以使用 iPhone Map Kit 在 Google 地图上方添加自定义叠加层(或多个叠加层)?感谢您的任何评论。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您对渲染图像或图像图块覆盖层而不是矢量形状感兴趣,请对 MKOverlayView 进行子类化并定义 [-canDrawMapRect:zoomScale] 和 [drawMapRect:zoomScale:inContext:]可以为你做。
我有一个示例,使用 [-canDrawMapRect:zoomScale] 检查本地缓存并异步处理图块加载(如果未缓存图块),然后使用 [drawMapRect:zoomScale:inContext:] 处理渲染生成的 UIImage进入 CoreGraphics 上下文。
http://github.com/mtigas/iOS-MapLayerDemo
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
当你指的是绘制诸如多边形、折线之类的形状时,你可以使用 MKOverlay(从 iOS 4 开始就非常好用)。
需要两个步骤:
- 使用“addOverlay”添加一个(或多个)叠加层
2 使用 (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id )overlay 明确 Overlay 的呈现方式。
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.
我很幸运地使用 MKOverlay 添加多层图像叠加。我们当前的应用程序具有 13 个大图像叠加功能,并且性能仍然不错。
要获得一些好的示例代码,请查看 WWDC 2010 中的 Apple TileMap 示例。
I've had good luck adding multiple layers of image overlays using MKOverlay. Our current app features 13 large image overlays, and performance is still good.
For some good sample code, check out Apple's TileMap sample from WWDC 2010.