Skip to content

Commit

Permalink
Optional inputs (#3)
Browse files Browse the repository at this point in the history
* Change how aol-features are found for click handlers

* Mark relevant inputs as optional, add some missing ones

* Bump version
  • Loading branch information
fergaldoyle authored Nov 7, 2024
1 parent 8fd19a1 commit 2d9a2b4
Show file tree
Hide file tree
Showing 23 changed files with 97 additions and 68 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo-ngx-ol",
"version": "18.1.7",
"version": "18.1.8",
"scripts": {
"ng": "ng",
"start": "npm run build:lib && ng serve",
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-ol/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@compassinformatics/ngx-ol",
"version": "18.1.7",
"version": "18.1.8",
"peerDependencies": {
"@angular/common": "^18.1.0",
"@angular/core": "^18.1.0",
Expand Down
17 changes: 13 additions & 4 deletions projects/ngx-ol/src/lib/layers/layer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Event from 'ol/events/Event';
import { MapComponent } from '../map.component';
import { LayerGroupComponent } from './layergroup.component';
import { Extent } from 'ol/extent';
import { RenderFunction } from 'ol/layer/Layer';

@Directive()
// eslint-disable-next-line @angular-eslint/directive-class-suffix
Expand All @@ -16,13 +17,21 @@ export abstract class LayerComponent implements OnInit, OnChanges, OnDestroy {
@Input()
visible: boolean;
@Input()
extent: Extent;
extent?: Extent;
@Input()
zIndex: number;
zIndex?: number;
@Input()
minResolution: number;
minResolution?: number;
@Input()
maxResolution: number;
maxResolution?: number;
@Input()
minZoom?: number;
@Input()
maxZoom?: number;
@Input()
render?: RenderFunction;
@Input()
properties?: Record<string, any>;

@Input()
prerender: (evt: Event) => void;
Expand Down
13 changes: 0 additions & 13 deletions projects/ngx-ol/src/lib/layers/layerimage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@ import { Extent } from 'ol/extent';
template: ` <ng-content></ng-content> `,
})
export class LayerImageComponent extends LayerComponent implements OnInit, OnChanges {
@Input()
opacity: number;
@Input()
visible: boolean;
@Input()
extent: Extent;
@Input()
minResolution: number;
@Input()
maxResolution: number;
@Input()
zIndex: number;

constructor(map: MapComponent, @Optional() group?: LayerGroupComponent) {
super(group || map);
}
Expand Down
2 changes: 2 additions & 0 deletions projects/ngx-ol/src/lib/layers/layertile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class LayerTileComponent extends LayerComponent implements OnInit, OnDest
preload: number;
@Input()
useInterimTilesOnError: boolean;
@Input()
cacheSize: number;

constructor(map: MapComponent, @Optional() group?: LayerGroupComponent) {
super(group || map);
Expand Down
6 changes: 5 additions & 1 deletion projects/ngx-ol/src/lib/layers/layervector.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ import { LayerComponent } from './layer.component';
import { LayerGroupComponent } from './layergroup.component';
import { BackgroundColor } from 'ol/layer/Base';
import { FlatStyleLike } from 'ol/style/flat';
import { OrderFunction } from 'ol/render';

@Component({
selector: 'aol-layer-vector',
template: ` <ng-content></ng-content> `,
})
export class LayerVectorComponent extends LayerComponent implements OnInit, OnDestroy, OnChanges {
@Input()
renderOrder?: OrderFunction;

@Input()
renderBuffer: number;

Expand All @@ -36,7 +40,7 @@ export class LayerVectorComponent extends LayerComponent implements OnInit, OnDe
declutter: boolean | string | number;

@Input()
background: BackgroundColor;
background?: BackgroundColor;

@Input()
properties: Record<string, any>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class LayerVectorImageComponent
declutter: boolean | string | number;

@Input()
background: BackgroundColor;
background?: BackgroundColor;

@Input()
imageRatio: number;
Expand Down
5 changes: 4 additions & 1 deletion projects/ngx-ol/src/lib/layers/layervectortile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { LayerComponent } from './layer.component';
import { LayerGroupComponent } from './layergroup.component';
import { StyleLike } from 'ol/style/Style';
import { Options } from 'ol/source/VectorTile';
import { BackgroundColor } from 'ol/layer/Base';

@Component({
selector: 'aol-layer-vectortile',
Expand All @@ -18,10 +19,12 @@ export class LayerVectorTileComponent extends LayerComponent implements OnInit,
renderMode: any | string;
/* not marked as optional in the typings */
@Input()
renderOrder: (feature1: Feature, feature2: Feature) => number;
renderOrder?: (feature1: Feature, feature2: Feature) => number;
@Input()
style: StyleLike | null | undefined;
@Input()
background?: BackgroundColor;
@Input()
updateWhileAnimating: boolean;
@Input()
updateWhileInteracting: boolean;
Expand Down
4 changes: 2 additions & 2 deletions projects/ngx-ol/src/lib/overlay.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class OverlayComponent implements OnInit, OnDestroy, OnChanges {
content: ContentComponent;

@Input()
id: number | string;
id: number | string | undefined;
@Input()
offset: number[];
@Input()
Expand All @@ -37,7 +37,7 @@ export class OverlayComponent implements OnInit, OnDestroy, OnChanges {
@Input()
autoPanMargin: number;
@Input()
position: Coordinate;
position: Coordinate | undefined;

componentType = 'overlay';
instance: Overlay;
Expand Down
13 changes: 11 additions & 2 deletions projects/ngx-ol/src/lib/sources/bingmaps.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BingMaps } from 'ol/source';
import { SourceComponent } from './source.component';
import { LayerTileComponent } from '../layers/layertile.component';
import { LoadFunction } from 'ol/Tile';
import { NearestDirectionFunction } from 'ol/array';

@Component({
selector: 'aol-source-bingmaps',
Expand All @@ -11,7 +12,7 @@ import { LoadFunction } from 'ol/Tile';
})
export class SourceBingmapsComponent extends SourceComponent implements OnInit {
@Input()
cacheSize: number;
cacheSize?: number;
@Input()
hidpi: boolean;
@Input()
Expand All @@ -25,9 +26,17 @@ export class SourceBingmapsComponent extends SourceComponent implements OnInit {
@Input()
reprojectionErrorThreshold: number;
@Input()
tileLoadFunction: LoadFunction;
tileLoadFunction?: LoadFunction;
@Input()
wrapX: boolean;
@Input()
interpolate: boolean;
@Input()
placeholderTiles?: boolean;
@Input()
transition?: number;
@Input()
zDirection: number | NearestDirectionFunction;

instance: BingMaps;

Expand Down
4 changes: 4 additions & 0 deletions projects/ngx-ol/src/lib/sources/cluster.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ export class SourceClusterComponent extends SourceComponent implements AfterCont
@Input()
distance: number;
@Input()
minDistance: number;
@Input()
geometryFunction?: (feature: Feature) => Point;
@Input()
wrapX?: boolean;
@Input()
createCluster: any;

@ContentChild(SourceVectorComponent, { static: false })
sourceVectorComponent: SourceVectorComponent;
Expand Down
7 changes: 4 additions & 3 deletions projects/ngx-ol/src/lib/sources/imagearcgisrest.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ import { ImageSourceEvent } from 'ol/source/Image';
],
})
export class SourceImageArcGISRestComponent extends SourceComponent implements OnInit, OnChanges {
@Input() projection: ProjectionLike | string;
@Input() url: string;
@Input() projection?: ProjectionLike | string;
@Input() url?: string;
@Input() attributions: AttributionLike;
@Input() crossOrigin?: string;
@Input() crossOrigin?: string | null;
@Input() imageLoadFunction?: LoadFunction;
@Input() interpolate: boolean;
@Input() params?: { [k: string]: any };
@Input() ratio = 1.5;
@Input() resolutions?: number[];
Expand Down
8 changes: 3 additions & 5 deletions projects/ngx-ol/src/lib/sources/imagestatic.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@ import { ImageSourceEvent } from 'ol/source/Image';
})
export class SourceImageStaticComponent extends SourceComponent implements OnInit, OnChanges {
@Input()
projection: ProjectionLike | string;
projection?: ProjectionLike | string;
@Input()
imageExtent: Extent;
@Input()
url: string;
@Input()
attributions: AttributionLike;
@Input()
crossOrigin?: string;
crossOrigin?: null | string;
@Input()
imageLoadFunction?: LoadFunction;
@Input()
imageSize?: Size;
interpolate: boolean;

@Output()
imageLoadStart = new EventEmitter<ImageSourceEvent>();
Expand Down
14 changes: 8 additions & 6 deletions projects/ngx-ol/src/lib/sources/imagewms.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,25 @@ export class SourceImageWMSComponent extends SourceComponent implements OnChange
@Input()
attributions: AttributionLike;
@Input()
crossOrigin: string;
crossOrigin?: null | string;
@Input()
hidpi: boolean;
@Input()
serverType: ServerType;
serverType?: ServerType;
@Input()
imageLoadFunction?: LoadFunction;
@Input()
params: { [key: string]: any };
interpolate: boolean;
@Input()
projection: ProjectionLike | string;
params?: { [key: string]: any };
@Input()
projection?: ProjectionLike | string;
@Input()
ratio: number;
@Input()
resolutions: Array<number>;
resolutions?: Array<number>;
@Input()
url: string;
url?: string;

@Output()
imageLoadStart = new EventEmitter<ImageSourceEvent>();
Expand Down
8 changes: 7 additions & 1 deletion projects/ngx-ol/src/lib/sources/osm.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,23 @@ export class SourceOsmComponent extends SourceXYZComponent implements AfterConte
@Input()
crossOrigin: string;
@Input()
interpolate: boolean;
@Input()
maxZoom: number;
@Input()
opaque: boolean;
@Input()
reprojectionErrorThreshold: number;
@Input()
tileLoadFunction: LoadFunction;
tileLoadFunction?: LoadFunction;
@Input()
transition: number;
@Input()
url: string;
@Input()
wrapX: boolean;
@Input()
zDirection: number;

@Output()
tileLoadStart = new EventEmitter<TileSourceEvent>();
Expand Down
2 changes: 2 additions & 0 deletions projects/ngx-ol/src/lib/sources/raster.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export class SourceRasterComponent extends SourceComponent implements AfterConte
lib?: any;
@Input()
operationType?: 'pixel' | 'image';
@Input()
resolutions?: number[] | null;

@Output()
beforeOperations = new EventEmitter<RasterSourceEvent>();
Expand Down
12 changes: 6 additions & 6 deletions projects/ngx-ol/src/lib/sources/tilewms.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ export class SourceTileWMSComponent extends SourceComponent implements OnChanges
@Input()
cacheSize: number;
@Input()
crossOrigin: string;
crossOrigin?: null | string;
@Input()
gutter: number;
@Input()
hidpi: boolean;
@Input()
params: { [key: string]: any };
@Input()
projection: string;
projection?: string;
@Input()
reprojectionErrorThreshold: number;
@Input()
serverType: ServerType;
serverType?: ServerType;
@Input()
tileGrid: TileGrid;
tileGrid?: TileGrid;
@Input()
tileLoadFunction: LoadFunction;
tileLoadFunction?: LoadFunction;
@Input()
url: string;
url?: string;
@Input()
urls: string[];
@Input()
Expand Down
4 changes: 2 additions & 2 deletions projects/ngx-ol/src/lib/sources/tilewmts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export class SourceTileWMTSComponent
@Input()
cacheSize?: number;
@Input()
crossOrigin?: string;
crossOrigin?: null | string;
@Input()
tileGrid: WMTS;
@Input()
projection: ProjectionLike;
projection?: ProjectionLike;
@Input()
reprojectionErrorThreshold?: number;
@Input()
Expand Down
4 changes: 2 additions & 2 deletions projects/ngx-ol/src/lib/sources/utfgrid.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { Config } from 'ol/source/TileJSON';
providers: [{ provide: SourceComponent, useExisting: forwardRef(() => SourceUTFGridComponent) }],
})
export class SourceUTFGridComponent extends SourceComponent implements OnInit {
@Input() tileJSON: Config;
@Input() url: string;
@Input() tileJSON?: Config;
@Input() url?: string;

instance: UTFGrid;

Expand Down
Loading

0 comments on commit 2d9a2b4

Please sign in to comment.