How to add WMS Layer from Geoserver on Cesium Globe?

3,809 views
Skip to first unread message

skirve...@qq.com

unread,
Nov 27, 2015, 9:35:19 AM11/27/15
to cesium-dev
I am trying to add WMS layer from geoserver(version 2.8.1). I can connect Cesium with geoserver,but nothing is displayed on earth. geoserver is running successfully, there is keep flashing information, indicates that the following code is accessing data.there is no any error.
the SRS of layer in geoserver is 'EPSG:4326'.Is the cause of the coordinate system?

I am not sure, CORS Filter must be installed or not. but I have installed CORS Filter Under guidance of 'http://software.dzhuvinov.com/cors-filter-installation.html'.Please tell me how to add WMS layer from geoserver.
 
//my code:
var viewer = new Cesium.Viewer('cesiumContainer');

var imageryLayers = viewer.imageryLayers;
var geoWmsLayer = new Cesium.WebMapServiceImageryProvider({
layers : 'sz:SZ_region',
parameters : {
service : 'WMS', 
version : '1.1.0', 
request : 'GetMap'//, 
styles : '', 
format : 'image/png', 
format : 'application/openlayers',
srs : 'EPSG:4326',
transparent : true
}//,
//proxy: new Cesium.DefaultProxy('/proxy/')
});
imageryLayers.addImageryProvider(geoWmsLayer);


Please tell me where I went wrong in the code.thank you.

bobac...@gmail.com

unread,
Nov 28, 2015, 5:42:12 AM11/28/15
to cesium-dev
Hello my code:
new Cesium.WebMapServiceImageryProvider({
url: 'http://localhost:8090/geoserver/ows',
parameters: {
format:'image/png',
transparent:'true'
},
layers : 'cartographie:worldMix',
maximumLevel : 12
});
it's for imagery layer named "worldMix" stored in 'cartographie'

skirve...@qq.com

unread,
Nov 28, 2015, 7:25:39 AM11/28/15
to cesium-dev, bobac...@gmail.com
hi,
thank you for your response.why is '...geoserver/ows',not '...geoserver/wms'?what is your version of geoserver?
certainly,I kown layers means,It is not the issue.

I tried all sorts of options settings.I think the problem is on geoserver,

I have installed CORS Filter.geoserver servcice is running normal.when I zoom or pan globe,the window of geoserver keep flashing information,but report no any error.

Who can give me any help?

thank you all!

skirve...@qq.com

unread,
Nov 29, 2015, 11:17:13 AM11/29/15
to cesium-dev
when I copy my code into Sandcastle to run,I get following error:
An error occurred in "WebMapServiceImageryProvider": Failed to obtain image tile X: 1 Y: 0 Level: 0. 
An error occurred in "WebMapServiceImageryProvider": Failed to obtain image tile X: 0 Y: 0 Level: 0. 
An error occurred in "WebMapServiceImageryProvider": Failed to obtain image tile X: 1 Y: 1 Level: 1. 
.....
everybodys says the prolem is CORS.
My MapServer is geoserver 2.8.1,JDK environment is jdk-8u66-windows-x64,Cesium app is issued with windows IIS.I have install the CORS Filter in accordance with the 'http://software.dzhuvinov.com/cors-filter-installation.html'.
the CORS filter is not work?how enable CORS in geoserver 2.8.1?

rsho...@charter.net

unread,
Nov 29, 2015, 1:53:40 PM11/29/15
to cesium-dev
I had issues with geoserver as well. Finally had to run geoserver out of tomcat with the tomcat cors filter. Don't know if that is an option for you.

tomcat filter:

<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>

cesium code:

var myLayer=new Cesium.WebMapServiceImageryProvider({
url: 'http://174.29.87.2:6486/geoserver/wms',
parameters : {
transparent : 'true',
tiled : 'true',
format : 'image/png',
tileWidth : 1024,
tileHeight : 1024,
maximumLevel : 3,
enablePickFeatures : false
},
layers:'Grand_Valley'
});

skirve...@qq.com

unread,
Nov 30, 2015, 8:01:26 PM11/30/15
to cesium-dev, rsho...@charter.net
thank you for reply very much!
when I changed following code:
<filter-mapping>
<!-- CORS Filter mapping -->
<filter-name>CORS</filter-name>
<url-pattern>/cors-resource.html</url-pattern>
</filter-mapping>
to:
<filter-name>CORS</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
it work well!
thank you very much!
Reply all
Reply to author
Forward
0 new messages