# WMTS WebMapTileService imageryProvider is not working

**URL:** <https://community.cesium.com/t/wmts-webmaptileservice-imageryprovider-is-not-working/37304>\
**Category:** CesiumJS\
**Created:** [December 12, 2024, 10:42am UTC](https://community.cesium.com/t/wmts-webmaptileservice-imageryprovider-is-not-working/37304 "2024-12-12T10:42:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![swiss\_knight](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/swiss_knight/32/3458_2.png) [@swiss\_knight](https://community.cesium.com/u/swiss_knight)\
**Post date:** [December 12, 2024, 10:42am UTC](https://community.cesium.com/t/wmts-webmaptileservice-imageryprovider-is-not-working/37304/1 "2024-12-12T10:42:54Z")

</div>

[This Sandcastle](https://sandcastle.cesium.com/#c=bVPBbuIwEP0VKxdAQjZsL7uUoq7oCiEVdVXT5ZKLcYbgrh1HthOaRfx77YS0YYtyGY/fmzeeN+E6sw6VAg5g0B3K4IDmYEWh8J86148jXp/nOnNMZGDiaIiOcYaQUCwFU/02uhQJmAnq12mEGsK6ymGCehvYrli+FhIomFJwWF7SesOGVBiJPHzvXD4hZMssKJbjjDmhMyZDnOqSMMNTYYkB64ht6lnyQheU7lkCyTNIAbunTFbEiwZBMGSzWlPifANkjEd4dB1+pK6ScCLH0OmKOSPeKLiL8/nwrA/naK7lCb/mafsEySo/RP+IawotyAadAEpgxwrp2vxOG8VcuKjnSl5z+Cjsuj0tHzrs0bfvSrUwxd6EKtQjlCAnaPzjnOYGEhEqd8yd17l+7wUjitECtNSp4EwiWviZVb1BoJ4GdQUHxnjnP33u1Plp+GJJwzCSXxLK2q31Jb7dCm/wpIkQiqPgs/VGQ8u6SXBjLuZaXfd5o438lLl5IGclH9VL1fjt9/Oj+dPgFsVZ+KJhNK1HP2t7uBcq18aFvvoYEwcql8x5mW3B/4LD3NrBbQOeki51mogSieTuyp+BuGTW+ptdISUV/yCOZlPi8V+oUrNEZOmTb9ivTYDtx7PHJokxnhJ/vM50WsstM/9Vfgc) based on a [WebMapTileServiceImageryProvider](https://cesium.com/learn/ion-sdk/ref-doc/WebMapTileServiceImageryProvider.html) `imageryProvider` is actually not working.

Here’s the code:

```auto
const viewer = new Cesium.Viewer("cesiumContainer", {
  imageryProvider: ({
    cesiumType: 'WebMapTileServiceImageryProvider',
    url : 'http://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/WMTS/tile/1.0.0/USGSShadedReliefOnly/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg',
    layer : 'USGSShadedReliefOnly',
    style : 'default',
    format : 'image/jpeg',
    tileMatrixSetID : 'default028mm',
    maximumLevel: 19,
    credit : new Cesium.Credit('U. S. Geological Survey')
  }),
  terrainProvider: new Cesium.ArcGISTiledElevationTerrainProvider({
    url:
      "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer",
  }),
}); 

```

I’m wondering what is wrong with it?  
Thanks.

---

<div class="post-metadata">

**Author:** ![Luke\_McKinstry](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/luke_mckinstry/32/25557_2.png) [@Luke\_McKinstry](https://community.cesium.com/u/Luke_McKinstry)\
**Post date:** [December 16, 2024, 9:16pm UTC](https://community.cesium.com/t/wmts-webmaptileservice-imageryprovider-is-not-working/37304/2 "2024-12-16T21:16:35Z")

</div>

Hi @swiss_knight ,  
Thanks for your post and for being part of the Cesium community.

We very much appreciate you reporting the potential issue you saw in our documentation!

First it looks like you are using some outdated API code for the `Cesium.Viewer` class. `options.imageryProvider` was depreciated in favor of `options.baseLayer`. [https://github.com/CesiumGS/cesium/blob/main/CHANGES.md#deprecated-hourglass\_flowing\_sand-9](https://github.com/CesiumGS/cesium/blob/main/CHANGES.md#deprecated-hourglass_flowing_sand-9)

I believe the code samples in the docs are up to date reflecting the current API [WebMapTileServiceImageryProvider - Cesium Documentation](https://cesium.com/learn/ion-sdk/ref-doc/WebMapTileServiceImageryProvider.html) so if you plug them into sandcastle they are supposed to work. However it looks like there is a requirement to call the `basemap.nationalmap.gov` urls with https. So you will need to update the url. I made an issue in Cesium for us to update the docs to reflect this [Docs should call `basemap.nationalmap.gov` urls with https · Issue #12375 · CesiumGS/cesium · GitHub](https://github.com/CesiumGS/cesium/issues/12375).

The following works for me in sandcastle

```auto
const viewer = new Cesium.Viewer("cesiumContainer", {
  infoBox: false,
  selectionIndicator: false
});

const shadedRelief1 = new Cesium.WebMapTileServiceImageryProvider({
    url : 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/WMTS',
    layer : 'USGSShadedReliefOnly',
    style : 'default',
    format : 'image/jpeg',
    tileMatrixSetID : 'default028mm',
    // tileMatrixLabels : ['default028mm:0', 'default028mm:1', 'default028mm:2' ...],
    maximumLevel: 19,
    credit : new Cesium.Credit('U. S. Geological Survey')
});
viewer.imageryLayers.addImageryProvider(shadedRelief1);

```

Please let us know if you this works for you or if you see more potential problems.  
Best,  
Luke
