【问题标题】:Convert MKTileOverlayPath to MKMapRect?将 MKTileOverlayPath 转换为 MKMapRect?
【发布时间】:2014-06-13 15:37:44
【问题描述】:

我用的是方法:

- (void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *data, NSError *error))result

MKTileOverlayPath 给了我一个 x、y 和 z。我正在尝试沿此路径拍摄该区域的 Apple Maps 版本的快照,以便我可以对图像应用过滤器。

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

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;
    }
}];

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

【问题讨论】:

  • 知道如何反其道而行之吗? MapRect 到 OverlayPath?
  • 还有...您找到解决问题的方法了吗?

标签: ios objective-c mapkit mkmapsnapshotter mktileoverlay


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2012-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-17
    • 1970-01-01
    • 2014-01-17
    • 1970-01-01
    • 2014-07-20
    相关资源
    最近更新 更多