隐藏 MKMapView 而叠加可见

发布于 2024-10-01 16:06:41 字数 164 浏览 1 评论 0原文

我正在编写一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

懷念過去 2024-10-08 16:06:41

在 iOS 6 上,以下代码根据 show 标志将地图图块的 Alpha 通道设置为 0(或 1)。

请注意,此方法假定这些图块以某种方式排序。如果 Apple 决定在 iOS 更新中更改 MKMapView 的内部工作原理,则此方法可能会中断。

if ( [mapView.subviews count] &&
     [((UIView *)[mapView.subviews objectAtIndex:0]).subviews count] ) {
    ((UIView *)[((UIView *)[mapView.subviews objectAtIndex:0]).subviews objectAtIndex:0]).alpha = show ? 1.0 : 0.0;
}

学分在这里: 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.

if ( [mapView.subviews count] &&
     [((UIView *)[mapView.subviews objectAtIndex:0]).subviews count] ) {
    ((UIView *)[((UIView *)[mapView.subviews objectAtIndex:0]).subviews objectAtIndex:0]).alpha = show ? 1.0 : 0.0;
}

Credits go here: http://iphonedevsdk.com/forum/iphone-sdk-development/84694-how-to-use-mapkit-without-maps.html

云淡风轻 2024-10-08 16:06:41

MKTileOverlay 有一个 canReplaceMapContent 属性。将其设置为 YES 告诉 MKMapView 不要在叠加层下方绘制自己的图块。

https://developer.apple.com/library /ios/documentation/MapKit/Reference/MKTileOverlay_class/Reference/Reference.html

MKTileOverlay has a canReplaceMapContent property. Set this to YES to tell the MKMapView not to draw its own tile underneath your overlay.

https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKTileOverlay_class/Reference/Reference.html

不如归去 2024-10-08 16:06:41

我建议您可以借助 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文