Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenLayers typings and use to fix type mismatches #259

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@angular/platform-browser": "~9.1.0",
"@angular/platform-browser-dynamic": "~9.1.0",
"@angular/router": "~9.1.0",
"@types/ol": "^6.3.1",
"hammerjs": "^2.0.8",
"ol": "~6.3.1",
"rxjs": "~6.5.4",
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;
}
}
4 changes: 2 additions & 2 deletions projects/ngx-openlayers/src/lib/attributions.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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 +18,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
Expand Up @@ -9,7 +9,7 @@ import { MapComponent } from '../map.component';
export class ControlAttributionComponent implements OnInit, OnDestroy {
public componentType = 'control';
instance: Attribution;
target: Element;
target: HTMLElement;
@Input()
collapsible: boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component, ContentChild, OnDestroy, OnInit } from '@angular/core';
import { Control } from 'ol/control';
import { MapComponent } from '../map.component';
import { ContentComponent } from '../content.component';
import { TileGridComponent } from '../tilegrid.component';

@Component({
selector: 'aol-control',
Expand All @@ -11,7 +10,7 @@ import { TileGridComponent } from '../tilegrid.component';
export class ControlComponent implements OnInit, OnDestroy {
public componentType = 'control';
instance: Control;
element: Element;
element: HTMLElement;
@ContentChild(ContentComponent, { static: true })
content: ContentComponent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ControlMousePositionComponent implements OnInit, OnDestroy {
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
Expand Up @@ -21,7 +21,7 @@ export class ControlOverviewMapComponent implements OnInit, OnChanges, OnDestroy
@Input()
layers: Layer[];
@Input()
target: Element;
target: HTMLElement;
@Input()
tipLabel: string;
@Input()
Expand Down
4 changes: 2 additions & 2 deletions projects/ngx-openlayers/src/lib/controls/zoom.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export class ControlZoomComponent implements OnInit, OnDestroy {
@Input()
duration: number;
@Input()
zoomInLabel: string | Node;
zoomInLabel: string | HTMLElement;
@Input()
zoomOutLabel: string | Node;
zoomOutLabel: string | HTMLElement;
@Input()
zoomInTipLabel: string;
@Input()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ControlZoomToExtentComponent implements OnInit, OnDestroy {
@Input()
className: string;
@Input()
label: string | Node;
label: string | HTMLElement;
@Input()
tipLabel: string;
@Input()
Expand Down
7 changes: 2 additions & 5 deletions projects/ngx-openlayers/src/lib/formats/mvt.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Component, forwardRef, Input } from '@angular/core';
import { FormatComponent } from './format.component';
import { MVT } from 'ol/format';
import { Geometry } from 'ol/geom';
import GeometryType from 'ol/geom/GeometryType';
import { FeatureClass } from 'ol/Feature';

@Component({
selector: 'aol-format-mvt',
Expand All @@ -13,9 +12,7 @@ export class FormatMVTComponent extends FormatComponent {
instance: MVT;

@Input()
featureClass:
| ((geom: Geometry | { [k: string]: any }) => any)
| ((geom: GeometryType, arg2: number[], arg3: number[] | number[][], arg4: { [k: string]: any }) => any);
featureClass: FeatureClass;
@Input()
geometryName: string;
@Input()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { DragAndDrop } from 'ol/interaction';
import Feature from 'ol/format/Feature';
import FeatureFormat from 'ol/format/Feature';
import { MapComponent } from '../map.component';
import { ProjectionLike } from 'ol/proj';

Expand All @@ -12,11 +12,11 @@ export class DragAndDropInteractionComponent implements OnInit, OnDestroy {
instance: DragAndDrop;

@Input()
formatConstructors: ((n: Feature) => any)[];
formatConstructors: FeatureFormat[];
@Input()
projection: ProjectionLike;
@Input()
target: Element;
target: HTMLElement;

constructor(private map: MapComponent) {}

Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-openlayers/src/lib/layers/layer.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OnDestroy, OnInit, OnChanges, Input, SimpleChanges } from '@angular/core';
import { Event } from 'ol/events';
import Event from 'ol/events/Event';
import { MapComponent } from '../map.component';
import { LayerGroupComponent } from './layergroup.component';
import { Extent } from 'ol/extent';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { Extent } from 'ol/extent';
template: ` <ng-content></ng-content> `,
})
export class LayerImageComponent extends LayerComponent implements OnInit, OnChanges {
public source: Image;

@Input()
opacity: number;
@Input()
Expand Down
2 changes: 0 additions & 2 deletions projects/ngx-openlayers/src/lib/layers/layertile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { LayerGroupComponent } from './layergroup.component';
template: ` <ng-content></ng-content> `,
})
export class LayerTileComponent extends LayerComponent implements OnInit, OnDestroy, OnChanges {
public source: Tile;

@Input()
preload: number;
@Input()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { LayerGroupComponent } from './layergroup.component';
template: ` <ng-content></ng-content> `,
})
export class LayerVectorComponent extends LayerComponent implements OnInit, OnDestroy, OnChanges {
public source: Vector;

@Input()
renderBuffer: number;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, Input, Optional, SimpleChanges, OnChanges } from '@angular/core';
import { VectorTile } from 'ol/layer';
import { RenderType } from 'ol/layer/VectorTile';
import VectorTileRenderType from 'ol/layer/VectorTileRenderType';
import { Feature } from 'ol';
import { Style } from 'ol/style';
import { MapComponent } from '../map.component';
Expand All @@ -16,7 +16,7 @@ export class LayerVectorTileComponent extends LayerComponent implements OnInit,
@Input()
renderBuffer: number;
@Input()
renderMode: RenderType | string;
renderMode: VectorTileRenderType | string;
/* not marked as optional in the typings */
@Input()
renderOrder: (feature1: Feature, feature2: Feature) => number;
Expand Down
6 changes: 3 additions & 3 deletions projects/ngx-openlayers/src/lib/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
SimpleChanges,
OnChanges,
} from '@angular/core';
import Map from 'ol/Map';
import { Map } from 'ol';
import MapBrowserEvent from 'ol/MapBrowserEvent';
import MapEvent from 'ol/MapEvent';
import ObjectEvent from 'ol/Object';
import { ObjectEvent } from 'ol/Object';
import RenderEvent from 'ol/render/Event';
import { Control } from 'ol/control';
import { Interaction } from 'ol/interaction';
Expand All @@ -35,7 +35,7 @@ export class MapComponent implements OnInit, AfterViewInit, OnChanges {
@Input()
pixelRatio: number;
@Input()
keyboardEventTarget: Element | string;
keyboardEventTarget: HTMLElement | string;
@Input()
loadTilesWhileAnimating: boolean;
@Input()
Expand Down
6 changes: 3 additions & 3 deletions projects/ngx-openlayers/src/lib/overlay.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, ContentChild, Input, OnDestroy, OnInit } from '@angular/core';
import { MapComponent } from './map.component';
import { Overlay, PanOptions } from 'ol';
import Overlay, { PanOptions } from 'ol/Overlay';
import { ContentComponent } from './content.component';
import OverlayPositioning from 'ol/OverlayPositioning';

Expand All @@ -11,7 +11,7 @@ import OverlayPositioning from 'ol/OverlayPositioning';
export class OverlayComponent implements OnInit, OnDestroy {
componentType = 'overlay';
instance: Overlay;
element: Element;
element: HTMLElement;
@ContentChild(ContentComponent, { static: true })
content: ContentComponent;

Expand All @@ -20,7 +20,7 @@ export class OverlayComponent implements OnInit, OnDestroy {
@Input()
offset: number[];
@Input()
positioning: OverlayPositioning | string;
positioning: OverlayPositioning;
@Input()
stopEvent: boolean;
@Input()
Expand Down
4 changes: 2 additions & 2 deletions projects/ngx-openlayers/src/lib/sources/geojson.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Host, Input, OnInit, forwardRef } from '@angular/core';
import { LayerVectorComponent } from '../layers/layervector.component';
import { SourceComponent } from './source.component';
import { Feature } from 'ol';
import FeatureFormat from 'ol/format/Feature';
import { Vector } from 'ol/source';
import { GeoJSON } from 'ol/format';
import { ProjectionLike } from 'ol/proj';
Expand All @@ -13,7 +13,7 @@ import { ProjectionLike } from 'ol/proj';
})
export class SourceGeoJSONComponent extends SourceComponent implements OnInit {
instance: Vector;
format: Feature;
format: FeatureFormat;
@Input()
defaultDataProjection: ProjectionLike;
@Input()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Output,
SimpleChanges,
} from '@angular/core';
import { ImageArcGISRest } from 'ol/source';
import ImageArcGISRest from 'ol/source/ImageArcGISRest';
import { LayerImageComponent } from '../layers/layerimage.component';
import { SourceComponent } from './source.component';
import { ProjectionLike } from 'ol/proj';
Expand All @@ -27,7 +27,7 @@ export class SourceImageArcGISRestComponent extends SourceComponent implements O

@Input() projection: ProjectionLike | string;
@Input() url: string;
@Input() attributions: AttributionLike[];
@Input() attributions: AttributionLike;
@Input() crossOrigin?: string;
@Input() imageLoadFunction?: LoadFunction;
@Input() params?: { [k: string]: any };
Expand Down
4 changes: 2 additions & 2 deletions projects/ngx-openlayers/src/lib/sources/raster.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Output,
} from '@angular/core';
import { Raster, Source } from 'ol/source';
import { Operation, RasterOperationType, RasterSourceEvent } from 'ol/source/Raster';
import { Operation, RasterSourceEvent } from 'ol/source/Raster';

import { LayerImageComponent } from '../layers/layerimage.component';
import { SourceComponent } from './source.component';
Expand All @@ -34,7 +34,7 @@ export class SourceRasterComponent extends SourceComponent implements AfterConte
@Input()
lib?: any;
@Input()
operationType?: RasterOperationType;
operationType?: 'pixel' | 'image';

@Output()
beforeOperations: EventEmitter<RasterSourceEvent> = new EventEmitter<RasterSourceEvent>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Input, OnDestroy } from '@angular/core';
import { Source } from 'ol';
import Source from 'ol/source/Source';

