# I don't think I am building this wms provider correctly

**URL:** <https://community.cesium.com/t/i-dont-think-i-am-building-this-wms-provider-correctly/3685>\
**Category:** CesiumJS\
**Created:** [February 4, 2016, 11:01pm UTC](https://community.cesium.com/t/i-dont-think-i-am-building-this-wms-provider-correctly/3685 "2016-02-04T23:01:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thoms\_Evan](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@Thoms\_Evan](https://community.cesium.com/u/Thoms_Evan)\
**Post date:** [February 4, 2016, 11:01pm UTC](https://community.cesium.com/t/i-dont-think-i-am-building-this-wms-provider-correctly/3685/1 "2016-02-04T23:01:40Z")

</div>

Hi there,

Could someone take a look at this WMS ?

[http://wms.alaskamapped.org/ortho](http://wms.alaskamapped.org/ortho)

and help me out with building a Cesium.WebMapServiceImageryProvider?

I have:

> var spot = new Cesium.WebMapServiceImageryProvider({  
> url: ‘[http://wms.alaskamapped.org/ortho](http://wms.alaskamapped.org/ortho)’,  
> layers: 'ORTHO.RGB, //tried a bunch of different names out here  
> });

I am seeing a CORS error when the page loads, but I have seen those before when the problem ultimately was a poorly constructed url or parameter. I think I need to rule out the possibility that I am not referencing the layer properly.

thanks,

Evan

---

<div class="post-metadata">

**Author:** ![hannah](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hannah/32/4509_2.png) [@hannah](https://community.cesium.com/u/hannah)\
**Post date:** [February 5, 2016, 2:07pm UTC](https://community.cesium.com/t/i-dont-think-i-am-building-this-wms-provider-correctly/3685/2 "2016-02-05T14:07:34Z")

</div>

Hello Evan,

CORS issues usually have to do with how your server is configured. [http://enable-cors.org/](http://enable-cors.org/) is a good resource for learning about CORS and how to enable it.

I was able to get your imagery to load with the code you included in your post, so that’s not the problem.

Best,

Hannah

---

<div class="post-metadata">

**Author:** ![michelle.coombs](https://avatars.discourse-cdn.com/v4/letter/m/51bf81/32.png) [@michelle.coombs](https://community.cesium.com/u/michelle.coombs)\
**Post date:** [February 5, 2016, 5:37pm UTC](https://community.cesium.com/t/i-dont-think-i-am-building-this-wms-provider-correctly/3685/3 "2016-02-05T17:37:25Z")

</div>

Hi Hannah,  
Thanks for looking into that. Do you have an example I could see in the cesium online sandcastle?

I also found a TMS address:  
[http://tiles.gina.alaska.edu/tiles/SPOT5.SDMI.ORTHO\_RGB/tile/{x}/{y}/{z}.png](http://tiles.gina.alaska.edu/tiles/SPOT5.SDMI.ORTHO_RGB/tile/%7Bx%7D/%7By%7D/%7Bz%7D.png)  
and I can get this to work in a Leaflet fiddle app by simply adding

L.tileLayer('[http://tiles.gina.alaska.edu/tiles/SPOT5.SDMI.ORTHO\_RGB/tile/{x}/{y}/{z}.png](http://tiles.gina.alaska.edu/tiles/SPOT5.SDMI.ORTHO_RGB/tile/%7Bx%7D/%7By%7D/%7Bz%7D.png)').addTo(map)

But, again, when I try:

var spot = new Cesium.TileMapServiceImageryProvider({  
&nbsp;&nbsp;url: '[http://tiles.gina.alaska.edu/tiles/SPOT5.SDMI.ORTHO\_RGB/tile/{x}/{y}/{z}.png](http://tiles.gina.alaska.edu/tiles/SPOT5.SDMI.ORTHO_RGB/tile/%7Bx%7D/%7By%7D/%7Bz%7D.png)',  
&nbsp;&nbsp;fileExtension: 'png'  
});

it doesn't work. Same resource, same browser, and I am not doing anything to address CORS, what's the difference?

PS. I don't have any control over the server

---

<div class="post-metadata">

**Author:** ![hannah](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hannah/32/4509_2.png) [@hannah](https://community.cesium.com/u/hannah)\
**Post date:** [February 5, 2016, 6:15pm UTC](https://community.cesium.com/t/i-dont-think-i-am-building-this-wms-provider-correctly/3685/4 "2016-02-05T18:15:57Z")

</div>

Hi Evan,

You most likely have to enable CORS support on your own server. For example, we have a proxy route included in the server.js node script included with the Cesium download. If you run Sandcastle locally by doing `node server.js`, this code will work:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {  
imageryProvider : new Cesium.WebMapServiceImageryProvider({  
url: ‘[//wms.alaskamapped.org/ortho](https://wms.alaskamapped.org/ortho)’,  
layers: ‘ORTHO.RGB’,  
proxy : new Cesium.DefaultProxy(’/proxy/’)  
}),  
baseLayerPicker : false  
});

``

For the TMS server, consider using the UrlTemplateImageryProvider instead, since you know the template of the URL:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {  
imageryProvider : new Cesium.UrlTemplateImageryProvider({  
url: ‘[//tiles.gina.alaska.edu/tiles/SPOT5.SDMI.ORTHO\_RGB/tile/{x}/{y}/{z}.png](https://tiles.gina.alaska.edu/tiles/SPOT5.SDMI.ORTHO_RGB/tile/%7Bx%7D/%7By%7D/%7Bz%7D.png)’,  
proxy : new Cesium.DefaultProxy(’/proxy/’)  
}),  
baseLayerPicker : false  
});

``

Best,

Hannah

---

<div class="post-metadata">

**Author:** ![Evan\_Thoms](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Evan\_Thoms](https://community.cesium.com/u/Evan_Thoms)\
**Post date:** [February 5, 2016, 8:10pm UTC](https://community.cesium.com/t/i-dont-think-i-am-building-this-wms-provider-correctly/3685/5 "2016-02-05T20:10:45Z")

</div>

Thanks again,

sorry I am so dense about CORS. I have read dozens of explanations and I only sort of get it. I will try this out.
