Skip to content

Providers

Tzahi Levi edited this page May 6, 2019 · 2 revisions

Our app need some config in order to work correctly.
we need to inject some data to her. let's look in our app.module.ts

...
providers: [
    {
      provide: OL_CONFIG,
      useValue: {}
    },
    {
      provide: MAP_PROVIDERS_CONFIG,
      useValue: {
        openLayersMap: {
          defaultMapSource: 'BING'
        }
      }
    },
    {
      provide: MAP_SOURCE_PROVIDERS_CONFIG,
      useValue: {
        'BING': {
          key: '<YOUR-KEYS>',
          styles: ['AerialWithLabels']
        }
      }
    }
  ]
...

OL_CONFIG

The default config for OpenLayers
we need to pass an empty object.

MAP_PROVIDERS_CONFIG

we need to pass an object like

MAP_NAME:{
  defaultMapSource: MAP_SOURCE_PROVIDER
  }
}

The MAP_NAME is the same we provide to the imageryModule maps.
The MAP_SOURCE_PROVIDER is the name of the mapSourceProviders we provide to imageryModule.

MAP_SOURCE_PROVIDERS_CONFIG

provide config for our source providers.
see list of the configs for each source provider.