Skip to content

Commit

Permalink
Add definitely-type OpenLayers typings and use to fix type mismatches
Browse files Browse the repository at this point in the history
  • Loading branch information
maurizi committed Oct 9, 2019
1 parent f41daf9 commit 165630f
Show file tree
Hide file tree
Showing 46 changed files with 203 additions and 156 deletions.
73 changes: 62 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@angular/language-service": "^7.2.12",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/ol": "^5.3.1",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
Expand Down
7 changes: 2 additions & 5 deletions projects/ngx-openlayers/src/lib/attribution.component.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { Component, ElementRef, OnInit } from '@angular/core';
import { Attribution } from 'ol/control';

@Component({
selector: 'aol-attribution',
template: '<ng-content></ng-content>',
})
export class AttributionComponent implements OnInit {
instance: Attribution;
html: string;
label: string;

constructor(private elementRef: ElementRef) {}

ngOnInit() {
this.html = this.elementRef.nativeElement.innerHTML;
this.instance = new Attribution(this);
this.label = this.elementRef.nativeElement.innerHTML;
}
}
5 changes: 2 additions & 3 deletions projects/ngx-openlayers/src/lib/attributions.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AfterViewInit, Component, ContentChildren, Host, QueryList } from '@angular/core';
import { Attribution } from 'ol/control';
import { SourceComponent } from './sources/source.component';
import { AttributionComponent } from './attribution.component';

Expand All @@ -8,7 +7,7 @@ import { AttributionComponent } from './attribution.component';
template: '<ng-content></ng-content>',
})
export class AttributionsComponent implements AfterViewInit {
instance: Array<Attribution>;
instance: Array<string>;

@ContentChildren(AttributionComponent)
attributions: QueryList<AttributionComponent>;
Expand All @@ -18,7 +17,7 @@ export class AttributionsComponent implements AfterViewInit {
/* we can do this at the very end */
ngAfterViewInit() {
if (this.attributions.length) {
this.instance = this.attributions.map(cmp => cmp.instance);
this.instance = this.attributions.map(cmp => cmp.label);
// console.log('setting attributions:', this.instance);
this.source.instance.setAttributions(this.instance);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Component, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';
import { Attribution } from 'ol/control';
import Attribution, { Options as AttributionOptions } from 'ol/control/Attribution';
import { MapComponent } from '../map.component';

@Component({
selector: 'aol-control-attribution',
template: ``,
})
export class ControlAttributionComponent implements OnInit, OnDestroy {
export class ControlAttributionComponent implements OnInit, OnDestroy, AttributionOptions {
public componentType = 'control';
instance: Attribution;
target: Element;
target: HTMLElement;
@Input()
collapsible: boolean;

Expand Down
6 changes: 3 additions & 3 deletions projects/ngx-openlayers/src/lib/controls/control.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, ContentChild, OnDestroy, OnInit } from '@angular/core';
import { Control } from 'ol/control';
import Control, { Options as ControlOptions } from 'ol/control/Control';
import { MapComponent } from '../map.component';
import { ContentComponent } from '../content.component';

Expand All @@ -9,10 +9,10 @@ import { ContentComponent } from '../content.component';
<ng-content></ng-content>
`,
})
export class ControlComponent implements OnInit, OnDestroy {
export class ControlComponent implements OnInit, OnDestroy, ControlOptions {
public componentType = 'control';
instance: Control;
element: Element;
element: HTMLElement;
@ContentChild(ContentComponent)
content: ContentComponent;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnDestroy, OnInit, Input } from '@angular/core';
import { Control, defaults } from 'ol/control';
import { DefaultsOptions } from 'ol/control/util';
import { Collection } from 'ol';
import { Options as AttributionOptions } from 'ol/control/Attribution';
import { Options as RotateOptions } from 'ol/control/Rotate';
Expand All @@ -11,7 +12,7 @@ import { MapComponent } from '../map.component';
selector: 'aol-control-defaults',
template: '',
})
export class DefaultControlComponent implements OnInit, OnDestroy {
export class DefaultControlComponent implements OnInit, OnDestroy, DefaultsOptions {
instance: Collection<Control>;
@Input()
attribution: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { FullScreen } from 'ol/control';
import FullScreen, { Options as FullScreenOptions } from 'ol/control/FullScreen';
import { MapComponent } from '../map.component';

@Component({
Expand All @@ -8,7 +8,7 @@ import { MapComponent } from '../map.component';
<ng-content></ng-content>
`,
})
export class ControlFullScreenComponent implements OnInit, OnDestroy {
export class ControlFullScreenComponent implements OnInit, OnDestroy, FullScreenOptions {
instance: FullScreen;

@Input()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';
import MousePosition from 'ol/control/MousePosition';
import MousePosition, { Options as MousePositionOptions } from 'ol/control/MousePosition';
import { MapComponent } from '../map.component';
import { CoordinateFormat } from 'ol/coordinate';
import { ProjectionLike } from 'ol/proj';
Expand All @@ -8,13 +8,13 @@ import { ProjectionLike } from 'ol/proj';
selector: 'aol-control-mouseposition',
template: ``,
})
export class ControlMousePositionComponent implements OnInit, OnDestroy {
export class ControlMousePositionComponent implements OnInit, OnDestroy, MousePositionOptions {
instance: MousePosition;
@Input()
coordinateFormat: CoordinateFormat;
@Input()
projection: ProjectionLike;
target: Element;
target: HTMLElement;

constructor(private map: MapComponent, private element: ElementRef) {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Input, OnDestroy, OnInit, OnChanges, SimpleChanges } from '@angular/core';
import { Layer } from 'ol/layer';
import { View } from 'ol';
import { OverviewMap } from 'ol/control';
import OverviewMap, { Options as OverviewMapOptions } from 'ol/control/OverviewMap';
import { MapComponent } from '../map.component';

@Component({
Expand All @@ -10,7 +10,7 @@ import { MapComponent } from '../map.component';
<ng-content></ng-content>
`,
})
export class ControlOverviewMapComponent implements OnInit, OnChanges, OnDestroy {
export class ControlOverviewMapComponent implements OnInit, OnChanges, OnDestroy, OverviewMapOptions {
instance: OverviewMap;
@Input()
collapsed: boolean;
Expand All @@ -23,7 +23,7 @@ export class ControlOverviewMapComponent implements OnInit, OnChanges, OnDestroy
@Input()
layers: Layer[];
@Input()
target: Element;
target: HTMLElement;
@Input()
tipLabel: string;
@Input()
Expand Down
Loading

0 comments on commit 165630f

Please sign in to comment.