Click or drag to resize

ArcGISVectorTiledLayer Class

A class that allows you to display data from an AcrGIS Vector Tile data source.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.MappingLayer
    Esri.ArcGISRuntime.MappingArcGISVectorTiledLayer

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.9.0.0
Syntax
C#
public sealed class ArcGISVectorTiledLayer : Layer

The ArcGISVectorTiledLayer type exposes the following members.

Constructors
  NameDescription
Public methodArcGISVectorTiledLayer
Initializes a new instance of the ArcGISVectorTiledLayer class.
Public methodCode exampleArcGISVectorTiledLayer(Uri)
Initializes a new instance of the ArcGISVectorTiledLayer class from the specified URI.
Public methodArcGISVectorTiledLayer(Item)
Initializes a new instance of the ArcGISVectorTiledLayer class from the specified Item.
Public methodArcGISVectorTiledLayer(VectorTileCache)
Initializes a new instance of the ArcGISVectorTiledLayer class from the specified VectorTileCache.
Public methodArcGISVectorTiledLayer(VectorTileCache, ItemResourceCache)
Initializes a new instance of the ArcGISVectorTiledLayer class from the specified VectorTileCache and ItemResourceCache.
Top
Properties
  NameDescription
Public propertyAttribution
Gets the attribution text for the layer.
(Inherited from Layer.)
Public propertyCanChangeVisibility
Gets a value indicating whether the layer content's visibility can be changed.
(Inherited from Layer.)
Public propertyCredential
Gets or sets the Credential used to access a remote service.
Public propertyDescription
Gets the description for the layer.
(Inherited from Layer.)
Public propertyCode exampleFullExtent
Gets the full extent of the layer, which is the extent where all the data in the layer is contained.
(Inherited from Layer.)
Public propertyCode exampleId
Gets or sets an identifier for the layer
(Inherited from Layer.)
Public propertyIsIdentifyEnabled
Gets a value indicating whether the layer supports the identify operation.
(Inherited from Layer.)
Public propertyCode exampleIsVisible
Gets or sets a value indicating whether the layer content is visible.
(Inherited from Layer.)
Public propertyItem
Gets the ArcGIS Item
(Inherited from Layer.)
Public propertyItemResourceCache
Gets the ItemResourceCache or null if no item resource cache is present.
Public propertyLoadError
Gets the load error of the layer, if there is one.
(Inherited from Layer.)
Public propertyCode exampleLoadStatus
Gets the load status of the layer.
(Inherited from Layer.)
Public propertyCode exampleMaxScale
Gets or sets the maximum scale where the layer is visible.
(Inherited from Layer.)
Public propertyCode exampleMinScale
Gets or sets the minimum scale where the layer is visible.
(Inherited from Layer.)
Public propertyCode exampleName
Gets or sets the name of the layer content.
(Inherited from Layer.)
Public propertyCode exampleOpacity
Gets or sets the opacity of the layer.
(Inherited from Layer.)
Public propertyShowInLegend
Gets or sets a value indicating whether the layer content participates in the legend.
(Inherited from Layer.)
Public propertySource
Gets or sets the endpoint of the vector tiled map service or the path to a vector tile package.
Public propertySourceInfo
Gets the VectorTileSourceInfo metadata.
Public propertySpatialReference
Gets the spatial reference of the layer.
(Inherited from Layer.)
Public propertyStyle
Gets the VectorTileStyle.
Public propertyCode exampleSublayerContents
Gets the sub layer contents of a layer content.
(Inherited from Layer.)
Public propertyVectorTileCache
Gets the underlying VectorTileCache or null if no vector tile cache is present.
Top
Methods
  NameDescription
Public methodCancelLoad
Cancels an ongoing load.
(Inherited from Layer.)
Public methodCode exampleClone
Clones this instance of Layer and its members.
(Inherited from Layer.)
Public methodGetLegendInfosAsync
Returns an immutable list of LegendInfo.
(Inherited from Layer.)
Public methodIsVisibleAtScale
Returns the layer content's effective visibility at the specified scale.
(Inherited from Layer.)
Public methodCode exampleLoadAsync
Initiates loading of a layer
(Inherited from Layer.)
Public methodRetryLoadAsync
Retry loading the layer.
(Inherited from Layer.)
Top
Events
  NameDescription
Public eventCode exampleLoaded
Occurs when the layer is loaded.
(Inherited from Layer.)
Public eventLoadStatusChanged
Occurs when the layer LoadStatus is changed.
(Inherited from Layer.)
Public eventPropertyChanged
Occurs when a property value changes.
(Inherited from Layer.)
Top
Remarks

An ArcGIS vector tiled layer consumes vector tiles and an associated style for drawing them. This data source can be a service in ArcGIS Online or ArcGIS Enterprise portal or local vector tiles in a package (.vtpk file). You can use one of the many styled vector tiled basemaps on ArcGIS Online or create your own with the online style editor. Your customized vector tiled layers can be saved to and read from ArcGIS Online.

