New to Telerik UI for WPF? Download free 30-day trial

Export Support

The RadMap control has a built-in export to image support.

Export RadMap to Image

To save the map control as an image you can use its ExportToImage() method. The method has two overloads. One that allows you to export directly to the file system by only passing a file path аnd another one for exporting the image to a stream.

Example 1: Save the image using a string path

radMap.ExportToImage("../../map-image.png"); 

Example 2: Save the image using a stream

using (var stream = File.Create("../../map-image.png")) 
{ 
    radMap.ExportToImage(stream); 
}    

Only the current viewport of the map will be exported. Also, the navigation controls won't be included in the saved image.

By default the objects defined in the map layers (VisualizatioLayer or InformationLayer) like map objects and FrameworkElements won't be exported. In order to export them you will need to set the first optional parameter (includeMapObjects) of the ExportToImage() method to True.

Example 3: Save map objects

radMap.ExportToImage("../../map-image.png", includeMapObjects: true); 
The last optional parameter (encoder) of the method allows you to specify a BitmapEncoder.

Example 4: Set an encoder

radMap.ExportToImage("../../map-image.png", encoder: new PngBitmapEncoder()); 
By default the export uses PngBitmapEncoder.

The exporting will work only if the map is properly measured and arranged - otherwise, an exception will be thrown.

See Also

In this article