Take screenshot

View inMAUIUWPWPFWinUIView on GitHub

Take a screenshot of the map.

Image of take screenshot

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

  1. Wait for the MapView to finish rendering the Map.
  2. Call mapView.ExportImageAsync() to get the RuntimeImage, which is a bitmap image.
  3. 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

TakeScreenshot.xamlTakeScreenshot.xamlTakeScreenshot.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<UserControl
    x:Class="ArcGIS.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>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.