reearth / resium

React components for 🌏 Cesium
https://resium.reearth.io
MIT License
744 stars 134 forks source link

Use Cesium user token rather than the default ion access token #60

Closed ale-cristofori closed 5 years ago

ale-cristofori commented 5 years ago

When using the Viewer component in Resium there is a message on the the bottom saying "This application is using Cesium's default ion access token. Please assign Cesium.Ion.defaultAccessToken..."

I was wondering if it would be possible to insert my own Cesium token.

rot1024 commented 5 years ago

Just do it in entry point such as index.js:

import Cesium from "cesium";

Cesium.Ion.defaultAccessToken = "YOUR_ACCESS_TOKEN";

ReactDOM.render(
  // ...
)
utkarsh447 commented 4 years ago
import Cesium from "cesium";
Cesium.Ion.defaultAccessToken = "YOUR_ACCESS_TOKEN";

Import of Cesium was returned as undefined. Rather, do this

import { Ion } from "cesium";
Ion.defaultAccessToken = "YOUR_ACCESS_TOKEN";
badoubadou commented 2 years ago

Hello, I did Ion.defaultAccessToken = "YOUR_ACCESS_TOKEN"; but I still have the "This application is using Cesium's default ion access token. Please assign Cesium.Ion.defaultAccessToken..." Did something change ? It's kind of weird because I can display my own asset from cesium ion, which I can't if I remove this line and run with the default AccessToken. So it's working, but not completely ?

janhartmann commented 2 years ago

Facing the same issue as @badoubadou

salahelfarissi commented 2 years ago

Hi, I have the same problem.

yanhanruan commented 1 year ago

Hello, I did Ion.defaultAccessToken = "YOUR_ACCESS_TOKEN"; but I still have the "This application is using Cesium's default ion access token. Please assign Cesium.Ion.defaultAccessToken..." Did something change ? It's kind of weird because I can display my own asset from cesium ion, which I can't if I remove this line and run with the default AccessToken. So it's working, but not completely ?

I solved this problem by encapsulating the token into the defaultAccessToken attribute. By the way,I didn't use the original cesium , I use the Resium which integrates Cesium with React, I think you could consider bingding this property to a jsx element.My complete code is as follows:

import { Ion } from "cesium";
Ion.defaultAccessToken = "YOUR_TOKEN";
const Map = () => {
    return (<Viewer defaultAccessToken = {Ion}> <Viewer/>);
}
export default Map;
AddictArts commented 3 months ago

Unfortunately the below is not a thing or Viewer removed that attribute at some point. The cesium docs have the above methods Cesium.Ion.defaultAccessToken or Ion.defaultAccessToken depending on how you've included the cesium source.

import { Ion } from "cesium";
Ion.defaultAccessToken = "YOUR_TOKEN";
const Map = () => {
    return (<Viewer defaultAccessToken = {Ion}> <Viewer/>);
}
export default Map;
yanhanruan commented 3 months ago

Unfortunately the below is not a thing or Viewer removed that attribute at some point. The cesium docs have the above methods Cesium.Ion.defaultAccessToken or Ion.defaultAccessToken depending on how you've included the cesium source.

import { Ion } from "cesium";
Ion.defaultAccessToken = "YOUR_TOKEN";
const Map = () => {
    return (<Viewer defaultAccessToken = {Ion}> <Viewer/>);
}
export default Map;

yeah, you are right, I checked the source code of "Viewer" component, the "defaultAccessToken " attribute does not exist