Hey there!
I’m trying the following basic cesium with angular code to use in an Offline environment, and I’ve got some errors.
Here is my code:
import { Directive, ElementRef } from '@angular/core';
import { ImageryLayer, TileMapServiceImageryProvider, Viewer, buildModuleUrl } from 'cesium';
@Directive({ selector: '[appCesium]' })
export class CesiumDirective {
constructor(private el: ElementRef) { }
ngOnInit() {
const viewer = new Viewer(this.el.nativeElement, {
baseLayer: ImageryLayer.fromProviderAsync(TileMapServiceImageryProvider.fromUrl(buildModuleUrl("Assets/Textures/NaturalEarthII")), {}),
baseLayerPicker: false,
geocoder: false,
});
}
}
package.json:
{
"name": "ang13",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --port 3000",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "~13.3.0",
"@angular/common": "~13.3.0",
"@angular/compiler": "~13.3.0",
"@angular/core": "~13.3.0",
"@angular/forms": "~13.3.0",
"@angular/platform-browser": "~13.3.0",
"@angular/platform-browser-dynamic": "~13.3.0",
"@angular/router": "~13.3.0",
"bootstrap": "^5.3.2",
"cesium": "1.113.0",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.3.11",
"@angular/cli": "~13.3.11",
"@angular/compiler-cli": "~13.3.0",
"@types/jasmine": "~3.10.0",
"@types/leaflet": "^1.9.8",
"@types/node": "^12.11.1",
"@types/react": "18.2.12",
"@types/react-dom": "18.2.5",
"assert": "^2.1.0",
"browserify-zlib": "^0.2.0",
"https-browserify": "^1.0.0",
"jasmine-core": "~4.0.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.1.0",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"nosleep.js": "^0.12.0",
"stream": "^0.0.2",
"stream-http": "^3.2.0",
"typescript": "~4.6.2",
"url": "^0.11.3",
"util": "^0.12.5"
}
}
main.ts:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { Ion } from 'cesium';
const Cesium = (window as any)['Cesium'];
var poll = setInterval(() => {
if (Cesium) {
clearInterval(poll);
(window as any)['CESIUM_BASE_URL'] = '/assets/cesium/';
Ion.defaultAccessToken = AccessToken
const { AppModule } = require('./app/app.module');
platformBrowserDynamic().bootstrapModule(AppModule).then(ref => {}).catch(err => console.error(err));
}
}, 1000)
Here is the errors:
I would appreciate any idea to solve this problem.
P. S. For some reason, I prefer to not to use the Angular-Cesium NPM