Maps Manager Service

The MapManagerService

Angular Cesium extends cesium api and expose additional features, but if you want to use pure cesium api, you can do so by using the MapsManagerService. This service is a singleton that allow you to get the ac-map anywhere in your app. With the map component you can receive cesium viewer or any other util service that was created by ac-map.

@Component({
selector: 'my-component',
})
export class MyComponent {
constructor(mapsManagerService: MapsManagerService)
// Get default map values
const viewer = mapsManagerService.getMap().getCesiumViewer();
const mapEventManager = mapsManagerService.getMap().getMapEventsManager();
const cameraService = mapsManagerService.getMap().getCameraService();
// Get map by id name
const viewer = mapsManagerService.getMap('secondery-map').getCesiumViewer();
}

API

  • get(mapId?: string)

Retrieve a specific map by id. If mapId not provided then the first map is returned, for use cases when you have only one ac-map instance

The CesiumService

Service that initialize cesium viewer and expose cesium viewer and scene.

Provided and created by the ac-map component, so each map has it own CesiumService instance. Therefore can only be injected to components under the <ac-map/> hierarchy.

@Component({
selector: 'tracks-layer',
})
export class TracksLayerComponent implements OnInit {
constructor(private cesiumService: CesiumService) {
// return the cesium viewer
const viewer = this.cesiumService.getViewer()
// return the cesium scene
const scene = this.cesiumService.getScene()
// return the cesium canvas
const canvas = this.cesiumService.getCanvas()
// return the AcMapComponent
const acMap = this.cesiumSerice.getMap()
}
}