Refactor 3d to own library
This commit is contained in:
11
projects/common-map3d/src/fm-map3d/common-map3d.module.ts
Normal file
11
projects/common-map3d/src/fm-map3d/common-map3d.module.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Switch2D3DComponent } from './components/olcs/switch2d3d/switch2d3d.component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [Switch2D3DComponent],
|
||||
imports: [
|
||||
],
|
||||
exports: [Switch2D3DComponent]
|
||||
})
|
||||
export class CommonMap3dModule { }
|
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CommonMap3dService } from './common-map3d.service';
|
||||
|
||||
describe('CommonMap3dService', () => {
|
||||
let service: CommonMap3dService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(CommonMap3dService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
@@ -0,0 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CommonMap3dService {
|
||||
|
||||
constructor() { }
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
@import "~bootstrap/scss/bootstrap.scss";
|
||||
|
||||
.twotreed {
|
||||
display:block;
|
||||
width:2.5em;
|
||||
height:2.5em;
|
||||
background-color: $body-bg;
|
||||
background-size: contain;
|
||||
margin-top:0.5em;
|
||||
text-align: center;
|
||||
line-height: 2.5em;
|
||||
border-radius: 1.75em;
|
||||
padding: 0;
|
||||
color: $secondary;
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
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-map3d-switch2d3d',
|
||||
template: '<div (click)="handleClick($event)" class="btn btn-outline-secondary twotreed">{{label}}</div>',
|
||||
styleUrls: ['./switch2d3d.component.scss']
|
||||
})
|
||||
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, 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.synchronize();
|
||||
}
|
||||
this.ol3d.setEnabled(this.enable);
|
||||
this.label = this.enable?"2D":"3D";
|
||||
}
|
||||
}
|
7
projects/common-map3d/src/public-api.ts
Normal file
7
projects/common-map3d/src/public-api.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
* Public API Surface of common-map3d
|
||||
*/
|
||||
|
||||
export * from './fm-map3d/common-map3d.service';
|
||||
export * from './fm-map3d/components/olcs/switch2d3d/switch2d3d.component';
|
||||
export * from './fm-map3d/common-map3d.module';
|
26
projects/common-map3d/src/test.ts
Normal file
26
projects/common-map3d/src/test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/dist/zone';
|
||||
import 'zone.js/dist/zone-testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import {
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting
|
||||
} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
declare const require: {
|
||||
context(path: string, deep?: boolean, filter?: RegExp): {
|
||||
keys(): string[];
|
||||
<T>(id: string): T;
|
||||
};
|
||||
};
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting()
|
||||
);
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
// And load the modules.
|
||||
context.keys().map(context);
|
Reference in New Issue
Block a user