How to add WMS Layer from Mapserver( localhost) on Cesium Globe?

664 views
Skip to first unread message

bikram....@gmail.com

unread,
Jan 27, 2015, 12:05:56 AM1/27/15
to cesiu...@googlegroups.com
I am trying to add WMS layer from mapserver i.e. from localhost on Cesium Globe with the following HTML code. But I am not able to load or connect Cesium with the Mapserver and nothing is displayed on the browser. Mapserver is running successfully, there is no issue with Mapserver, I am not able to locate the error in the following code. Please tell me where I went wrong in the code.

The script, I used is -

<script id="cesium_sandcastle_script">
function startup(Cesium) {
"use strict";
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer');
// Add a WMS imagery layer
var imageryLayers = viewer.imageryLayers;
imageryLayers.addImageryProvider(new Cesium.WebMapServiceImageryProvider({
url : 'http://demo.mapserver.org/cgi-bin/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities',
layers : 'bluemarble',
parameters : {
transparent : true,
format : 'image/png'
}
}));

// Start off looking at Australia.
viewer.camera.viewRectangle(Cesium.Rectangle.fromDegrees(114.591, -45.837, 148.970, -5.730));//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>

Kevin Ring

unread,
Jan 27, 2015, 12:22:49 AM1/27/15
to cesiu...@googlegroups.com
Hi,

Is there anything in the browser's console?  Any exceptions?  The most likely problem is that your server does not support CORS, so browser security prevents Cesium (or any other WebGL-based library) from accessing it. http://enable-cors.org/

Kevin


--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

bikram....@gmail.com

unread,
Jan 27, 2015, 2:06:36 AM1/27/15
to cesiu...@googlegroups.com, bikram....@gmail.com
Hi,
I checked there is no problem with the browser's console. Actually it runs fine for WMS servers which are online, but I am having problem regarding WMS service through localhost. I am having Mapserver, it is running fine without any problem; but I am not getting the correct URL for calling WMS service from localhost Mapserver. Infact with this demo also its not working. Please indicate where I went worng with this code.
Thanks for the reply !

Just van den Broecke

unread,
Jan 27, 2015, 2:35:51 PM1/27/15
to cesiu...@googlegroups.com
Hi,

I think you need to provide more context/details for your problem. There
are a number of things that could go wrong.

- CORS: as Kevin indicated your server may not support CORS:
http://enable-cors.org
- WMS URL: in your example:
http://demo.mapserver.org/cgi-bin/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities.
This is not a localhost and I think the URL should be the base URL like:
http://demo.mapserver.org/cgi-bin/wms or the localhost-equivalent.
- projection issues

Apart from the Console observe also the network traffic in the browser
debugger: outgoing requests and their responses+HTTP codes.

best,

Just van den Broecke

PS Please reply to the last answer given, so the mail thread gets preserved.
Reply all
Reply to author
Forward
0 new messages