Select to view content in your preferred language

How do I add an WMTS layer?

4750
16
Jump to solution
12-12-2016 01:48 AM
MatthiasPorges
Emerging Contributor

I'm kinda lost here.

I basically just want to add a Layer for basemap.at - see here: https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml

How do I do this? Do I use ArcGISTiledLAyer? ArcGISMapImageLayer? Which Uri?

The only documentation about WMTS I found was a "PortalItemType". If I need a "ArcGISPortal", what should I use as an Uri here?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

Actually OpenStreetMap didn't make it either.  However here's a custom tiled layer that renders OSM. You can probably tweak it to work for your WMTS service.

public class OpenStreetMapLayer : Esri.ArcGISRuntime.Mapping.ServiceImageTiledLayer
{
     public OpenStreetMapLayer() 
            : base(CreateTileInfo(), new Envelope(-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892, SpatialReferences.WebMercator))
     {
     }

     private static Esri.ArcGISRuntime.ArcGISServices.TileInfo CreateTileInfo()
     {
          var levels = new Esri.ArcGISRuntime.ArcGISServices.LevelOfDetail[19];
          double resolution = 20037508.3427892 * 2 / 256;
          double scale = resolution * 96 * 39.37;
          for (int i = 0; i < levels.Length; i++)
          {
               levels[i] = new Esri.ArcGISRuntime.ArcGISServices.LevelOfDetail(i, resolution, scale);
               resolution /= 2;
               scale /= 2;
          }
          return new Esri.ArcGISRuntime.ArcGISServices.TileInfo(96, TileImageFormat.Png, levels, new MapPoint(-20037508.3427892, 20037508.3427892, SpatialReferences.WebMercator),
               SpatialReferences.WebMercator, 256, 256);
     }

     private static string[] subdomains = { "a", "b", "c" };
     
     protected override Task<Uri> GetTileUriAsync(int level, int row, int column, CancellationToken cancellationToken)
     {
          return Task.FromResult(new Uri($"http://{ subdomains[(level + column + row) % subdomains.Length]}.tile.openstreetmap.org/{level}/{column}/{row}.png", UriKind.Absolute));
     }
}

View solution in original post

16 Replies
PreetiMaske
Esri Regular Contributor

WMTS support is not available in the released version but it's up on the list for next release.

0 Kudos
MatthiasPorges
Emerging Contributor

Is there no workaround for adding a single layer?

I was told, the SDK supports "Open Street Map", which uses the same protocol as basemap.at.

0 Kudos
dotMorten_esri
Esri Notable Contributor

Actually OpenStreetMap didn't make it either.  However here's a custom tiled layer that renders OSM. You can probably tweak it to work for your WMTS service.

public class OpenStreetMapLayer : Esri.ArcGISRuntime.Mapping.ServiceImageTiledLayer
{
     public OpenStreetMapLayer() 
            : base(CreateTileInfo(), new Envelope(-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892, SpatialReferences.WebMercator))
     {
     }

     private static Esri.ArcGISRuntime.ArcGISServices.TileInfo CreateTileInfo()
     {
          var levels = new Esri.ArcGISRuntime.ArcGISServices.LevelOfDetail[19];
          double resolution = 20037508.3427892 * 2 / 256;
          double scale = resolution * 96 * 39.37;
          for (int i = 0; i < levels.Length; i++)
          {
               levels[i] = new Esri.ArcGISRuntime.ArcGISServices.LevelOfDetail(i, resolution, scale);
               resolution /= 2;
               scale /= 2;
          }
          return new Esri.ArcGISRuntime.ArcGISServices.TileInfo(96, TileImageFormat.Png, levels, new MapPoint(-20037508.3427892, 20037508.3427892, SpatialReferences.WebMercator),
               SpatialReferences.WebMercator, 256, 256);
     }

     private static string[] subdomains = { "a", "b", "c" };
     
     protected override Task<Uri> GetTileUriAsync(int level, int row, int column, CancellationToken cancellationToken)
     {
          return Task.FromResult(new Uri($"http://{ subdomains[(level + column + row) % subdomains.Length]}.tile.openstreetmap.org/{level}/{column}/{row}.png", UriKind.Absolute));
     }
}
MatthiasPorges
Emerging Contributor

This works, thank you!

You don't happen to have a similar workaround/implementation for ServiceFeatureTable from WMS?

0 Kudos
Pierre-JeanMuller
Occasional Contributor

here is the code in order to show wmts tiles

protected override Task<Uri> GetTileUriAsync(int level, int row, int column, CancellationToken cancellationToken)
 {
row = (int)(Math.Pow(2, level) - row - 1);
 string uriString = tilesUri + $"/{level}/{column}/{row}.png";
return Task.FromResult(new Uri(uriString, UriKind.Absolute));
}
0 Kudos
Parh_JinChia
Emerging Contributor

with version 100.1.0 of the SDK for .Net, support for WMTS is supposed to be here as mentioned in the release notes.

However, I could still find no documentation on this.

How do I take in a WMTS map? I was using 10.2.4 previously, I had hoped to do something like that...

0 Kudos
NagmaYasmin
Esri Contributor

Hi Parh,

WmtsLayer (WmtsLayer Class) is introduced in 100.1 to display WMTS layer. If you have downloaded the sample, there is an example how to consume the WMTS service using Runtime .net application. 

Hope that helps,

Nagma

WmtsLayer

0 Kudos
Parh_JinChia
Emerging Contributor

Thanks Yasmin. I have gotten it working now.

I am trying to work on something lightweight and cost nothing.

My current solution is to use open street map data in a local installation

of geoserver,

that is why I am using WMTS.

I would like to know whether there is any simpler solution?

i.e. is there any way for Esri Arcgis .NET SDK to consume local map data

(or even a geotagged image)?

I know there are map packages that can be generated from ArcGIS Desktop,

but that would require me to

buy ArcGIS desktop, so I am not going that direction..

thanks in advance for any pointers.

rgds

PJ

0 Kudos
dotMorten_esri
Esri Notable Contributor