Search code examples
angularcesiumjs

After installing angular-cesium how can I add new access token


I am using angular-cesium in my Angular project. After following the guide in ,and using the command:

ng add angular-cesium

The library is ready to use, but it uses the default access token. Where should I replace the default access token with my own generated token?


Solution

  • This is not mentioned in the documentations, but after investigating the code, there is a commented line in the main.ts file where we can supply the access token:

    import { enableProdMode } from '@angular/core';
    import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
    
    import { AppModule } from './app/app.module';
    import { environment } from './environments/environment';
    
    if (environment.production) {
      enableProdMode();
    }
    
    Cesium.buildModuleUrl.setBaseUrl('/assets/cesium/');
    //Cesium.Ion.defaultAccessToken="";
    
    platformBrowserDynamic().bootstrapModule(AppModule)
      .catch(err => console.error(err));

    I can add the token in defaultAccessToken and uncomment the line.