ArcGIS Runtime SDK for Qt

Web Map Tile Service (WMTS) layer

Loading

Code

import QtQuick 2.6
import Esri.ArcGISRuntime 100.3

Rectangle {
    id: rootRectangle
    clip: true
    width: 800
    height: 600

    property url wmtsServiceUrl: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS"
    property WmtsService service;

    MapView {
        id: mapView
        anchors.fill: parent

        Component.onCompleted: createWmtsLayer();
    }

    function createWmtsLayer() {
        // create the service
        service = ArcGISRuntimeEnvironment.createObject("WmtsService", { url: wmtsServiceUrl });

        // connect to loadStatusChanged signal of the service
        service.loadStatusChanged.connect(function() {
            if (service.loadStatus === Enums.LoadStatusLoaded) {
                // get the layer info list
                var serviceInfo = service.serviceInfo;
                var layerInfos = serviceInfo.layerInfos;
                // get the first layer id from the list
                var layerId = layerInfos[0].wmtsLayerId;
                // create WMTS layer
                var wmtsLayer = ArcGISRuntimeEnvironment.createObject("WmtsLayer", {
                                                                          url: wmtsServiceUrl,
                                                                          layerId: layerId
                                                                      });
                // create a basemap from the layer
                var basemap = ArcGISRuntimeEnvironment.createObject("Basemap");
                basemap.baseLayers.append(wmtsLayer);
                // create a map
                var map = ArcGISRuntimeEnvironment.createObject("Map", {
                                                                    basemap: basemap
                                                                });
                // set the map on the mapview
                mapView.map = map;
            }
        });

        // load the service
        service.load();
    }
}


In this topic
  1. Code