Take a screenshot of the map.
Use case
GIS users may want to export a screenshot of a map to enable sharing as an image or printing.
How to use the sample
Pan and zoom to find an interesting location, then use the button to take a screenshot. The screenshot will be displayed. Note that there may be a small delay if the map is still rendering when you push the button.
How it works
- Wait for the MapView to finish rendering the Map.
- Call
mapView.ExportImageAsync()
to get theRuntimeImage
, which is a bitmap image. - Use the
RuntimeImage.ToImageSourceAsync
extension method to get a copy of the image that is compatible with native image display controls.
Relevant API
- GeoView.DrawStatus
- GeoView.DrawStatusChanged
- GeoView.ExportImageAsync
- RuntimeImage
- RuntimeImage.ToImageSourceAsync
Tags
capture, export, image, print, screen capture, screenshot, share, shot
Sample Code
<UserControl
x:Class="ArcGISRuntime.UWP.Samples.TakeScreenshot.TakeScreenshot"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<Grid>
<esriUI:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<StackPanel>
<Button Content="Take screenshot"
HorizontalAlignment="Stretch"
Click="OnTakeScreenshotButtonClicked" />
<Image x:Name="ScreenshotView"
HorizontalAlignment="Stretch"
Margin="0,5,0,0"
Visibility="Collapsed" />
</StackPanel>
</Border>
</Grid>
</UserControl>