Convert MKTileOverlayPath to MKMapRect?

755 Views Asked by At

I'm using the method:

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

The MKTileOverlayPath gives me an x, y and z. I'm trying to take this path and take a snapshot of what the Apple Maps version of this area is, so that I can apply a filter to the image.

I'm using MKMapSnapshotter as so, but don't know what values to give it to draw me the apple maps representation of this area.

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

Or perhaps there's another known way of taking the map image from this area.

1

There are 1 best solutions below

0
On

The conversion between x/y/z and coordinates is done here:

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

Use that to determine (indirectly) and MKMapRect to capture, setup your map view, then use MKMapSnapshotter to grab an image to process.