Camera Control
Util service that wraps Cesium's camera, exposes the scene's camera and screenSpaceCameraController. Provided and created by the ac-map component, so each map has it own CameraService instance.
1
@Component({
2
selector: 'track-entity-layer',
3
templateUrl: 'track-entity-layer.component.html',
4
})
5
export class TrackEntityLayerComponent implements OnInit, AfterViewInit {
6
constructor(private mapEventsManager: MapEventsManagerService,
7
private cameraService: CameraService) {
8
}
9
10
ngOnInit() {
11
// PERFORMANCE_SCENE2D - columbos view with 2D restrications, better perfornace then SCENE2D.
12
this.cameraService.setSceneMode(SceneMode.PERFORMANCE_SCENE2D);
13
14
// Get cesium camera
15
const camera = this.cameraService.getCamera();
16
17
// Click on an enity will casuse the camera to track it with an animation
18
this.mapEventsManager.register({event: CesiumEvent.LEFT_CLICK})
19
.subscribe(result => {
20
if (result.cesiumEntities && result.cesiumEntities.length) {
21
this.cameraService.trackEntity(result.cesiumEntities[0], {flyTo: true, altitude: 10000});
22
}
23
});
24
// Cancel entity tracking
25
this.cameraService.untrackEntity();
26
27
// Zoom out
28
this.cameraService.getCamera().zoomOut(50000);
29
30
// Zoom in
31
this.cameraService.getCamera().zoomIn(10000);
32
33
// Scene changes
34
this.cameraService.setSceneMode(SceneMode.SCENE3D); // 3D view
35
this.cameraService.setSceneMode(SceneMode.SCENE2D); // 2D view
36
this.cameraService.setSceneMode(SceneMode.COLUMBUS_VIEW); // Columbus view
37
this.cameraService.setSceneMode(SceneMode.PERFORMANCE_SCENE2D); // Columbos view with 2d restrications, better perfornace the 2D.
38
}
39
}
40
41
Copied!

API

    getCamera() - Gets the scene's camera
    getScreenSpaceCameraController()
    getMinimumZoom()
    setMinimumZoom(amount: number)
    getMaximumZoom()
    setMaximumZoom()
    enableTilt(tilt: boolean)
    enableRotate(rotate: boolean)
    enableLook(lock: boolean)
    enableTranslate(translate: boolean)
    enableZoom(zoom: boolean)
    enableInputs(inputs: boolean)
    cameraFlyTo(options: any) - Flies the camera to a destination
    flyTo(target: any, options?: any) - Flies the camera to a target (viewer.flyTo())
    zoomIn(amount: number)
    zoomOut(amount: number)
    zoomTo(amount: number)
    setView(options: any)
    setRotation(degreesInRadians: number)
    lockRotation(lock: boolean)
    trackEntity(cesiumEntity, options?: { flyTo: boolean; flyToDuration?: number; altitude?: number } )
    untrackEntity()
    setSceneMode(sceneMode: SceneMode, duration?: number)-Sets the map's SceneMode.
Last modified 1yr ago
Copy link