Use ExportVectorTilesTask to generate and download a vector tile cache (optionally including a custom style) directly to the device as a single-tile .vtpk file. You can use ArcGIS Pro to create a vector tile package and provision it to the device. Or, you can use ArcGIS Pro to create a mobile map package (.mmpk file) that contains a vector tile package and your custom style.

Because vector tiles are defined in terms of points, lines, and polygons, they take up less disk space and draw more quickly than bitmap-based data and they tend to be more suitable for low-bandwidth or offline environments. Vector tiles are rendered on the device, they always look crisp, regardless of screen size or resolution.

Vector tiled layers do not support identify, query, selection, or time, and they cannot be displayed in scenes.

Vector Tiled Layers are much like ArcGIS Tiled Layer. They are a layer in the map loaded from ArcGIS online, Portal for ArcGIS, ArcGIS for server, or a local vector tile layer package file. The tile data format is optimized to reduce network bandwidth and reduce CPU load while rendering the tiles. Vector Tiled Layers are appropriate for basemap, reference and possibly operational layers. They do not contain any feature data, and do not support identify or search operations.

Vector tiles are an alternative to raster tile basemap layers. Instead of pixels, the cartography is delivered using 2D points. The points describe lines, polygons or the locations of labels and marker symbols. The file format of tiles is binary and conforms to the Mapbox Vector Tile Specification. The vector tile file format requires much less space than raster tiles. Also, since the cartography is rendered at runtime, the differences between levels of detail appear more continuous than with raster tiles.

To create a vector tiled layer, the runtime client is given either a URI or a portal item. The URI can point to a vector tile source, a vector tile style sheet, or a local vector tile package file. The portal item will contain a URI to a vector tile stylesheet. The style sheet describes the appearance of the geometry and must be in the Mapbox GL Style format. The style sheet also contains a URI to a vector tile source. The source must be in the Mapbox TileJSON format. The source info includes a URI to a default style sheet.

More than one vector tile style sheet can use the same source. Both the source info and the style sheet are human readable JSON files.

Vector tile packages can also be downloaded from a ArcGIS Online vector tile service. The vector tile package is a single file (.vptk) that contains all of the tile data files, the source information, a style sheet, and the font and symbol marker resources required to display the map.

Vector tile packages are also distributed inside Mobile Map Packages. The MMPK contains JSON that points to the location of the vector tile style sheet or the root of the vector tile package data.

Sample Code:

Examples

Android

Example Name: ArcGISVectorTiledLayerUrl

Load an ArcGIS Vector Tiled Layer from a URL.

Code example screen shot.

C#
// Copyright 2018 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Android.App;
using Android.OS;
using Android.Views;
using Android.Widget;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;
using System;
using System.Collections.Generic;
using System.Linq;

namespace ArcGISRuntime.Samples.ArcGISVectorTiledLayerUrl
{
    [Activity (ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "ArcGIS vector tiled layer URL",
        category: "Layers",
        description: "Load an ArcGIS Vector Tiled Layer from a URL.",
        instructions: "Use the drop down menu to load different vector tile basemaps.",
        tags: new[] { "tiles", "vector", "vector basemap", "vector tiled layer", "vector tiles" })]
    public class ArcGISVectorTiledLayerUrl : Activity
    {
        // Hold a reference to the map view
        private MapView _myMapView;

        // Dictionary associates layer names with URIs
        private readonly Dictionary<string, Uri> _layerUrls = new Dictionary<string, Uri>()
        {
            {"Mid-Century", new Uri("https://www.arcgis.com/home/item.html?id=7675d44bb1e4428aa2c30a9b68f97822")},
            {"Colored Pencil", new Uri("https://www.arcgis.com/home/item.html?id=4cf7e1fb9f254dcda9c8fbadb15cf0f8")},
            {"Newspaper", new Uri("https://www.arcgis.com/home/item.html?id=dfb04de5f3144a80bc3f9f336228d24a")},
            {"Nova", new Uri("https://www.arcgis.com/home/item.html?id=75f4dfdff19e445395653121a95a85db")},
            {"World Street Map (Night)", new Uri("https://www.arcgis.com/home/item.html?id=86f556a2d1fd468181855a35e344567f")}
        };

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Title = "ArcGIS vector tiled Layer";

            // Create the UI, setup the control references and execute initialization
            CreateLayout();
            Initialize();
        }

        private void Initialize()
        {
            // Create a new ArcGISVectorTiledLayer with the navigation service URL
            ArcGISVectorTiledLayer vectorTiledLayer = new ArcGISVectorTiledLayer(_layerUrls.Values.First());

            // Create new Map with basemap
            Map myMap = new Map();
            myMap.OperationalLayers.Add(vectorTiledLayer);

            // Provide used Map to the MapView
            _myMapView.Map = myMap;
        }

