Select to view content in your preferred language

LINZ WMTS support with .Net SDK version 200.8

123
1
Sunday
NilankaD
Emerging Contributor

We want to support the following WMTS layer in the map.

https://data.linz.govt.nz/services;key=5169bef47e224d43a935e4283e2d57a6/wmts/1.0.0/set/4769/WMTSCapa...

With the old SDK (SDK 10.2.7), this worked. After the upgrade to 200.8, it's not working.

We changed the code to load the WmtsService first and get the layer info and then use it to create the WmtsLayer.  Few other WMTS layers are working successfully after the upgrade. However we had no luck with the above LINZ WMTS layer. Can you please help?

 

 

0 Kudos
1 Reply
GKmieliauskas
Esri Regular Contributor

Hi,

Your WMTS service has 2 Tile Matrix sets with different spatial references: 3857 and 2193. I have succeeded to view your WMTS service with wkid = 2193. I have modified Esri samples code which have Esri.ArcGISRuntime.WPF 300.0.0 package.  I think it must work and with 200.8.0. 

Code below:

                // Define the Uri to the WMTS service.
                Uri wmtsUri = new Uri("https://data.linz.govt.nz/services;key=5169bef47e224d43a935e4283e2d57a6/wmts/1.0.0/set/4769/WMTSCapabilities.xml");

                // 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, and select the one with the desired Id value.
                WmtsLayerInfo info = myWmtsServiceInfo.LayerInfos.Single(l => l.Id == "set-4769");

                Map myMap = new Map(SpatialReference.Create(2193));

                // Create an instance for the WMTS layer.
                WmtsLayer myWmtsLayer;
                // Inspect your layer info matrix names
                var matrixSet = info.TileMatrixSets.FirstOrDefault(cms => cms.SpatialReference.Wkid == 2193);
                if (matrixSet != null)
                {
                    myWmtsLayer = new WmtsLayer(info, matrixSet);
                }
                else
                {
                    myWmtsLayer = new WmtsLayer(info);
                }

                var newBasemap = new Basemap();
                newBasemap.BaseLayers.Add(myWmtsLayer);

                myMap.Basemap = newBasemap;

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

                // Zoom the MapView to the geographic boundaries of the WMTS data
                if (myWmtsLayer.FullExtent != null)
                {
                    await MyMapView.SetViewpointAsync(new Viewpoint(myWmtsLayer.FullExtent));
                }

 

0 Kudos