0

I am trying to take a screenshot of an ArcGIS map view programmatically. I haven't seen any code in the ArcGIS library to make this easy. I'm really trying to create a UIImage of the map view including any feature layers that are currently being displayed. I tried using UIGraphicsBeginImageContext for the arcgisMapView and on the superview containing the arcgisMapView, but both attempts return a blank view for the arcgisMapView area.

UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *mapImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(mapImage, nil, nil, nil);

and

UIGraphicsBeginImageContext(arcgisMapView.bounds.size);
[arcgisMapView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *mapImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(mapImage, nil, nil, nil);

Please help and thanks.

user2621075
  • 357
  • 4
  • 15
  • Check below link https://googleweblight.com/i?u=https://developers.arcgis.com/ios/latest/objective-c/guide/display-a-map.htm&grqid=gRwOOETc&hl=en-IN – Rajesh Dharani Mar 10 '17 at 06:53

1 Answers1

0

Use exportImageWithCompletion:.

https://developers.arcgis.com/ios/latest/swift/sample-code/take-screenshot.htm

And sample source.

https://github.com/Esri/arcgis-runtime-samples-ios/tree/master/arcgis-ios-sdk-samples/Maps/Take%20screenshot

Guess ArcGIS uses another custom layer, not just self.view.layer.

Leo
  • 39
  • 5
  • This seems to be the method but I can't use self.mapView.exportImage as it is shown on GitHub. Is it possible this only works in Swift? As my project is in Objective-C. – user2621075 Mar 11 '17 at 16:40
  • If it's written in Swift, you can use it in Obj-C. Like [mapView exportImageWithCompletion:]. – Leo Mar 12 '17 at 06:43