【问题标题】:Take Screenshot of ArcGIS Map View Programmatically for iOS以编程方式为 iOS 截取 ArcGIS Map View 的屏幕截图
【发布时间】:2017-07-31 05:15:51
【问题描述】:

我正在尝试以编程方式截取 ArcGIS 地图视图的屏幕截图。我还没有在 ArcGIS 库中看到任何可以简化此操作的代码。我真的在尝试创建地图视图的 UIImage,包括当前正在显示的任何要素图层。我尝试对 arcgisMapView 和包含 arcgisMapView 的超级视图使用 UIGraphicsBeginImageContext,但两次尝试都为 arcgisMapView 区域返回了一个空白视图。

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

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

请帮忙,谢谢。

【问题讨论】:

标签: ios objective-c dictionary arcgis arcgis-runtime


【解决方案1】:

使用exportImageWithCompletion:

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

还有样本来源。

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

猜测 ArcGIS 使用另一个自定义图层,而不仅仅是 self.view.layer

【讨论】:

  • 这似乎是方法,但我不能使用 self.mapView.exportImage ,因为它显示在 GitHub 上。这可能只适用于 Swift 吗?因为我的项目是在 Objective-C 中。
  • 如果它是用 Swift 编写的,你可以在 Obj-C 中使用它。喜欢 [mapView exportImageWithCompletion:]。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-19
  • 1970-01-01
  • 2016-03-18
  • 2011-01-13
  • 1970-01-01
  • 2013-07-31
  • 2014-04-17
相关资源
最近更新 更多