2020-09-18 06:38:05 +00:00
|
|
|
import { Component, OnInit,Input,Host } from '@angular/core';
|
|
|
|
import { MapComponent } from 'ngx-openlayers';
|
|
|
|
import OLCesium from 'ol-cesium';
|
2020-09-18 14:05:44 +00:00
|
|
|
//import OLCesium from '../../../../../../../../ol-cesium/src/olcs/OLCesium.js';
|
2020-09-18 06:38:05 +00:00
|
|
|
|
2020-09-18 12:20:33 +00:00
|
|
|
declare var olcs: any;
|
2020-09-18 06:38:05 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'fm-map-switch2d3d',
|
2020-09-18 15:19:29 +00:00
|
|
|
template: '<div (click)="handleClick($event)" class="btn btn-outline-secondary twotreed">{{label}}</div>',
|
|
|
|
styleUrls: ['./switch2d3d.component.scss']
|
2020-09-18 06:38:05 +00:00
|
|
|
})
|
|
|
|
export class Switch2D3DComponent {
|
|
|
|
|
|
|
|
@Input() enable:boolean;
|
|
|
|
public label: string = "3D";
|
|
|
|
private ol3d: OLCesium;
|
2020-09-18 12:20:33 +00:00
|
|
|
private synchronizers:any[];
|
2020-09-18 06:38:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
constructor(@Host() private map: MapComponent) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-09-18 12:20:33 +00:00
|
|
|
ngOnInit() {
|
2020-09-18 15:19:29 +00:00
|
|
|
|
|
|
|
this.ol3d = new OLCesium({ map: this.map.instance, createSynchronizers: (map,scene) => {
|
2020-09-18 12:20:33 +00:00
|
|
|
this.synchronizers = [
|
|
|
|
new olcs.RasterSynchronizer(map,scene),
|
|
|
|
new olcs.VectorSynchronizer(map,scene)
|
|
|
|
];
|
|
|
|
return this.synchronizers;
|
2020-09-18 15:19:29 +00:00
|
|
|
}, stopOpenLayersEventsPropagation:true});
|
2020-09-18 12:20:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
synchronize() {
|
|
|
|
this.synchronizers.forEach((synchronizer) => {
|
|
|
|
synchronizer.synchronize();
|
|
|
|
});
|
2020-09-18 06:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleClick(event) {
|
2020-09-18 12:20:33 +00:00
|
|
|
this.enable = !this.enable;
|
|
|
|
if(this.enable) {
|
|
|
|
this.synchronize();
|
|
|
|
}
|
|
|
|
this.ol3d.setEnabled(this.enable);
|
|
|
|
this.label = this.enable?"2D":"3D";
|
2020-09-18 06:38:05 +00:00
|
|
|
}
|
|
|
|
}
|