Add vector tiled layer from custom style

View inWPFWinUIMAUIView on GitHubSample viewer app

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. Update the Basemap and Viewpoint when a new style is selected.
  4. 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.
  5. Update the basemap upon a style selection change.

Relevant API

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

Tags

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

Sample Code

AddVectorTiledLayerFromCustomStyle.xamlAddVectorTiledLayerFromCustomStyle.xamlAddVectorTiledLayerFromCustomStyle.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
21
22
23
24
25
<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="StyleChooserSelectionChanged">
                    <ComboBoxItem Content="Default" />
                    <ComboBoxItem Content="Style 1" />
                    <ComboBoxItem Content="Style 2" />
                    <ComboBoxItem Content="Style 3" />
                    <ComboBoxItem Content="Offline custom style - Light" />
                    <ComboBoxItem Content="Offline custom style - Dark" />
                </ComboBox>
            </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.