import { LayerComponent } from '../layers/layer.component';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Host, Input, OnChanges, OnInit, forwardRef, SimpleChanges }
import { LayerTileComponent } from '../layers/layertile.component';
import { SourceComponent } from './source.component';
import { TileWMS } from 'ol/source';
import { TileGrid } from 'ol/tilegrid';
import TileGrid from 'ol/tilegrid/TileGrid';
import { LoadFunction } from 'ol/Tile';

@Component({
Expand Down
4 changes: 2 additions & 2 deletions projects/ngx-openlayers/src/lib/sources/tilewmts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { LayerTileComponent } from '../layers/layertile.component';
import { SourceComponent } from './source.component';
import { TileGridWMTSComponent } from '../tilegridwmts.component';
import { WMTS } from 'ol/source';
import { WMTS as TileGridWMTS } from 'ol/tilegrid';
import { WMTSRequestEncoding } from 'ol/source';
import TileGridWMTS from 'ol/tilegrid/WMTS';
import WMTSRequestEncoding from 'ol/source/WMTSRequestEncoding';
import { ProjectionLike } from 'ol/proj';
import { LoadFunction } from 'ol/Tile';
import { TileSourceEvent } from 'ol/source/Tile';
Expand Down
3 changes: 2 additions & 1 deletion projects/ngx-openlayers/src/lib/sources/utfgrid.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, Host, Input, OnInit, forwardRef } from '@angular/core';
import { SourceComponent } from './source.component';
import { LayerTileComponent } from '../layers/layertile.component';
import { UTFGrid } from 'ol/source';
import { Config } from 'ol/source/TileJSON';

@Component({
selector: 'aol-source-utfgrid',
Expand All @@ -10,7 +11,7 @@ import { UTFGrid } from 'ol/source';
})
export class SourceUTFGridComponent extends SourceComponent implements OnInit {
instance: UTFGrid;
@Input() tileJSON: JSON;
@Input() tileJSON: Config;
@Input() url: string;

constructor(@Host() layer: LayerTileComponent) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Host, Input, forwardRef, ContentChild, AfterContentInit } from '@angular/core';
import { VectorTile } from 'ol';
import { VectorTile } from 'ol/source';
import Feature from 'ol/format/Feature';
import TileGrid from 'ol/tilegrid/TileGrid';
import { LayerVectorTileComponent } from '../layers/layervectortile.component';
Expand Down
4 changes: 1 addition & 3 deletions projects/ngx-openlayers/src/lib/styles/circle.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, Host, AfterContentInit, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
import { AtlasManager, Circle, Fill, Stroke } from 'ol/style';
import { Circle, Fill, Stroke } from 'ol/style';
import { StyleComponent } from './style.component';

@Component({
Expand All @@ -18,8 +18,6 @@ export class StyleCircleComponent implements AfterContentInit, OnChanges, OnDest
snapToPixel: boolean;
@Input()
stroke: Stroke;
@Input()
atlasManager: AtlasManager;

constructor(@Host() private host: StyleComponent) {}

Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-openlayers/src/lib/styles/icon.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class StyleIconComponent implements OnInit, OnChanges {
@Input()
crossOrigin: IconOrigin;
@Input()
img: string;
img: HTMLCanvasElement | HTMLImageElement;
@Input()
offset: [number, number];
@Input()
Expand Down
4 changes: 2 additions & 2 deletions projects/ngx-openlayers/src/lib/styles/stroke.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export class StyleStrokeComponent implements OnInit, OnChanges {
@Input()
color: Color | undefined;
@Input()
lineCap: string | undefined;
lineCap: CanvasLineCap | undefined;
@Input()
lineDash: number[] | undefined;
@Input()
lineJoin: string | undefined;
lineJoin: CanvasLineJoin | undefined;
@Input()
miterLimit: number | undefined;
@Input()
Expand Down
Loading