Download tiles to a local tile cache file stored on the device.
Use case
Field workers with limited network connectivity can use exported tiles as a basemap for use offline.
How to use the sample
Pan and zoom into the desired area, making sure the area is within the red boundary. Click the 'Export tiles' button to start the process. On successful completion you will see a preview of the downloaded tile package.
How it works
- Create a map and set its
MinScale
to 10,000,000. Limiting the scale in this sample limits the potential size of the selection area, thereby keeping the exported tile package to a reasonable size. - Create an
ExportTileCacheTask
, passing in the URI of the tiled layer. - Create default
ExportTileCacheParameters
for the task, specifying extent, minimum scale and maximum scale. - Use the parameters and a path to create an
ExportTileCacheJob
from the task. - Start the job, and when it completes successfully, get the resulting
TileCache
. - Use the tile cache to create an
ArcGISTiledLayer
, and display it in the map.
Relevant API
- ArcGISTiledLayer
- ExportTileCacheJob
- ExportTileCacheParameters
- ExportTileCacheTask
- TileCache
Additional information
ArcGIS tiled layers do not support reprojection, query, select, identify, or editing. See the Layer types discussion in the developers guide to learn more about the characteristics of ArcGIS tiled layers.
Tags
cache, download, export, local, offline, package, tiles
Sample Code
<UserControl x:Class="ArcGIS.UWP.Samples.ExportTiles.ExportTiles"
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 x:Name="MyExportButton"
Content="Export tiles"
HorizontalAlignment="Stretch"
IsEnabled="False"
Click="MyExportButton_Click" />
<ProgressBar x:Name="MyProgressBar"
Visibility="Collapsed"
MinHeight="10"
IsIndeterminate="True" />
<esriUI:MapView x:Name="MyPreviewMapView"
Width="375" Height="400"
Visibility="Collapsed" />
<Button x:Name="MyClosePreviewButton"
Content="Close preview"
Margin="0,5,0,0"
Visibility="Collapsed"
HorizontalAlignment="Stretch"
Click="ClosePreview_Click" />
</StackPanel>
</Border>
</Grid>
</UserControl>