Search code examples
javascriptcesiumjswms

Cesium WMS layer issue


Hi all I am trying to get a WMS layer on my cesium globe. Below is the code I am using. When I look at the network tabs I do see the request going through all at 200 and when I use the links on the requests they do work; however, it says their file size is 0kb and I receive this error :

An error occurred in "p": Failed to obtain image tile X: 0 Y: 0 Level: 1. etc.

var viewer = new Cesium.Viewer('cesiumContainer');

var provider = new Cesium.WebMapServiceImageryProvider({
       url : url',
       layers : 'bm'
 });

viewer.imageryLayers.addImageryProvider(provider);

Solution

  • For me it was a CORS issue. If you add the filters in geoserver/webapp/geoserver/WEB-INF/web.xml

    <!-- Uncomment following filter to enable CORS -->
       <filter>
            <filter-name>cross-origin</filter-name>
            <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
        </filter>
    
    <!-- Uncomment following filter to enable CORS -->
        <filter-mapping>
            <filter-name>cross-origin</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    

    and add the jetty servlets in geoserver/webapp/geoserver/WEB-INF/lib it will fix this issue. Download for the servlets is here: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlets/

    See https://gis.stackexchange.com/questions/210109/enabling-cors-in-geoserver-jetty for more info.