简体   繁体   English

在 MKMapView 上绘制网格

[英]Draw a grid onto an MKMapView

I'd like to draw a grid into my map, that represents the size of a tile at a certain zoom level.我想在我的地图中绘制一个网格,它代表某个缩放级别下图块的大小。 So for example I'd like to have a grid on my mapview that shows the outline of a zoom level 10 tile.例如,我想在我的地图视图上有一个网格,显示缩放级别 10 磁贴的轮廓。 So the outline of where this tile would be.所以这个瓷砖的轮廓。 No matter if the mapview itself is at zoom level 5 or 15, it should display the outline of where that tile would be placed.无论地图视图本身是缩放级别 5 还是 15,它都应该显示该图块放置位置的轮廓。

The problem I have is how to calculate the proper rect that represents each visible "tile".我的问题是如何计算代表每个可见“瓷砖”的正确矩形。

Any help is sooo much appreciated!!!非常感谢任何帮助!!!

Or maybe the answer to following question would help:或者也许以下问题的答案会有所帮助:

How can I convert a MKMapRect to a MKTileOverlayPath?如何将 MKMapRect 转换为 MKTileOverlayPath?

I find that MapKit is way too limited when you want to start doing more and more with maps.我发现 MapKit 当你想开始做越来越多的地图时,它的局限性太大了。

I would reccomend using Google Maps SDK for iOS: https://developers.google.com/maps/documentation/ios/start我建议使用适用于 iOS 的 Google Maps SDK: https : //developers.google.com/maps/documentation/ios/start

and then using GMSTileLayer for the tiles: https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_tile_layer然后将 GMStileLayer 用于图块: https : //developers.google.com/maps/documentation/ios/reference/interface_g_m_s_tile_layer

In the long run, replacing MapKit with Google maps gives you far more features and options and has better geolocation and reverse geolocation than Apple从长远来看,用 Google 地图替换 MapKit 可为您提供更多功能和选项,并且比 Apple 具有更好的地理定位和反向地理定位

You can also look at Mapbox .你也可以看看Mapbox Between using TileMill to create a grid layer by setting the Map background to a pattern image, you could then only export zoom level 10 and either host it on Mapbox or export it to MBTiles format (SQLite-based).在使用TileMill通过将Map背景设置为图案图像来创建网格层之间,您只能导出缩放级别 10 并将其托管在 Mapbox 上或将其导出为 MBTiles 格式(基于 SQLite)。 Then one of the Mapbox mobile toolkits could serve the tiles out as an overlay on your map.然后,其中一个 Mapbox 移动工具包可以将图块作为地图上的叠加层提供。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM