ios - 将 MKTileOverlayPath 转换为 MKMapRect?

标签 ios objective-c mapkit mkmapsnapshotter mktileoverlay

我正在使用以下方法:
- (void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *data, NSError *error))result
MKTileOverlayPath 给了我一个 x、y 和 z。我正在尝试沿此路径拍摄该区域的 Apple Maps 版本的快照,以便我可以对图像应用过滤器。

我正在使用 MKMapSnapshotter,但不知道给它什么值来绘制该区域的苹果 map 表示。

MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init];
options.scale = [[UIScreen mainScreen] scale];
options.showsBuildings = NO;
options.showsPointsOfInterest = NO;
options.mapType = MKMapTypeStandard;

MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];
[snapshotter startWithCompletionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
    if (error || !snapshot) {
        NSLog(@"snapshotter error: %@", error);
        return;
    }
}];

或者也许还有另一种从该区域获取 map 图像的已知方法。

最佳答案

x/y/z 之间的转换坐标在这里完成:

https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames

使用它来确定(间接)和MKMapRect捕获,设置您的 map View ,然后使用 MKMapSnapshotter抓取要处理的图像。

关于ios - 将 MKTileOverlayPath 转换为 MKMapRect?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24209133/

相关文章:

iphone - iOS 应用程序崩溃,没有任何错误

ios - 为什么表格中的第一节标题未显示?

ios - 如何在 Objective C 中的 Google map 上动态创建多个图钉

ios - 是否可以为 MKMapView 上的用户定位 Pin 设置固定的屏幕位置?

objective-c - MKPinAnnotationView 标注未显示

ios - 计算具有固定对角线距离的MKCooperativeRegion

iphone - NSString sizeWithFont 行距

iphone - 选择时更改按钮文本颜色

ios - NSNotificationCenter 多次调用

ios - 当应用程序重新启动到后台时,是否会调度主队列?