        private void OnVectorLayersClicked(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            // Create menu to show options
            PopupMenu menu = new PopupMenu(this, button);
            menu.MenuItemClick += OnVectorLayersMenuItemClicked;

            // Create menu options
            foreach (string vectorLayerName in _layerUrls.Keys)
            {
                menu.Menu.Add(vectorLayerName);
            }

            // Show menu in the view
            menu.Show();
        }

        private void OnVectorLayersMenuItemClicked(object sender, PopupMenu.MenuItemClickEventArgs e)
        {
            // Get title from the selected item
            string selected = e.Item.TitleCondensedFormatted.ToString();

            // Create new ArcGISVectorTiled layer with the selected service Url
            ArcGISVectorTiledLayer vectorTiledLayer = new ArcGISVectorTiledLayer(_layerUrls[selected]);

            // Create a new map with a basemap that was selected. Assign this to the mapview's map
            _myMapView.Map.OperationalLayers.Clear();
            _myMapView.Map.OperationalLayers.Add(vectorTiledLayer);
        }

        private void CreateLayout()
        {
            // Create a new vertical layout for the app
            LinearLayout layout = new LinearLayout(this) { Orientation = Orientation.Vertical };

            // Create button to show options
            Button button = new Button(this)
            {
                Text = "Select layer"
            };
            button.Click += OnVectorLayersClicked;

            // Add button to the layout
            layout.AddView(button);

            // Add the map view to the layout
            _myMapView = new MapView(this);
            layout.AddView(_myMapView);

            // Show the layout in the app
            SetContentView(layout);
        }
    }
}
Examples

Xamarin Forms Android

Example Name: ArcGISVectorTiledLayerUrl

Load an ArcGIS Vector Tiled Layer from a URL.

Code example screen shot.

C#
// Copyright 2018 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Mapping;
using System;
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms;

namespace ArcGISRuntime.Samples.ArcGISVectorTiledLayerUrl
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "ArcGIS vector tiled layer URL",
        category: "Layers",
        description: "Load an ArcGIS Vector Tiled Layer from a URL.",
        instructions: "Use the drop down menu to load different vector tile basemaps.",
        tags: new[] { "tiles", "vector", "vector basemap", "vector tiled layer", "vector tiles" })]
    public partial class ArcGISVectorTiledLayerUrl : ContentPage
    {
        private readonly Dictionary<string, Uri> _layerUrls = new Dictionary<string, Uri>()
        {
            {"Mid-Century", new Uri("https://www.arcgis.com/home/item.html?id=7675d44bb1e4428aa2c30a9b68f97822")},
            {"Colored Pencil", new Uri("https://www.arcgis.com/home/item.html?id=4cf7e1fb9f254dcda9c8fbadb15cf0f8")},
            {"Newspaper", new Uri("https://www.arcgis.com/home/item.html?id=dfb04de5f3144a80bc3f9f336228d24a")},
            {"Nova", new Uri("https://www.arcgis.com/home/item.html?id=75f4dfdff19e445395653121a95a85db")},
            {"World Street Map (Night)", new Uri("https://www.arcgis.com/home/item.html?id=86f556a2d1fd468181855a35e344567f")}
        };

        public ArcGISVectorTiledLayerUrl()
        {
            InitializeComponent();

            // Create the UI, setup the control references and execute initialization
            Initialize();
        }

        private void Initialize()
        {
            // Create a new ArcGISVectorTiledLayer with the navigation service URL
            ArcGISVectorTiledLayer vectorTiledLayer = new ArcGISVectorTiledLayer(_layerUrls.Values.First());

            // Create new Map with basemap
            Map myMap = new Map(new Basemap(vectorTiledLayer));

            // Assign the map to the MapView
            MyMapView.Map = myMap;
        }

        private async void OnChangeLayerButtonClicked(object sender, EventArgs e)
        {
            // Get list of layer names as array to show in an action sheet
            string[] layerNames = _layerUrls.Keys.ToArray();

            // Show sheet and get title from the selection
            string selectedLayer = await ((Page)Parent).DisplayActionSheet("Select layer", "Cancel", null, layerNames);

            // If selected cancel do nothing
            if (selectedLayer == "Cancel") return;

            // Create a new ArcGISVectorTiledLayer with the URL Selected by the user
            ArcGISVectorTiledLayer vectorTiledLayer = new ArcGISVectorTiledLayer(_layerUrls[selectedLayer]);

            // Create new Map with basemap and assigning to the MapView's Map
            MyMapView.Map = new Map(new Basemap(vectorTiledLayer));
        }
    }
}
XAML
<?xml version="1.0" encoding="utf-8"?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
             x:Class="ArcGISRuntime.Samples.ArcGISVectorTiledLayerUrl.ArcGISVectorTiledLayerUrl">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <esriUI:MapView x:Name="MyMapView" />
        <Button Text="Choose a layer"
                Grid.Row="1"
                Clicked="OnChangeLayerButtonClicked" />
    </Grid>
</ContentPage>
See Also
Additional Examples
Hyperlink to ExampleDescription
ArcGISVectorTiledLayerUrlLoad an ArcGIS Vector Tiled Layer from a URL.