projects/angular-cesium/src/lib/angular-cesium/services/map-layers/map-layers.service.ts
Properties |
|
Methods |
constructor(cesiumService: CesiumService)
|
||||||
Parameters :
|
drawAllLayers |
drawAllLayers()
|
Returns :
void
|
registerLayerDataSources | |||||||||
registerLayerDataSources(dataSources: any[], zIndex: number)
|
|||||||||
Parameters :
Returns :
void
|
removeDataSources | ||||||
removeDataSources(dataSources: any[])
|
||||||
Parameters :
Returns :
void
|
updateAndRefresh | |||||||||
updateAndRefresh(dataSources: any[], newZIndex: number)
|
|||||||||
Parameters :
Returns :
void
|
Private layersDataSources |
layersDataSources:
|
Type : any[]
|
Default value : []
|
import { CesiumService } from '../cesium/cesium.service';
import { Injectable } from '@angular/core';
@Injectable()
export class MapLayersService {
private layersDataSources: any[] = [];
constructor(private cesiumService: CesiumService) {
}
registerLayerDataSources(dataSources: any[], zIndex: number) {
dataSources.forEach(ds => {
ds.zIndex = zIndex;
this.layersDataSources.push(ds);
});
}
drawAllLayers() {
this.layersDataSources.sort((a, b) => a.zIndex - b.zIndex);
this.layersDataSources.forEach((dataSource) => {
this.cesiumService.getViewer().dataSources.add(dataSource);
});
}
updateAndRefresh(dataSources: any[], newZIndex: number) {
if (dataSources && dataSources.length) {
dataSources.forEach((ds) => {
const index = this.layersDataSources.indexOf(ds);
if (index !== -1) {
this.layersDataSources[index].zIndex = newZIndex;
}
});
this.cesiumService.getViewer().dataSources.removeAll();
this.drawAllLayers();
}
}
removeDataSources(dataSources: any[]) {
dataSources.forEach(ds => {
const index = this.layersDataSources.indexOf(ds);
if (index !== -1) {
this.layersDataSources.splice(index, 1);
this.cesiumService.getViewer().dataSources.remove(ds, true);
}
});
}
}