Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AcMapLayerProviderComponent options input only accept url #418

Open
bentfc opened this issue Mar 11, 2022 · 1 comment
Open

AcMapLayerProviderComponent options input only accept url #418

bentfc opened this issue Mar 11, 2022 · 1 comment

Comments

@bentfc
Copy link

bentfc commented Mar 11, 2022

In the last version of code, the class "AcMapLayerProviderComponent":

@Component({
  selector: 'ac-map-layer-provider',
  template: '',
})
export class AcMapLayerProviderComponent implements OnInit, OnChanges, OnDestroy {

  /**
   * refer to cesium docs for details https://cesiumjs.org/Cesium/Build/Documentation/ImageryProvider.html
   */
  @Input()
  options: { url?: string } = {};

  ...

should become something like that:

@Component({
  selector: 'ac-map-layer-provider',
  template: '',
})
export class AcMapLayerProviderComponent implements OnInit, OnChanges, OnDestroy {

  /**
   * refer to cesium docs for details https://cesiumjs.org/Cesium/Build/Documentation/ImageryProvider.html
   */
  @Input()
  options: { url?: string, [key:string]: any } = {};

  ...

Declaring options like that allows to add whatever field needed for the chosen provider. Most of them are using much more than just a url.

@bentfc
Copy link
Author

bentfc commented Mar 11, 2022

To more exhaustive, all provider has its own options definition that are declared in cesium.d.ts file. So the input must be one of those type.

/**
   * refer to cesium docs for details https://cesiumjs.org/Cesium/Build/Documentation/ImageryProvider.html
   */
  @Input()
  options: Cesium.WebMapServiceImageryProvider.ConstructorOptions | Cesium.WebMapTileServiceImageryProvider.ConstructorOptions | Cesium.ArcGisMapServerImageryProvider.ConstructorOptions |
    Cesium.SingleTileImageryProvider.ConstructorOptions | Cesium.BingMapsImageryProvider.ConstructorOptions | Cesium.GoogleEarthEnterpriseMapsProvider.ConstructorOptions | Cesium.MapboxImageryProvider.ConstructorOptions |
    Cesium.MapboxStyleImageryProvider.ConstructorOptions | Cesium.UrlTemplateImageryProvider.ConstructorOptions | Cesium.OpenStreetMapImageryProvider.ConstructorOptions;

Also, url field isn't mandatory as declared on the previous post but the following code check and raise an error if the url isn't declared and the provider isn't OFFLINE.

...

ngOnInit() {
    if (!Checker.present(this.options.url) && this.provider !== MapLayerProviderOptions.OFFLINE) {
      throw new Error('options must have a url');
    }

...

This check should not exist anymore as for exemple 'MapboxStyleImageryProvider' doesn't need any url if styleId, accessToken and username are declared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant