3

I'm trying to implement my map using OL-Cesium / CesiumJS.

var layer2 = new ol.layer.Tile({
      source: new ol.source.TileWMS({
        url: 'https://demo.boundlessgeo.com/geoserver/wms',
        params: {
          'LAYERS': 'opengeo:countries'
        }
      })
});

var map = new ol.Map({
    layers: [
        layer2
    ],
    target: 'world-map',
    view: new ol.View({
        center: [-99.816397,43.2843246],
        zoom: 4,
        projection: 'EPSG:4326'
    })
}); 

var ol3d = new olcs.OLCesium({map: map});
var scene = ol3d.getCesiumScene();
ol3d.setEnabled(true);

This is working well and I can see my map as a globe. But when I change the layer to my local OpenStreetMap Geoserver ...

var osm = new ol.layer.Tile({
    source: new ol.source.TileWMS({
      url: 'http://my.local.osm/geoserver/wms',
      params: {
          'LAYERS': 'osm:worldlayer',

      },
    })
}); 

... I can see only a white globe. Inspecting the "network traffic" in my browser I can see all tiles are comming fine.

This is one of the tile URL in my local geosever (from the browser traffic inspector) :

http://my.local.osm/geoserver/osmope/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=osm%3Aworldlayer&WIDTH=256&HEIGHT=256&CRS=EPSG%3A4326&STYLES=&BBOX=39.375%2C-123.75%2C45%2C-118.125

and this is one of the tiles URL from working Boundless demo geoserver

https://demo.boundlessgeo.com/geoserver/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=opengeo%3Acountries&WIDTH=256&HEIGHT=256&CRS=EPSG%3A4326&STYLES=&BBOX=22.5%2C-135%2C45%2C-112.5

Both cases I can see the image thumbnail in the browser network inspector and the HTTP result is 200. The error (is not a CORS error):

An error occurred in "mf": Failed to obtain image tile X: 4 Y: 2 Level: 3. Cesium.js:459:3692

I'm using OL-Cesium v1.37 from GitHub

There is no proxy between me and my OSM geoserver. There is a proxy between me and Internet.

1
  • Already tried to inspect the code Cesium.js at 459 but the minified code is a nightmare to follow.
    – Magno C
    Commented May 9, 2018 at 13:40

1 Answer 1

1

Well this is a CORS error at all.

Solved (at least at my own server) editing the web.xml of my Tomcat at <TOMCAT_DIR>/conf/web.xml and added this:

<filter>
  <filter-name>CorsFilter</filter-name>
  <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>CorsFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

... but I think OL-Cesium is not very useful when using external layers from Geoserver. OpenLayers can show any WMS layer with easy. Most of my user's layers I can't show in Cesium globe because CORS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.