简体   繁体   中英

how to take snapshot in mapbox ios sdk of full map

/** @name Capturing Snapshots of the Map View */

/** Take a snapshot of the map view. By default, the overlay containing any visible annotations is also captured. @return An image depicting the map view. */

- (UIImage *)takeSnapshot;

/** Take a snapshot of the map view.

@param includeOverlay Whether to include the overlay containing any visible annotations.

@return An image depicting the map view. */

- (UIImage *)takeSnapshotAndIncludeOverlay:(BOOL)includeOverlay;

Actually You can use a method called takeSnapshot in a RMMapView it returns an UIImage so you can use it for whatever you want, here is an example blurring my snapshot

-(UIImage*) performScreenshotAndBlur
{
    UIImage *blurImage = self.mapView.takeSnapshot;
    blurImage = [blurImage applyBlurWithRadius:10 tintColor:[UIColor colorWithRed:0.067 green:0.067 blue:0.067 alpha:0.2] saturationDeltaFactor:1.8 maskImage:nil];
    return blurImage;
}

This depends on which zoom level you are at. If it is the furthest zoomed out possibly (somewhere from z0-2 , depending on device size), the world will be 256 , 512 , or 1024px on a side. If it's zoomed in much further, say to street level at z17 , you are talking about 2 ^ 17 * 256 or 33,554,432px on each side of the image. This is why maps are drawn tiled and why this functionality isn't built in by default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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