Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for .NET

WMTS layer

This code sample is available for these platforms:
View Sample on GitHub

Display a layer from a Web Map Tile Service.


Use case

WMTS services can have several layers. You can use Runtime to explore the layers available from a service. This would commonly be used to enable a browsing experience where users can choose which layers they want to display at run time.

How to use the sample

The layer will be displayed automatically. Use the buttons to choose a different method of loading the layer.

How it works

To display a WMTS layer directly from a URL:

  1. Create a WmtsService object using the URL of the WMTS service.
  2. Create a WmtsLayer object with the ID of the layer to display.

To explore layers from a WMTS service:

  1. Create a WmtsService object using the URL of the WMTS service.
  2. After loading the WMTS service, get the list of WmtsLayerInfo objects from the service info of the WMTS service.
  3. Use one of the layer infos to create the WMTS layer.
  4. Create a basemap with the WMTS layer and set it to the map.

Relevant API

  • WmtsLayer
  • WmtsLayerInfo
  • WmtsService
  • WmtsServiceInfo

About the data

The map visualizes world time zones.


OGC, WmtsLayer, WmtsLayerInfo, WmtsService, WmtsServiceInfo, layer, raster, tiled, web map tile service

Sample Code

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns=""
            <RowDefinition Height="60" />
            <RowDefinition Height="60" />
            <RowDefinition Height="*" />
        <Button x:Name="UriButton" Text="WMTSLayer via Uri" Clicked="UriButton_Click" Grid.Row="0" IsEnabled="false" />
        <Button x:Name="InfoButton" Text="WMTSLayer via WmtsLayerInfo" Clicked="InfoButton_Click" Grid.Row="1" />
        <esriUI:MapView x:Name="MyMapView" Grid.Row="2" />
// Copyright 2017 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:
// 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 Esri.ArcGISRuntime.Ogc;
using System;
using System.Collections.Generic;
using Xamarin.Forms;

namespace ArcGISRuntime.Samples.WMTSLayer
        "WMTS layer",
        "This sample demonstrates how to display a WMTS layer on a map via a Uri and WmtsLayerInfo.",
    public partial class WMTSLayer : ContentPage
        public WMTSLayer()

        private void UriButton_Click(object sender, EventArgs e)
            //Load the WMTS layer using Uri method.

            // Disable and enable the appropriate buttons.
            UriButton.IsEnabled = false;
            InfoButton.IsEnabled = true;

        private void InfoButton_Click(object sender, EventArgs e)
            //Load the WMTS layer using layer info.

            // Disable and enable the appropriate buttons.
            UriButton.IsEnabled = true;
            InfoButton.IsEnabled = false;

        private async void LoadWMTSLayer(bool uriMode)
                // Create a new map.
                Map myMap = new Map();

                // Get the basemap from the map.
                Basemap myBasemap = myMap.Basemap;

                // Get the layer collection for the base layers.
                LayerCollection myLayerCollection = myBasemap.BaseLayers;

                // Create an instance for the WMTS layer.
                WmtsLayer myWmtsLayer;

                // Define the Uri to the WMTS service.
                Uri wmtsUri = new Uri("");

                if (uriMode)
                    // Create a WMTS layer using a Uri and provide an Id value.
                    myWmtsLayer = new WmtsLayer(wmtsUri, "WorldTimeZones");

                    // Define a new instance of the WMTS service.
                    WmtsService myWmtsService = new WmtsService(wmtsUri);

                    // Load the WMTS service.
                    await myWmtsService.LoadAsync();

                    // Get the service information (i.e. metadata) about the WMTS service.
                    WmtsServiceInfo myWmtsServiceInfo = myWmtsService.ServiceInfo;

                    // Obtain the read only list of WMTS layer info objects.
                    IReadOnlyList<WmtsLayerInfo> myWmtsLayerInfos = myWmtsServiceInfo.LayerInfos;

                    // Create a WMTS layer using the first item in the read only list of WMTS layer info objects.
                    myWmtsLayer = new WmtsLayer(myWmtsLayerInfos[0]);

                // Add the WMTS layer to the layer collection of the map.

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

                // Zoom to appropriate level for iOS.
                await MyMapView.SetViewpointScaleAsync(300000000);
            catch (Exception ex)
                await Application.Current.MainPage.DisplayAlert("Sample error", ex.ToString(), "OK");