Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ngOnInit() {
this.cameraService.cameraFlyTo({destination: GameMapComponent.DEFAULT_START_LOCATION});
this.mapEventManager
.register({event: CesiumEvent.LEFT_CLICK, pick: PickOptions.PICK_FIRST})
.subscribe((result) => {
const clickPosition = this.geoConverter.screenToCartesian3(result.movement.endPosition);
const existingPoint: PathNode = result.entities && result.entities.length && result.entities[0];
if (!existingPoint) {
this.createNewPathNode(clickPosition)
} else {
// update existing point
this.updatePathNode(existingPoint);
}
this.polyLinePoints.push(clickPosition);
})
}
ngOnInit() {
const mouseOverObservable = this.mapEventsManager.register({
entityType: Track,
event: CesiumEvent.MOUSE_MOVE,
pick: PickOptions.PICK_FIRST,
priority: 2,
});
// Change color on hover
mouseOverObservable.subscribe((event) => {
const track = event.entities !== null ? event.entities[0] : null;
if (this.lastPickTrack && (!track || track.id !== this.lastPickTrack.id)) {
this.lastPickTrack.picked = false;
this.layer.update(this.lastPickTrack, this.lastPickTrack.id);
}
if (track && (!this.lastPickTrack || track.id !== this.lastPickTrack.id)) {
track.picked = true;
this.layer.update(track, track.id);
}
this.lastPickTrack = track;
});
ngOnInit() {
this.tracks$ = this.dataProvider.getDataSteam$().pipe(map(entity => ({
id: entity.id,
actionType: ActionType.ADD_UPDATE,
entity: entity,
})));
const mouseOverObservable = this.mapEventsManager.register({
event: CesiumEvent.MOUSE_MOVE,
pick: PickOptions.PICK_FIRST,
priority: 2,
});
// Change color on hover
mouseOverObservable.subscribe((event) => {
const track = event.entities !== null ? event.entities[0] : null;
if (this.lastPickTrack && (!track || track.id !== this.lastPickTrack.id)) {
this.lastPickTrack.picked = false;
this.layer.update(this.lastPickTrack, this.lastPickTrack.id);
}
if (track && (!this.lastPickTrack || track.id !== this.lastPickTrack.id)) {
track.picked = true;
this.layer.update(track, track.id);
}
this.lastPickTrack = track;
});
this.lastPickTrack.picked = false;
this.layer.update(this.lastPickTrack, this.lastPickTrack.id);
}
if (track && (!this.lastPickTrack || track.id !== this.lastPickTrack.id)) {
track.picked = true;
this.layer.update(track, track.id);
}
this.lastPickTrack = track;
});
// Open dialog on double click
const doubleClickObservable = this.mapEventsManager.register({
entityType: Track,
event: CesiumEvent.LEFT_DOUBLE_CLICK,
pick: PickOptions.PICK_FIRST,
priority: 2,
});
doubleClickObservable.subscribe((event) => {
const track = event.entities !== null ? event.entities[0] : null;
if (track) {
this.ngZone.run(() => this.openDialog(track, event.cesiumEntities[0]));
}
});
}
ngOnInit() {
this.eventManager.register({
event: CesiumEvent.LEFT_CLICK,
pick: PickOptions.PICK_FIRST
}).pipe(
map((result) => result.cesiumEntities),
filter(result => result !== null && result !== undefined), )
.subscribe((result) => {
console.log(result[0]);
alert(result[0].ellipse.material.color._value);
});
}
testColorChange() {
const inputConf = {event: CesiumEvent.LEFT_CLICK, pick: PickOptions.PICK_FIRST, entityType: AcEntity};
this.eventManager
.register(inputConf)
.pipe(
map(result => result.entities[0]),
filter(entity => entity.id === '0'),
)
.subscribe(entity => {
console.log('click3', 'toggle color');
entity.color = entity.color === Cesium.Color.GREEN ? Cesium.Color.BLUE : Cesium.Color.GREEN;
this.layer.update(entity, entity.id);
});
}
}