This application is using Cesium's default ion access token. How can i fix this warning?

3,083 views
Skip to first unread message

alex...@gmail.com

unread,
Aug 26, 2018, 5:21:40 PM8/26/18
to cesium-dev
I, everyone!
I create a world map using this code:
Cesium.BingMapsApi.defaultKey = 'MY KEY';
var viewer = new Cesium.Viewer('cont', {
selectionIndicator: false,
navigationHelpButton: false,
navigationInstructionsInitiallyVisible: false,
baseLayerPicker: false,
geocoder : [
new Cesium.CartographicGeocoderService(),
new Cesium.BingMapsGeocoderService()
],
terrainProvider: Cesium.createWorldTerrain(
{
requestWaterMask: true,
requestVertexNormals: true
})
});
var imageryProv = new Cesium.BingMapsImageryProvider({
url: '//dev.virtualearth.net',
mapStyle: Cesium.BingMapsStyle.AERIAL
});
var imageryLayers = viewer.imageryLayers;
imageryLayers.addImageryProvider(imageryProv);
I have warning: "This application is using Cesium's default ion access token. Please assign Cesium.Ion.defaultAccessToken with an access token from your ion account before making any Cesium API calls".

I don't want to use Ion in my project. In documentation i saw that BingMapsImageryProvider by default is provided through Cesium ion. To go back to the old default behavior with BingMaps my code should be like:
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider : new Cesium.BingMapsImageryProvider({
url : 'https://dev.virtualearth.net'
}),
geocoder : [
new Cesium.CartographicGeocoderService(),
new Cesium.BingMapsGeocoderService()
]
});
I've done all like in example, but warning is still there. Also i change geocoder to false. Nothing changed too.

What can be wrong with my code?
Thank you for any help.

Omar Shehata

unread,
Aug 26, 2018, 7:44:38 PM8/26/18
to cesium-dev
I think you're missing a `key` to the `BingMapsImageryProvider` constructor. See:


Hope this helps!
Message has been deleted

alex...@gmail.com

unread,
Aug 27, 2018, 3:03:35 AM8/27/18
to cesium-dev
thanks for advice, but the warning still exists

Omar Shehata

unread,
Aug 27, 2018, 8:53:05 AM8/27/18
to cesium-dev
You're right, I just tried it out. Looks like that warning will be there as long as as `Cesium.Ion.defaultAccessToken`  is set, because even if you're not loading imagery from ion on startup, you could still load assets and it'll use the default access token.

So all you have to do is set it to null or something else and that should remove the warning. The example below works for me. 

Cesium.Ion.defaultAccessToken = null;

var viewer = new Cesium.Viewer('cesiumContainer', {
    imageryProvider: new Cesium.BingMapsImageryProvider({
                url : 'https://dev.virtualearth.net',
                key: '<Your Key>',
                mapStyle: Cesium.BingMapsStyle.AERIAL_WITH_LABELS  
            }),
    baseLayerPicker : false
});

alex...@gmail.com

unread,
Aug 27, 2018, 9:30:07 AM8/27/18
to cesium-dev
thanks again!
As Ion defaultAccessToken tried null and valid ion token, but, unfortunately, with your example i still have the warning.
I know that ion is by default in geocoder, imageryProvider and terrainProvider in cesiumjs 1.48, but in github i saw that the last version also should work with previos cesium's default bingmaps key.

alex...@gmail.com

unread,
Aug 27, 2018, 9:42:31 AM8/27/18
to cesium-dev
did you have any errors in developer mode in browser?

Omar Shehata

unread,
Aug 27, 2018, 9:48:13 AM8/27/18
to cesium-dev
It looks the docs are actually outdated. It says here that it will use a default Bing key:


But this is no longer true. You'll have to get a key from https://www.bingmapsportal.com/ if you're not using Cesium ion.

I just tested with a geocoder, and this code works once I add my key in (and doesn't show the ion warning). 

Cesium.Ion.defaultAccessToken = null;

    var viewer = new Cesium.Viewer('cesiumContainer', {
       imageryProvider: new Cesium.BingMapsImageryProvider({
                   url : 'https://dev.virtualearth.net',
                   key: '<Your Key>',
                   mapStyle: Cesium.BingMapsStyle.AERIAL_WITH_LABELS  
               }),
       baseLayerPicker : false,
       geocoder : [
           new Cesium.CartographicGeocoderService(),
           new Cesium.BingMapsGeocoderService({key:'<Your Key>'})
   ]
   });

Thanks for pointing out the confusion here. I'll update the docs. 

Omar Shehata

unread,
Aug 27, 2018, 9:48:48 AM8/27/18
to cesium-dev
No errors with my latest example. Are you getting an error? Can you post it here?

alex...@gmail.com

unread,
Aug 27, 2018, 12:04:36 PM8/27/18
to cesium-dev
I experimented with your code, error was with accessing to cesium. I think my code has wrong lines, so this error appears.

Your latest example with code fixed my warning, many thanks!!

But when i added terrainProvider error appeared again))
my code looks like:

Cesium.Ion.defaultAccessToken = null;

var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider: new Cesium.BingMapsImageryProvider({
url : 'https://dev.virtualearth.net',

key: '<KEY>',
mapStyle: Cesium.BingMapsStyle.AERIAL
}),


baseLayerPicker : false,
geocoder : [
new Cesium.CartographicGeocoderService(),

new Cesium.BingMapsGeocoderService({key:'<KEY>'})

alex...@gmail.com

unread,
Aug 27, 2018, 1:45:14 PM8/27/18
to cesium-dev
If I use terrainProvider i can only use IonImageryProvider and IonGeocoderService instead of geocoder and imageryProvider (with BingMap key)? How should code looks like (to avoid warning with token access)? Thanks.

alex...@gmail.com

unread,
Aug 27, 2018, 4:33:08 PM8/27/18
to cesium-dev
I fixed warning. My problem was in invalid ion access token (don't know why it was invalid, i checked it many times). I replace program with new ion token and my code works. Omar, many thanks for your help.

Reply all
Reply to author
Forward
0 new messages