View in MAUI WPF WinUI View on GitHub

Load ArcGIS vector tiled layers using custom styles.

Image of offline vector tiled layer custom style

Use case

Vector tile basemaps can be created in ArcGIS Pro and published as offline packages or online services. You can create a custom style tailored to your needs and easily apply them to your map. The layer’s colors, patterns, icons, and labels could be modified, for example.

How to use the sample

Pan and zoom to explore the vector tile basemap.

How it works

  1. Create a PortalItem for each vector tiled layer.
  2. Create a Map and set the default Viewpoint.
  3. Export the light and dark offline custom styles.
    i. Create a ExportVectorTilesTask using the portal item.
    ii. Get the path for where the cache is being stored locally.
    iii. Return with the cache if the path already exists.
    iv. Else, create a ExportVectorTilesJob by having the task call ExportStyleResourceCache with the path as a parameter.
    v. Start the job.
    vi. When the job completes, store the result as a ExportVectorTilesResult.
    vii. Return the result’s item resource cache.
  4. Update the Basemap and Viewpoint when a new style is selected.

Relevant API

  • ExportVectorTilesJob
  • ExportVectorTilesResult
  • ExportVectorTilesTask
  • VectorTileCache
  • VectorTiledLayer
  • VectorTilesTask

Tags

tiles, vector, vector basemap, vector tiled layer, vector tiles

Sample Code

AddVectorTiledLayerFromCustomStyle.xaml AddVectorTiledLayerFromCustomStyle.xaml AddVectorTiledLayerFromCustomStyle.xaml.cs
<UserControl x:Class="ArcGIS.WPF.Samples.AddVectorTiledLayerFromCustomStyle.AddVectorTiledLayerFromCustomStyle"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<Grid>
<esri:MapView x:Name="MyMapView" />
<Border MaxWidth="230" Style="{StaticResource BorderStyle}">
<StackPanel>
<TextBlock Margin="0,0,0,5"
HorizontalAlignment="Center"
FontWeight="SemiBold"
Text="Select style:"
TextWrapping="Wrap" />
<ComboBox x:Name="StyleChooser" SelectionChanged="StyleChooser_SelectionChanged" />
</StackPanel>
</Border>
</Grid>
</UserControl>