How to use the token with olcesium

Skip to first unread message

Oct 30, 2018, 2:29:09 PM10/30/18
to cesium-dev
1. A concise explanation of the problem you're experiencing.

Can't reach to use token (Cesium ion) and the viewer properly with olcesium:
.without viewer and token, terrain is working fine but I have the message 'please assign....'
.with viewer and token, terrain isn't working (but no more 'please assign' message)
(TypeError: e is null[En savoir plus] Cesium.js:535:6460 )

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

const scene = ol3d.getCesiumScene();

Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjZDZiOGQ1Zi1mZThlLTQ5MjJgtYmM2Ny0yZjM1ZTUyZWQ3NWIiLCJpZCI6NDEzMCwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTUzOTk1NjYzNn0.4WXr-J59gKgmSOTsiARppKyjarOo_c7zjg8CEBCaOxo';

var viewer = new Cesium.Viewer('cesiumContainer', {

sceneModePicker : false,
terrainProvider : Cesium.createWorldTerrain()

scene.terrainProvider = Cesium.createWorldTerrain({
requestWaterMask: true,
requestVertexNormals: true,


var globe = scene.globe;
scene.globe.enableLighting = true;

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I use it with geoserver/openlayers(5.2) to improve the render

4. The Cesium version you're using, your operating system and browser.

Cesium Ion, windows 7 Pro, Firefox 63.0

Omar Shehata

Oct 31, 2018, 4:05:11 PM10/31/18
to cesium-dev
I think you might not be initializing the map correctly. You have to set the token before the open layers initializes the viewer. I found this example helpful:

Let me know if that helps.

Nov 5, 2018, 3:05:29 PM11/5/18
to cesium-dev
Thanks for the answer, if I do that when I switch to 3D, the logo cesium ion appears but the rest of the screen is black...

Échec du chargement pour l’élément <script> dont la source est « ».

Omar Shehata

Nov 5, 2018, 3:16:33 PM11/5/18
to cesium-dev
I would check the console to see if there are any errors. 

It also sounds like open layers might need to update their examples if it's not working. It might worth posting on their community/GitHub as well.

Nov 6, 2018, 11:57:28 AM11/6/18
to cesium-dev

I dont see critical errors but anyway I will check on github and I just post an issue on it, thanks!

Reply all
Reply to author
0 new messages