隐藏 MKMapView 而叠加可见
我正在编写一个 iPhone 应用程序,其中我将自定义图像作为地图叠加在 MKMapView
之上。该图像是 MKOverlayView
,我想知道是否有办法隐藏或覆盖底层 Google 地图,以便用户在滚动到自定义地图的边界时永远不会看到它。任何建议将不胜感激。
I'm am writing an iPhone app in which I overlay a custom image as a map on top of an MKMapView
. The image is an MKOverlayView
, and I would like to know if there is a way to hide or cover the underlying Google map up so the user never sees it when scrolling out bounds of my custom map. Any suggestions would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 iOS 6 上,以下代码根据 show 标志将地图图块的 Alpha 通道设置为 0(或 1)。
请注意,此方法假定这些图块以某种方式排序。如果 Apple 决定在 iOS 更新中更改 MKMapView 的内部工作原理,则此方法可能会中断。
学分在这里: http:// /iphonedevsdk.com/forum/iphone-sdk-development/84694-how-to-use-mapkit-without-maps.html
On iOS 6, the following sets the alpha channel of the map tiles to 0 (or 1) depending on the show flag.
Note that this method assumes a certain way in which these tiles are ordered. If Apple decides to change the inner workings of MKMapView in an iOS update, this method may break.
Credits go here: http://iphonedevsdk.com/forum/iphone-sdk-development/84694-how-to-use-mapkit-without-maps.html
MKTileOverlay
有一个canReplaceMapContent
属性。将其设置为 YES 告诉 MKMapView 不要在叠加层下方绘制自己的图块。https://developer.apple.com/library /ios/documentation/MapKit/Reference/MKTileOverlay_class/Reference/Reference.html
MKTileOverlay
has acanReplaceMapContent
property. Set this to YES to tell theMKMapView
not to draw its own tile underneath your overlay.https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKTileOverlay_class/Reference/Reference.html
我建议您可以借助 MKOverlay 在谷歌地图上方绘制一个非常大的多边形,并尝试将您的自定义地图覆盖在其上方,以便谷歌地图将被非常大的多边形隐藏,并且您的自定义地图和注释将被隐藏。出席。
这可能不是一个好主意。但这是一个可以锻炼的技巧。
I will sugest you can draw a very big polygon with the the help of MKOverlay above the google map and try to overlay your custom map above it so that the google map will be hidden by the the very big polygon and your custom maps and annotations will be present.
It may not be a good idea. But its a trick that can workout.