# Using WebMapTileServiceImageryProvider as ImageryProvider from Geoserver

**URL:** <https://community.cesium.com/t/using-webmaptileserviceimageryprovider-as-imageryprovider-from-geoserver/7762>\
**Category:** CesiumJS\
**Created:** [December 3, 2018, 1:26pm UTC](https://community.cesium.com/t/using-webmaptileserviceimageryprovider-as-imageryprovider-from-geoserver/7762 "2018-12-03T13:26:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![FerZur](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ferzur/32/21930_2.png) [@FerZur](https://community.cesium.com/u/FerZur)\
**Post date:** [December 3, 2018, 1:26pm UTC](https://community.cesium.com/t/using-webmaptileserviceimageryprovider-as-imageryprovider-from-geoserver/7762/1 "2018-12-03T13:26:59Z")

</div>

I'm trying to use WebMapTileServiceImageryProvider as ImageryProvider from Geoserver layer. I'm seeing that the browser is requesting correctly the tiled images to the server (and the server sends to the browser the images), but I can't see anything on Cesium.

var viewer = new Cesium.Viewer(‘cesiumContainer’, {  
&nbsp;&nbsp;&nbsp;&nbsp;imageryProvider : new Cesium.WebMapTileServiceImageryProvider({  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;url : ‘[http://localhost:8080/geoserver/gwc/service/wmts](http://localhost:8080/geoserver/gwc/service/wmts)’,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;layer : ‘PNOA\_Mun\_Com’,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;style : ‘default’,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format : ‘image/jpeg’,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tileMatrixSetID : ‘EPSG:4326’,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tileMatrixLabels : [‘EPSG:4326:0’, ‘EPSG:4326:1’, ‘EPSG:4326:2’,‘EPSG:4326:3’,‘EPSG:4326:4’,‘EPSG:4326:5’,‘EPSG:4326:6’,‘EPSG:4326:7’,‘EPSG:4326:8’,‘EPSG:4326:9’],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maximumLevel: 10,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rectangle: new Cesium.Rectangle(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cesium.Math.toRadians(-2),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cesium.Math.toRadians(38),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cesium.Math.toRadians(2),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cesium.Math.toRadians(42)),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tilingScheme: new Cesium.GeographicTilingScheme(),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;credit : new Cesium.Credit(‘PNOA’)  
&nbsp;&nbsp;&nbsp;&nbsp;}),  
&nbsp;&nbsp;&nbsp;&nbsp;baseLayerPicker : false  
});

I'm using Hello World Cesium 1.51 SandCastle ([https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/](https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/)). I see the http request to the server, and the images on response, but Cesium is painting nothing.

Thanks in advanced:  
F.Zuriaga

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [December 4, 2018, 5:09pm UTC](https://community.cesium.com/t/using-webmaptileserviceimageryprovider-as-imageryprovider-from-geoserver/7762/2 "2018-12-04T17:09:38Z")

</div>

Does the browser console show any errors? Does this Sandcastle example work for you:

> **[Cesium Sandcastle](https://sandcastle.cesium.com/?src=Web%20Map%20Tile%20Service%20with%20Time.html)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

What happens if you remove the `rectangle` property? Or if you add it to the viewer after initialization and then run “flyTo” like in this example?

> **[Cesium Sandcastle](https://sandcastle.cesium.com/?src=Washington%20DC%202017.html)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

---

<div class="post-metadata">

**Author:** ![FerZur](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ferzur/32/21930_2.png) [@FerZur](https://community.cesium.com/u/FerZur)\
**Post date:** [December 5, 2018, 7:32am UTC](https://community.cesium.com/t/using-webmaptileserviceimageryprovider-as-imageryprovider-from-geoserver/7762/3 "2018-12-05T07:32:36Z")

</div>

The browser console shows many errors, like "

An error occurred in “WebMapTileServiceImageryProvider”: Failed to obtain image tile X: 129 Y: 34 Level: 7.

An error occurred in “WebMapTileServiceImageryProvider”: Failed to obtain image tile X: 128 Y: 34 Level: 7.

An error occurred in “WebMapTileServiceImageryProvider”: Failed to obtain image tile X: 256 Y: 70 Level: 8.

An error occurred in “WebMapTileServiceImageryProvider”: Failed to obtain image tile X: 257 Y: 70 Level: 8.

…because the layer’s limits. But I see in the browser console request that works fine. I send you one screenshot.

 ![capturaPeticiones.jpg](https://global.discourse-cdn.com/cesium/original/2X/e/e9bdf0b894940ee3d63441d655c74450a7062c08.jpeg)

Cesium is making the correct request to the server, and the server is sending the tiles to the browser. The problem is that I can’t see any tile of my layer on the map.

Regards:

F.Zuriaga

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [December 6, 2018, 4:27pm UTC](https://community.cesium.com/t/using-webmaptileserviceimageryprovider-as-imageryprovider-from-geoserver/7762/4 "2018-12-06T16:27:16Z")

</div>

This is quite interesting. I wonder why it’s reporting a failure then. I think you can debug this by putting a console.log where the error is thrown:

[https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/ImageryLayer.js#L754](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/ImageryLayer.js#L754)

Perhaps print out the `e` error object. I would also check the requestImage here:

[https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/WebMapTileServiceImageryProvider.js#L235](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/WebMapTileServiceImageryProvider.js#L235)

Please update this thread if you make any progress here.

---

<div class="post-metadata">

**Author:** ![FerZur](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ferzur/32/21930_2.png) [@FerZur](https://community.cesium.com/u/FerZur)\
**Post date:** [December 7, 2018, 1:39pm UTC](https://community.cesium.com/t/using-webmaptileserviceimageryprovider-as-imageryprovider-from-geoserver/7762/5 "2018-12-07T13:39:21Z")

</div>

The console show errors because this tiles isn't on the server. It's  
normal behavior. My problem is, why can't see on the map the tiles  
that are correctly downloaded from the server?. I only see a blue  
sphere, without any tile... I can't understand why, the tiles is  
correctly downloaded from server.

---

<div class="post-metadata">

**Author:** ![FerZur](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ferzur/32/21930_2.png) [@FerZur](https://community.cesium.com/u/FerZur)\
**Post date:** [December 10, 2018, 2:24pm UTC](https://community.cesium.com/t/using-webmaptileserviceimageryprovider-as-imageryprovider-from-geoserver/7762/6 "2018-12-10T14:24:17Z")

</div>

Hi, finally, I find where is the problem. The problem is CORS, I add a proxy in my web server, and works fine. I thought that, if browser was able to download the image, Cesium would be able to drawn it. But not.

Thanks for your support.

F.Zuriaga

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [December 11, 2018, 9:12pm UTC](https://community.cesium.com/t/using-webmaptileserviceimageryprovider-as-imageryprovider-from-geoserver/7762/7 "2018-12-11T21:12:06Z")

</div>

That’s very interesting, and thanks for posting your solution! I’m sure it’ll help others running into this.
