More or less working now

This commit is contained in:
Willem Dantuma
2020-09-18 14:20:33 +02:00
parent 22e007b70b
commit 15d1f14ee1
8 changed files with 51 additions and 32 deletions

View File

@@ -2,6 +2,7 @@ import { Component, OnInit,Input,Host } from '@angular/core';
import { MapComponent } from 'ngx-openlayers';
import OLCesium from 'ol-cesium';
declare var olcs: any;
@Component({
selector: 'fm-map-switch2d3d',
@@ -21,20 +22,35 @@ export class Switch2D3DComponent {
@Input() enable:boolean;
public label: string = "3D";
private ol3d: OLCesium;
private synchronizers:any[];
constructor(@Host() private map: MapComponent) {
}
ngOnInit() {
this.ol3d = new OLCesium({ map: this.map.instance }); // ol2dMap is the ol.Map instance
ngOnInit() {
this.ol3d = new OLCesium({ map: this.map.instance,createSynchronizers: (map,scene) => {
this.synchronizers = [
new olcs.RasterSynchronizer(map,scene),
new olcs.VectorSynchronizer(map,scene)
];
return this.synchronizers;
},stopOpenLayersEventsPropagation:true});
}
synchronize() {
this.synchronizers.forEach((synchronizer) => {
synchronizer.synchronize();
});
}
handleClick(event) {
this.enable = !this.enable;
if (this.enable)
this.ol3d.setEnabled(this.enable);
this.label = this.enable?"2D":"3D";
this.enable = !this.enable;
if(this.enable) {
this.synchronize();
}
this.ol3d.setEnabled(this.enable);
this.label = this.enable?"2D":"3D";
}
}