Map Snapshot
The iOS Map SDK supports capturing a screenshot of a specified rectangular area (CGRect) on the screen. The captured content includes the map, map overlays, and callout bubbles.
Note: The screenshot feature depends on the map being displayed. Only content that is currently visible on the map can be captured.
Capture a Screenshot
Use the takeSnapshotInRect method in MAMapView to capture a screenshot. This method returns a UIImage object.
__block UIImage *screenshotImage = nil;
__block NSInteger resState = 0;
[self.mapView takeSnapshotInRect:inRect withCompletionBlock:^(UIImage *resultImage, NSInteger state) {
screenshotImage = resultImage;
resState = state; // state indicates whether the map is fully loaded: 0 = incomplete, 1 = complete
}];Completion Block Parameters
Important
When the state parameter is 0, the screenshot may be incomplete, as shown in the following example:
