import { CommonModule } from '@angular/common';
import {
AfterViewInit,
Component,
ElementRef,
EventEmitter,
Inject,
Input,
NgModule,
Output,
ViewChild,
} from '@angular/core';
import {
FormsModule,
} from '@angular/forms';
import { CRS, latLng, LatLngBounds, Point } from 'leaflet';
import { IExampleProperties } from './app-component-blueprint';
/* tslint:disable:max-line-length */
export const PROPERTIES_WRAPPER: string = `
`;
/* tslint:enable */
/* tslint:disable:max-line-length */
@Component({
selector: 'example-property',
template: `
`,
})
/* tslint:enable */
export class ExamplePropertyComponent {
@Output() public valueChange: EventEmitter = new EventEmitter();
@Input() public name: string;
@Input() public type: string;
@Input() public value: any;
@Input() public additional: any;
public addToArrayValue: any;
public addToArray(value: any): void {
this.value.push(value);
this.valueChange.emit(this.value);
}
public updateInArray(value: any, element: any): void {
this.value[( this.value).indexOf(element)] = value;
this.valueChange.emit(this.value);
}
public spliceArray(element: any): void {
this.value.splice(this.value.indexOf(element), 1);
this.valueChange.emit(this.value);
}
public updateLat(value: number) {
this.value.lat = value;
this.value = this.value.clone();
this.valueChange.emit(this.value);
}
public updateLng(value: number) {
this.value.lng = value;
this.value = this.value.clone();
this.valueChange.emit(this.value);
}
public updatePointX(value: number): Point {
this.value.x = value;
this.value = this.value.clone();
return this.value;
}
public updatePointY(value: number): Point {
this.value.y = value;
this.value = this.value.clone();
return this.value;
}
public updateLatLngBoundsSouth(value: number): LatLngBounds {
this.value = new LatLngBounds(
latLng(value, (this.value as LatLngBounds).getWest()),
latLng((this.value as LatLngBounds).getNorth(), (this.value as LatLngBounds).getEast()),
);
return this.value;
}
public updateLatLngBoundsWest(value: number): LatLngBounds {
this.value = new LatLngBounds(
latLng((this.value as LatLngBounds).getSouth(), value),
latLng((this.value as LatLngBounds).getNorth(), (this.value as LatLngBounds).getEast()),
);
return this.value;
}
public updateLatLngBoundsNorth(value: number): LatLngBounds {
this.value = new LatLngBounds(
latLng((this.value as LatLngBounds).getSouth(), (this.value as LatLngBounds).getWest()),
latLng(value, (this.value as LatLngBounds).getEast()),
);
return this.value;
}
public updateLatLngBoundsEast(value: number): LatLngBounds {
this.value = new LatLngBounds(
latLng((this.value as LatLngBounds).getSouth(), (this.value as LatLngBounds).getWest()),
latLng((this.value as LatLngBounds).getNorth(), value),
);
return this.value;
}
public getCRS(value: CRS): string {
switch (value) {
case CRS.EPSG3857:
return 'EPSG3857';
case CRS.EPSG3395:
return 'EPSG3395';
case CRS.EPSG4326:
return 'EPSG4326';
case CRS.Simple:
return 'Simple';
}
}
public setCRS(value: string): CRS {
return CRS[value];
}
}
/* tslint:disable:max-classes-per-file */
@Component({
selector: 'example-properties',
template: PROPERTIES_WRAPPER,
})
export class ExamplePropertiesComponent {
@Output() public propertiesChange: EventEmitter = new EventEmitter();
@Input() public properties: IExampleProperties;
}
/* tslint:disable:max-line-length max-classes-per-file */
@Component({
selector: 'example-header',
template: `
`,
})
export class ExampleHeaderComponent {
@Input() public title: string;
}
/* tslint:enable */
/* tslint:disable:max-line-length max-classes-per-file */
@Component({
selector: 'example-footer',
template: `
`,
})
export class ExampleFooterComponent {}
@NgModule({
declarations: [
ExamplePropertyComponent,
ExamplePropertiesComponent,
ExampleHeaderComponent,
ExampleFooterComponent,
],
exports: [
ExamplePropertyComponent,
ExamplePropertiesComponent,
ExampleHeaderComponent,
ExampleFooterComponent,
],
imports: [
CommonModule,
FormsModule,
],
})
export class ExamplePropertiesModule { }