From d306d5c4c10f7ae8977edb026e4a548f1f1ee4d2 Mon Sep 17 00:00:00 2001 From: Peter Bastiani Date: Tue, 9 Apr 2024 10:58:42 +0200 Subject: [PATCH] AW-6046 Angular 17 --- .gitignore | 2 +- Jenkinsfile.develop | 2 +- angular.json | 22 +- package.json | 2 +- .../src/fm-map/common-map.module.ts | 228 +++++++++--------- .../file-drop-target.component.ts | 2 +- .../gps-location/gps-location.component.ts | 2 +- .../aol/item-layers/item-layers.component.ts | 2 +- .../item-vector-source.component.ts | 2 +- .../layer-values/layer-values.component.ts | 2 +- .../layer-vector-image.component.ts | 2 +- .../pan-to-location.component.ts | 2 +- .../rotation-reset.component.ts | 2 +- .../zoom-to-extent.component.ts | 2 +- .../if-zoom-to-show.directive.ts | 2 +- .../olcs/switch2d3d/switch2d3d.component.ts | 2 +- .../.eslintrc.json | 6 +- projects/ng-openlayers/.gitignore | 2 + projects/ng-openlayers/karma.conf.js | 32 +++ .../ng-package.json | 2 +- projects/ng-openlayers/ngcc.config.js | 3 + projects/ng-openlayers/package-lock.json | 33 +++ projects/ng-openlayers/package.json | 39 +++ projects/ng-openlayers/project.json | 38 +++ .../src/lib/attribution.component.ts | 7 +- .../src/lib/attributions.component.ts | 7 +- .../lib/collectioncoordinates.component.ts | 12 +- .../src/lib/content.component.ts | 0 .../src/lib/controls/attribution.component.ts | 9 +- .../src/lib/controls/control.component.ts | 6 +- .../src/lib/controls/default.component.ts | 4 +- .../src/lib/controls/fullscreen.component.ts | 0 .../lib/controls/mouseposition.component.ts | 9 +- .../src/lib/controls/overviewmap.component.ts | 6 +- .../src/lib/controls/rotate.component.ts | 0 .../src/lib/controls/scaleline.component.ts | 8 +- .../src/lib/controls/zoom.component.ts | 4 +- .../src/lib/controls/zoomslider.component.ts | 0 .../lib/controls/zoomtoextent.component.ts | 4 +- .../src/lib/coordinate.component.ts | 8 +- .../src/lib/feature.component.ts | 6 +- .../src/lib/formats/format.component.ts | 0 .../src/lib/formats/mvt.component.ts | 9 +- .../src/lib/geom/geometrycircle.component.ts | 22 +- .../lib/geom/geometrylinestring.component.ts | 0 .../geom/geometrymultilinestring.component.ts | 0 .../lib/geom/geometrymultipoint.component.ts | 0 .../geom/geometrymultipolygon.component.ts | 0 .../src/lib/geom/geometrypoint.component.ts | 0 .../src/lib/geom/geometrypolygon.component.ts | 0 .../src/lib/geom/simplegeometry.component.ts | 14 +- .../src/lib/graticule.component.ts | 4 +- .../src/lib/interactions/default.component.ts | 27 ++- .../interactions/doubleclickzoom.component.ts | 0 .../lib/interactions/draganddrop.component.ts | 8 +- .../src/lib/interactions/dragbox.component.ts | 6 +- .../src/lib/interactions/dragpan.component.ts | 6 +- .../lib/interactions/dragrotate.component.ts | 4 +- .../dragrotateandzoom.component.ts | 4 +- .../lib/interactions/dragzoom.component.ts | 4 +- .../src/lib/interactions/draw.component.ts | 30 ++- .../lib/interactions/keyboardpan.component.ts | 27 +++ .../interactions/keyboardzoom.component.ts | 27 +++ .../src/lib/interactions/modify.component.ts | 42 ++-- .../interactions/mousewheelzoom.component.ts | 0 .../lib/interactions/pinchzoom.component.ts | 2 +- .../src/lib/interactions/select.component.ts | 27 ++- .../lib/interactions/translate.component.ts | 36 +-- .../src/lib/layers/layer.component.ts | 13 +- .../src/lib/layers/layergroup.component.ts | 0 .../src/lib/layers/layerimage.component.ts | 4 +- .../src/lib/layers/layertile.component.ts | 4 +- .../src/lib/layers/layervector.component.ts | 6 +- .../lib/layers/layervectortile.component.ts | 3 +- .../ng-openlayers/src/lib/map.component.ts | 142 +++++++++++ .../src/lib/overlay.component.ts | 9 +- .../src/lib/sources/bingmaps.component.ts | 4 +- .../src/lib/sources/cluster.component.ts | 5 +- .../src/lib/sources/geojson.component.ts | 10 +- .../lib/sources/imagearcgisrest.component.ts | 12 +- .../src/lib/sources/imagestatic.component.ts | 24 +- .../src/lib/sources/imagewms.component.ts | 3 +- .../src/lib/sources/osm.component.ts | 10 +- .../src/lib/sources/raster.component.ts | 20 +- .../src/lib/sources/source.component.ts | 9 +- .../src/lib/sources/tilejson.component.ts | 0 .../src/lib/sources/tilewms.component.ts | 5 +- .../src/lib/sources/tilewmts.component.ts | 22 +- .../src/lib/sources/utfgrid.component.ts | 3 +- .../src/lib/sources/vector.component.ts | 0 .../src/lib/sources/vectortile.component.ts | 9 +- .../src/lib/sources/xyz.component.ts | 10 +- .../src/lib/styles/circle.component.ts | 8 +- .../src/lib/styles/fill.component.ts | 8 +- .../src/lib/styles/icon.component.ts | 11 +- .../src/lib/styles/stroke.component.ts | 10 +- .../src/lib/styles/style.component.ts | 6 +- .../src/lib/styles/text.component.ts | 8 +- .../src/lib/tilegrid.component.ts | 0 .../src/lib/tilegridwmts.component.ts | 2 +- .../src/lib/view.component.ts | 27 ++- .../src/public-api.ts | 6 +- .../src/test.ts | 3 +- projects/ng-openlayers/tsconfig.lib.json | 27 +++ projects/ng-openlayers/tsconfig.lib.prod.json | 9 + .../tsconfig.spec.json | 4 +- projects/ng-openlayers/tslint-prettier.json | 7 + projects/ngx-openlayers/ngcc.config.js | 3 - projects/ngx-openlayers/package-lock.json | 17 -- projects/ngx-openlayers/package.json | 12 - .../ngx-openlayers/src/lib/map.component.ts | 122 ---------- projects/ngx-openlayers/tsconfig.lib.json | 39 --- .../ngx-openlayers/tsconfig.lib.prod.json | 39 --- tsconfig.base.json | 39 +++ tsconfig.json | 4 +- 115 files changed, 904 insertions(+), 656 deletions(-) rename projects/{ngx-openlayers => ng-openlayers}/.eslintrc.json (84%) create mode 100644 projects/ng-openlayers/.gitignore create mode 100644 projects/ng-openlayers/karma.conf.js rename projects/{ngx-openlayers => ng-openlayers}/ng-package.json (79%) create mode 100644 projects/ng-openlayers/ngcc.config.js create mode 100644 projects/ng-openlayers/package-lock.json create mode 100644 projects/ng-openlayers/package.json create mode 100644 projects/ng-openlayers/project.json rename projects/{ngx-openlayers => ng-openlayers}/src/lib/attribution.component.ts (60%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/attributions.component.ts (84%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/collectioncoordinates.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/content.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/controls/attribution.component.ts (83%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/controls/control.component.ts (93%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/controls/default.component.ts (94%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/controls/fullscreen.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/controls/mouseposition.component.ts (89%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/controls/overviewmap.component.ts (93%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/controls/rotate.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/controls/scaleline.component.ts (75%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/controls/zoom.component.ts (91%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/controls/zoomslider.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/controls/zoomtoextent.component.ts (96%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/coordinate.component.ts (96%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/feature.component.ts (85%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/formats/format.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/formats/mvt.component.ts (68%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/geom/geometrycircle.component.ts (91%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/geom/geometrylinestring.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/geom/geometrymultilinestring.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/geom/geometrymultipoint.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/geom/geometrymultipolygon.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/geom/geometrypoint.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/geom/geometrypolygon.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/geom/simplegeometry.component.ts (52%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/graticule.component.ts (89%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/default.component.ts (52%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/doubleclickzoom.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/draganddrop.component.ts (86%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/dragbox.component.ts (91%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/dragpan.component.ts (91%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/dragrotate.component.ts (90%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/dragrotateandzoom.component.ts (91%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/dragzoom.component.ts (91%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/draw.component.ts (69%) create mode 100644 projects/ng-openlayers/src/lib/interactions/keyboardpan.component.ts create mode 100644 projects/ng-openlayers/src/lib/interactions/keyboardzoom.component.ts rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/modify.component.ts (56%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/mousewheelzoom.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/pinchzoom.component.ts (90%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/select.component.ts (69%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/interactions/translate.component.ts (53%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/layers/layer.component.ts (83%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/layers/layergroup.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/layers/layerimage.component.ts (98%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/layers/layertile.component.ts (86%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/layers/layervector.component.ts (88%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/layers/layervectortile.component.ts (93%) create mode 100644 projects/ng-openlayers/src/lib/map.component.ts rename projects/{ngx-openlayers => ng-openlayers}/src/lib/overlay.component.ts (86%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/bingmaps.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/cluster.component.ts (95%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/geojson.component.ts (93%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/imagearcgisrest.component.ts (95%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/imagestatic.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/imagewms.component.ts (96%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/osm.component.ts (85%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/raster.component.ts (78%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/source.component.ts (61%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/tilejson.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/tilewms.component.ts (91%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/tilewmts.component.ts (82%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/utfgrid.component.ts (90%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/vector.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/vectortile.component.ts (90%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/sources/xyz.component.ts (88%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/styles/circle.component.ts (90%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/styles/fill.component.ts (90%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/styles/icon.component.ts (85%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/styles/stroke.component.ts (91%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/styles/style.component.ts (90%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/styles/text.component.ts (94%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/tilegrid.component.ts (100%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/tilegridwmts.component.ts (95%) rename projects/{ngx-openlayers => ng-openlayers}/src/lib/view.component.ts (76%) rename projects/{ngx-openlayers => ng-openlayers}/src/public-api.ts (97%) rename projects/{ngx-openlayers => ng-openlayers}/src/test.ts (86%) create mode 100644 projects/ng-openlayers/tsconfig.lib.json create mode 100644 projects/ng-openlayers/tsconfig.lib.prod.json rename projects/{ngx-openlayers => ng-openlayers}/tsconfig.spec.json (69%) create mode 100644 projects/ng-openlayers/tslint-prettier.json delete mode 100644 projects/ngx-openlayers/ngcc.config.js delete mode 100644 projects/ngx-openlayers/package-lock.json delete mode 100644 projects/ngx-openlayers/package.json delete mode 100644 projects/ngx-openlayers/src/lib/map.component.ts delete mode 100644 projects/ngx-openlayers/tsconfig.lib.json delete mode 100644 projects/ngx-openlayers/tsconfig.lib.prod.json create mode 100644 tsconfig.base.json diff --git a/.gitignore b/.gitignore index 0958d60..d72afb6 100644 --- a/.gitignore +++ b/.gitignore @@ -51,5 +51,5 @@ projects/common-map/node_modules/ .angular/* projects/common-map3d/node_modules/ projects/common-map/node_modules/ -projects/ngx-openlayers/node_modules/ +projects/ng-openlayers/node_modules/ projects/common/node_modules/ diff --git a/Jenkinsfile.develop b/Jenkinsfile.develop index a01ee2e..4f59b33 100644 --- a/Jenkinsfile.develop +++ b/Jenkinsfile.develop @@ -21,4 +21,4 @@ pipeline { postAlways(); } } -} \ No newline at end of file +}c \ No newline at end of file diff --git a/angular.json b/angular.json index 6d06409..948b96a 100644 --- a/angular.json +++ b/angular.json @@ -254,38 +254,38 @@ } } }, - "ngx-openlayers": { + "ng-openlayers": { "projectType": "library", - "root": "projects/ngx-openlayers", - "sourceRoot": "projects/ngx-openlayers/src", + "root": "projects/ng-openlayers", + "sourceRoot": "projects/ng-openlayers/src", "prefix": "lib", "architect": { "build": { "builder": "@angular-devkit/build-angular:ng-packagr", "options": { - "tsConfig": "projects/ngx-openlayers/tsconfig.lib.json", - "project": "projects/ngx-openlayers/ng-package.json" + "tsConfig": "projects/ng-openlayers/tsconfig.lib.json", + "project": "projects/ng-openlayers/ng-package.json" }, "configurations": { "production": { - "tsConfig": "projects/ngx-openlayers/tsconfig.lib.prod.json" + "tsConfig": "projects/ng-openlayers/tsconfig.lib.prod.json" } } }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { - "main": "projects/ngx-openlayers/src/test.ts", - "tsConfig": "projects/ngx-openlayers/tsconfig.spec.json", - "karmaConfig": "projects/ngx-openlayers/karma.conf.js" + "main": "projects/ng-openlayers/src/test.ts", + "tsConfig": "projects/ng-openlayers/tsconfig.spec.json", + "karmaConfig": "projects/ng-openlayers/karma.conf.js" } }, "lint": { "builder": "@angular-eslint/builder:lint", "options": { "lintFilePatterns": [ - "projects/ngx-openlayers/**/*.ts", - "projects/ngx-openlayers/**/*.html" + "projects/ng-openlayers/**/*.ts", + "projects/ng-openlayers/**/*.html" ] } } diff --git a/package.json b/package.json index 48de1a4..edd8469 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@farmmaps/common": "file:dist/common", "@farmmaps/common-map": "file:dist/common-map", "@farmmaps/common-map3d": "file:dist/common-map3d", - "ngx-openlayers": "file:dist/ngx-openlayers", + "ng-openlayers": "file:dist/ng-openlayers", "@microsoft/signalr": "^3.1.16", "@ng-bootstrap/ng-bootstrap": "^15.0.0", "@ngrx/effects": "^16", diff --git a/projects/common-map/src/fm-map/common-map.module.ts b/projects/common-map/src/fm-map/common-map.module.ts index d3b0dee..56a85c8 100644 --- a/projects/common-map/src/fm-map/common-map.module.ts +++ b/projects/common-map/src/fm-map/common-map.module.ts @@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; //external modules -import { AngularOpenlayersModule } from 'ngx-openlayers'; +import { AngularOpenlayersModule } from 'ng-openlayers'; import { StoreModule, ActionReducer, MetaReducer } from '@ngrx/store'; import { EffectsModule } from '@ngrx/effects'; import { NgbModule } from "@ng-bootstrap/ng-bootstrap"; @@ -169,119 +169,119 @@ export { GeometryThumbnailComponent } -@NgModule({ - imports: [ - CommonModule, - AngularOpenlayersModule, - MapRoutingModule, - StoreModule.forFeature(MODULE_NAME, mapReducers.reducer, { metaReducers: metaReducers }), - EffectsModule.forFeature([mapEffects.MapEffects]), - NgbModule, - FormsModule, - ReactiveFormsModule, - AppCommonModule - ], - declarations: [ - ZoomToExtentComponent, - ItemVectorSourceComponent, - ItemLayersComponent, - FileDropTargetComponent, - MapComponent, - MetaDataModalComponent, - RotationResetComponent, - MapSearchComponent, - SelectPeriodModalComponent, - LayerListComponent, - LegendComponent, - LayerVectorImageComponent, - FeatureListComponent, - WidgetHostDirective, - FeatureListContainerComponent, - FeatureListCroppingschemeComponent, - FeatureListCropfieldComponent, - FeatureListFeatureContainerComponent, - FeatureListFeatureComponent, - FeatureListFeatureCroppingschemeComponent, - FeatureListFeatureCropfieldComponent, - SelectedItemContainerComponent, - SelectedItemComponent, - SelectedItemCropfieldComponent, - SelectedItemGeotiffComponent, - SelectedItemTemporalComponent, - SelectedItemShapeComponent, - ItemListItemComponent, - ItemListItemContainerComponent, - ItemListComponent, - ItemWidgetListComponent, - WidgetStatusComponent, - GpsLocation, - PanToLocation, - LayerSwitcher, - HistogramDetailsComponent, - StatisticsDetailsComponent, - ifZoomToShowDirective, - ZoomToShowAlert, - LayerValuesComponent, - GeometryThumbnailComponent - ], - exports: [ - ItemVectorSourceComponent, - ItemLayersComponent, - FileDropTargetComponent, - MetaDataModalComponent, - MapComponent, - GpsLocation, - PanToLocation, - LayerSwitcher, - FeatureListFeatureComponent, - FeatureListFeatureCropfieldComponent, - FeatureListFeatureCroppingschemeComponent, - SelectedItemContainerComponent, - SelectedItemComponent, - SelectedItemCropfieldComponent, - SelectedItemGeotiffComponent, - SelectedItemTemporalComponent, - SelectedItemShapeComponent, - ItemListItemComponent, - ItemListItemContainerComponent, - ItemListComponent, - ItemWidgetListComponent, - WidgetStatusComponent, - RotationResetComponent, - MapSearchComponent, - SelectPeriodModalComponent, - LayerListComponent, - LegendComponent, - LayerVectorImageComponent, - FeatureListComponent, - WidgetHostDirective, - FeatureListContainerComponent, - FeatureListCroppingschemeComponent, - FeatureListCropfieldComponent, - FeatureListFeatureContainerComponent, - ZoomToExtentComponent, - ifZoomToShowDirective, - ZoomToShowAlert, - GeometryThumbnailComponent - ], - providers: [ - FeatureIconService, - GeolocationService, - DeviceOrientationService, - TemporalService, - { provide: AbstractFeatureListComponent, useClass: FeatureListCroppingschemeComponent, multi: true }, - { provide: AbstractFeatureListComponent, useClass: FeatureListCropfieldComponent, multi: true }, - { provide: AbstractFeatureListFeatureComponent, useClass: FeatureListFeatureComponent, multi: true }, - { provide: AbstractFeatureListFeatureComponent, useClass: FeatureListFeatureCroppingschemeComponent, multi: true }, - { provide: AbstractFeatureListFeatureComponent, useClass: FeatureListFeatureCropfieldComponent, multi: true }, - { provide: AbstractSelectedItemComponent, useClass: SelectedItemComponent, multi: true }, - { provide: AbstractSelectedItemComponent, useClass: SelectedItemCropfieldComponent, multi: true }, - { provide: AbstractSelectedItemComponent, useClass: SelectedItemGeotiffComponent, multi: true }, - { provide: AbstractSelectedItemComponent, useClass: SelectedItemTemporalComponent, multi: true }, - { provide: AbstractSelectedItemComponent, useClass: SelectedItemShapeComponent, multi: true }, - { provide: AbstractItemListItemComponent, useClass: ItemListItemComponent, multi: true }, - { provide: AbstractItemListComponent, useClass: ItemListComponent, multi: true } - ] +@NgModule({ + imports: [ + CommonModule, + AngularOpenlayersModule, + MapRoutingModule, + StoreModule.forFeature(MODULE_NAME, mapReducers.reducer, { metaReducers: metaReducers }), + EffectsModule.forFeature([mapEffects.MapEffects]), + NgbModule, + FormsModule, + ReactiveFormsModule, + AppCommonModule + ], + declarations: [ + ZoomToExtentComponent, + ItemVectorSourceComponent, + ItemLayersComponent, + FileDropTargetComponent, + MapComponent, + MetaDataModalComponent, + RotationResetComponent, + MapSearchComponent, + SelectPeriodModalComponent, + LayerListComponent, + LegendComponent, + LayerVectorImageComponent, + FeatureListComponent, + WidgetHostDirective, + FeatureListContainerComponent, + FeatureListCroppingschemeComponent, + FeatureListCropfieldComponent, + FeatureListFeatureContainerComponent, + FeatureListFeatureComponent, + FeatureListFeatureCroppingschemeComponent, + FeatureListFeatureCropfieldComponent, + SelectedItemContainerComponent, + SelectedItemComponent, + SelectedItemCropfieldComponent, + SelectedItemGeotiffComponent, + SelectedItemTemporalComponent, + SelectedItemShapeComponent, + ItemListItemComponent, + ItemListItemContainerComponent, + ItemListComponent, + ItemWidgetListComponent, + WidgetStatusComponent, + GpsLocation, + PanToLocation, + LayerSwitcher, + HistogramDetailsComponent, + StatisticsDetailsComponent, + ifZoomToShowDirective, + ZoomToShowAlert, + LayerValuesComponent, + GeometryThumbnailComponent + ], + exports: [ + ItemVectorSourceComponent, + ItemLayersComponent, + FileDropTargetComponent, + MetaDataModalComponent, + MapComponent, + GpsLocation, + PanToLocation, + LayerSwitcher, + FeatureListFeatureComponent, + FeatureListFeatureCropfieldComponent, + FeatureListFeatureCroppingschemeComponent, + SelectedItemContainerComponent, + SelectedItemComponent, + SelectedItemCropfieldComponent, + SelectedItemGeotiffComponent, + SelectedItemTemporalComponent, + SelectedItemShapeComponent, + ItemListItemComponent, + ItemListItemContainerComponent, + ItemListComponent, + ItemWidgetListComponent, + WidgetStatusComponent, + RotationResetComponent, + MapSearchComponent, + SelectPeriodModalComponent, + LayerListComponent, + LegendComponent, + LayerVectorImageComponent, + FeatureListComponent, + WidgetHostDirective, + FeatureListContainerComponent, + FeatureListCroppingschemeComponent, + FeatureListCropfieldComponent, + FeatureListFeatureContainerComponent, + ZoomToExtentComponent, + ifZoomToShowDirective, + ZoomToShowAlert, + GeometryThumbnailComponent + ], + providers: [ + FeatureIconService, + GeolocationService, + DeviceOrientationService, + TemporalService, + { provide: AbstractFeatureListComponent, useClass: FeatureListCroppingschemeComponent, multi: true }, + { provide: AbstractFeatureListComponent, useClass: FeatureListCropfieldComponent, multi: true }, + { provide: AbstractFeatureListFeatureComponent, useClass: FeatureListFeatureComponent, multi: true }, + { provide: AbstractFeatureListFeatureComponent, useClass: FeatureListFeatureCroppingschemeComponent, multi: true }, + { provide: AbstractFeatureListFeatureComponent, useClass: FeatureListFeatureCropfieldComponent, multi: true }, + { provide: AbstractSelectedItemComponent, useClass: SelectedItemComponent, multi: true }, + { provide: AbstractSelectedItemComponent, useClass: SelectedItemCropfieldComponent, multi: true }, + { provide: AbstractSelectedItemComponent, useClass: SelectedItemGeotiffComponent, multi: true }, + { provide: AbstractSelectedItemComponent, useClass: SelectedItemTemporalComponent, multi: true }, + { provide: AbstractSelectedItemComponent, useClass: SelectedItemShapeComponent, multi: true }, + { provide: AbstractItemListItemComponent, useClass: ItemListItemComponent, multi: true }, + { provide: AbstractItemListComponent, useClass: ItemListComponent, multi: true } + ] }) diff --git a/projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts b/projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts index c1f72ea..43d76af 100644 --- a/projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts +++ b/projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts @@ -1,5 +1,5 @@ import { Component, Input, OnDestroy, OnInit, EventEmitter, Output, Inject } from '@angular/core'; -import { MapComponent } from 'ngx-openlayers'; +import { MapComponent } from 'ng-openlayers'; import * as proj from 'ol/proj'; import {Point,Geometry} from 'ol/geom'; diff --git a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts b/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts index cd74db8..af1dceb 100644 --- a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts +++ b/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, Input, ViewChild, ElementRef, OnChanges, SimpleChanges ,Host} from '@angular/core'; -import { MapComponent } from 'ngx-openlayers'; +import { MapComponent } from 'ng-openlayers'; import Overlay from 'ol/Overlay'; import { fromLonLat, toLonLat } from 'ol/proj'; diff --git a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts b/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts index 819fe3c..8d950e0 100644 --- a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts +++ b/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts @@ -1,5 +1,5 @@ import { Component, Host, Input, Output, EventEmitter,OnDestroy, OnInit, OnChanges, SimpleChanges, forwardRef } from '@angular/core'; -import { LayerGroupComponent, MapComponent } from 'ngx-openlayers'; +import { LayerGroupComponent, MapComponent } from 'ng-openlayers'; import { ItemService,IItem,AppConfig } from '@farmmaps/common'; import { IItemLayer, ITemporalItemLayer} from '../../../models/item.layer'; import { ILayerData} from '../../../models/layer.data'; diff --git a/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts b/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts index 4e9d85c..ff46d46 100644 --- a/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts +++ b/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts @@ -1,5 +1,5 @@ import { Component, Host, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges, forwardRef, Inject, InjectionToken, OnDestroy, LOCALE_ID } from '@angular/core'; -import { LayerVectorComponent, SourceVectorComponent, MapComponent } from 'ngx-openlayers'; +import { LayerVectorComponent, SourceVectorComponent, MapComponent } from 'ng-openlayers'; import { ItemService, ItemTypeService, IItem, IItemType, FolderService } from '@farmmaps/common'; import { Feature } from 'ol'; diff --git a/projects/common-map/src/fm-map/components/aol/layer-values/layer-values.component.ts b/projects/common-map/src/fm-map/components/aol/layer-values/layer-values.component.ts index 84d30ce..c56e989 100644 --- a/projects/common-map/src/fm-map/components/aol/layer-values/layer-values.component.ts +++ b/projects/common-map/src/fm-map/components/aol/layer-values/layer-values.component.ts @@ -3,7 +3,7 @@ import { IItemLayer } from '../../../models/item.layer'; import { Store } from '@ngrx/store'; import * as mapReducers from '../../../reducers/map.reducer'; import * as mapActions from '../../../actions/map.actions'; -import { MapComponent } from 'ngx-openlayers'; +import { MapComponent } from 'ng-openlayers'; import { ILayervalue } from '../../../models/layer.value'; import { Observable, interval, Subject } from 'rxjs'; import { debounce, throttle } from 'rxjs/operators'; diff --git a/projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts b/projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts index 649e30b..4e83edd 100644 --- a/projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts +++ b/projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts @@ -1,5 +1,5 @@ import { Component, OnDestroy, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core'; -import { LayerVectorComponent, MapComponent } from 'ngx-openlayers'; +import { LayerVectorComponent, MapComponent } from 'ng-openlayers'; import RenderType from 'ol/layer/Vector'; import { Vector as VectorSource } from 'ol/source'; import { Geometry } from 'ol/geom'; diff --git a/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.ts b/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.ts index 302516c..969f367 100644 --- a/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.ts +++ b/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, Input, Host, OnChanges, SimpleChanges,ChangeDetectorRef } from '@angular/core'; -import { MapComponent } from 'ngx-openlayers'; +import { MapComponent } from 'ng-openlayers'; import {IMapState} from '../../../models/map.state' import {View} from 'ol'; import { fromLonLat } from 'ol/proj'; diff --git a/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.ts b/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.ts index b20150e..621c3d9 100644 --- a/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.ts +++ b/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.ts @@ -1,5 +1,5 @@ import { Component, Host, Input, OnInit, ChangeDetectorRef } from '@angular/core'; -import { ViewComponent, MapComponent } from 'ngx-openlayers'; +import { ViewComponent, MapComponent } from 'ng-openlayers'; import {View} from 'ol'; diff --git a/projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts b/projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts index 5c6461f..dbf361f 100644 --- a/projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts +++ b/projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts @@ -1,6 +1,6 @@ import { Component, Host, Input, OnInit, OnChanges, SimpleChanges, forwardRef } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { ViewComponent, MapComponent } from 'ngx-openlayers'; +import { ViewComponent, MapComponent } from 'ng-openlayers'; @Component({ diff --git a/projects/common-map/src/fm-map/components/if-zoom-to-show/if-zoom-to-show.directive.ts b/projects/common-map/src/fm-map/components/if-zoom-to-show/if-zoom-to-show.directive.ts index 62924bb..6f8eba8 100644 --- a/projects/common-map/src/fm-map/components/if-zoom-to-show/if-zoom-to-show.directive.ts +++ b/projects/common-map/src/fm-map/components/if-zoom-to-show/if-zoom-to-show.directive.ts @@ -1,7 +1,7 @@ import { Directive, ViewContainerRef,TemplateRef,OnInit,Input, OnChanges } from '@angular/core'; import { Layer } from 'ol/layer'; import { Source } from 'ol/source'; -import { MapComponent } from 'ngx-openlayers'; +import { MapComponent } from 'ng-openlayers'; @Directive({ selector: '[fmMapIfZoomToShow]', diff --git a/projects/common-map3d/src/fm-map3d/components/olcs/switch2d3d/switch2d3d.component.ts b/projects/common-map3d/src/fm-map3d/components/olcs/switch2d3d/switch2d3d.component.ts index c7da446..4e01e17 100644 --- a/projects/common-map3d/src/fm-map3d/components/olcs/switch2d3d/switch2d3d.component.ts +++ b/projects/common-map3d/src/fm-map3d/components/olcs/switch2d3d/switch2d3d.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit,Input,Host } from '@angular/core'; import { Interaction} from 'ol/interaction'; -import { MapComponent } from 'ngx-openlayers'; +import { MapComponent } from 'ng-openlayers'; import OLCesium from 'olcs/OLCesium'; import RasterSynchronizer from 'olcs/RasterSynchronizer'; import VectorSynchronizer from 'olcs/VectorSynchronizer'; diff --git a/projects/ngx-openlayers/.eslintrc.json b/projects/ng-openlayers/.eslintrc.json similarity index 84% rename from projects/ngx-openlayers/.eslintrc.json rename to projects/ng-openlayers/.eslintrc.json index 300efbd..9863079 100644 --- a/projects/ngx-openlayers/.eslintrc.json +++ b/projects/ng-openlayers/.eslintrc.json @@ -10,8 +10,7 @@ ], "parserOptions": { "project": [ - "projects/ngx-openlayers/tsconfig.lib.json", - "projects/ngx-openlayers/tsconfig.spec.json" + "libs/ng-openlayers/tsconfig.*?.json" ], "createDefaultProgram": true }, @@ -42,8 +41,7 @@ "off", "always" ], - "import/order": "off", - "no-underscore-dangle": "off" + "import/order": "off" } }, { diff --git a/projects/ng-openlayers/.gitignore b/projects/ng-openlayers/.gitignore new file mode 100644 index 0000000..4d64059 --- /dev/null +++ b/projects/ng-openlayers/.gitignore @@ -0,0 +1,2 @@ +/node_modules + diff --git a/projects/ng-openlayers/karma.conf.js b/projects/ng-openlayers/karma.conf.js new file mode 100644 index 0000000..ce04701 --- /dev/null +++ b/projects/ng-openlayers/karma.conf.js @@ -0,0 +1,32 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma'), + ], + client: { + clearContext: false, // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../../coverage/ng-openlayers'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true, + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true, + }); +}; diff --git a/projects/ngx-openlayers/ng-package.json b/projects/ng-openlayers/ng-package.json similarity index 79% rename from projects/ngx-openlayers/ng-package.json rename to projects/ng-openlayers/ng-package.json index ff20cdf..bcf2327 100644 --- a/projects/ngx-openlayers/ng-package.json +++ b/projects/ng-openlayers/ng-package.json @@ -1,6 +1,6 @@ { "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", - "dest": "../../dist/ngx-openlayers", + "dest": "../../dist/libs/ng-openlayers", "assets": [ "ngcc.config.js" ], diff --git a/projects/ng-openlayers/ngcc.config.js b/projects/ng-openlayers/ngcc.config.js new file mode 100644 index 0000000..81d297a --- /dev/null +++ b/projects/ng-openlayers/ngcc.config.js @@ -0,0 +1,3 @@ +module.exports = { + ignorableDeepImportMatchers: [/ol\//], +}; diff --git a/projects/ng-openlayers/package-lock.json b/projects/ng-openlayers/package-lock.json new file mode 100644 index 0000000..16f395d --- /dev/null +++ b/projects/ng-openlayers/package-lock.json @@ -0,0 +1,33 @@ +{ + "name": "ng-openlayers", + "version": "17.1.3", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "ng-openlayers", + "version": "17.1.3", + "license": "MPL-2.0", + "dependencies": { + "tslib": "^2.3.0" + }, + "peerDependencies": { + "@angular/common": ">=17.0.0", + "@angular/core": ">=17.0.0", + "ol": "^8.2.0" + } + }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + } + }, + "dependencies": { + "tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + } + } +} diff --git a/projects/ng-openlayers/package.json b/projects/ng-openlayers/package.json new file mode 100644 index 0000000..90aa737 --- /dev/null +++ b/projects/ng-openlayers/package.json @@ -0,0 +1,39 @@ +{ + "name": "ng-openlayers", + "version": "17.1.3", + "description": "OpenLayers library for Angular", + "author": "Kamil Furtak (kamil.furtak@gmail.com)", + "repository": { + "type": "git", + "url": "https://github.com/kamilfurtak/ng-openlayers.git" + }, + "bugs": { + "url": "https://github.com/kamilfurtak/ng-openlayers/issues" + }, + "homepage": "https://github.com/kamilfurtak/ng-openlayers", + "keywords": [ + "ngx-openlayers", + "angular", + "angular17", + "openlayers", + "openlayers8", + "ol8" + ], + "license": "MPL-2.0", + "private": false, + "scripts": { + "release": "standard-version -m \"chore(release): version %s\" -t \"\"", + "prepublishOnly": "cp projects/ng-openlayers/README.md dist/ng-openlayers/README.md" + }, + "standard-version": { + "postchangelog": "cp projects/ng-openlayers/CHANGELOG.md dist/ng-openlayers/CHANGELOG.md" + }, + "dependencies": { + "tslib": "^2.3.0" + }, + "peerDependencies": { + "@angular/common": ">=17.0.0", + "@angular/core": ">=17.0.0", + "ol": "^8.2.0" + } +} diff --git a/projects/ng-openlayers/project.json b/projects/ng-openlayers/project.json new file mode 100644 index 0000000..e88a908 --- /dev/null +++ b/projects/ng-openlayers/project.json @@ -0,0 +1,38 @@ +{ + "name": "ng-openlayers", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "projectType": "library", + "sourceRoot": "libs/ng-openlayers/src", + "prefix": "lib", + "targets": { + "build": { + "executor": "@nx/angular:package", + "options": { + "tsConfig": "libs/ng-openlayers/tsconfig.lib.json", + "project": "libs/ng-openlayers/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "libs/ng-openlayers/tsconfig.lib.prod.json" + } + } + }, + "test": { + "executor": "@angular-devkit/build-angular:karma", + "options": { + "main": "libs/ng-openlayers/src/test.ts", + "tsConfig": "libs/ng-openlayers/tsconfig.spec.json", + "karmaConfig": "libs/ng-openlayers/karma.conf.js" + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "options": { + "lintFilePatterns": [ + "libs/ng-openlayers/**/*.ts", + "libs/ng-openlayers/**/*.html" + ] + } + } + } +} diff --git a/projects/ngx-openlayers/src/lib/attribution.component.ts b/projects/ng-openlayers/src/lib/attribution.component.ts similarity index 60% rename from projects/ngx-openlayers/src/lib/attribution.component.ts rename to projects/ng-openlayers/src/lib/attribution.component.ts index 9d0300f..28b0c99 100644 --- a/projects/ngx-openlayers/src/lib/attribution.component.ts +++ b/projects/ng-openlayers/src/lib/attribution.component.ts @@ -1,18 +1,15 @@ import { Component, ElementRef, OnInit } from '@angular/core'; -import { Attribution } from 'ol/control'; @Component({ selector: 'aol-attribution', template: '', }) 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; } } diff --git a/projects/ngx-openlayers/src/lib/attributions.component.ts b/projects/ng-openlayers/src/lib/attributions.component.ts similarity index 84% rename from projects/ngx-openlayers/src/lib/attributions.component.ts rename to projects/ng-openlayers/src/lib/attributions.component.ts index 17fb3bf..47ead99 100644 --- a/projects/ngx-openlayers/src/lib/attributions.component.ts +++ b/projects/ng-openlayers/src/lib/attributions.component.ts @@ -1,7 +1,6 @@ import { AfterViewInit, Component, ContentChildren, Host, QueryList } from '@angular/core'; -import { Attribution } from 'ol/control'; -import { AttributionComponent } from './attribution.component'; import { SourceComponent } from './sources/source.component'; +import { AttributionComponent } from './attribution.component'; @Component({ selector: 'aol-attributions', @@ -11,14 +10,14 @@ export class AttributionsComponent implements AfterViewInit { @ContentChildren(AttributionComponent) attributions: QueryList; - instance: Array; + instance: Array; constructor(@Host() private source: SourceComponent) {} /* 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); } diff --git a/projects/ngx-openlayers/src/lib/collectioncoordinates.component.ts b/projects/ng-openlayers/src/lib/collectioncoordinates.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/collectioncoordinates.component.ts rename to projects/ng-openlayers/src/lib/collectioncoordinates.component.ts index 277bc9f..94565b1 100644 --- a/projects/ngx-openlayers/src/lib/collectioncoordinates.component.ts +++ b/projects/ng-openlayers/src/lib/collectioncoordinates.component.ts @@ -1,12 +1,12 @@ import { Component, Input, OnChanges, OnInit, Optional, SimpleChanges } from '@angular/core'; +import { MapComponent } from './map.component'; +import { GeometryLinestringComponent } from './geom/geometrylinestring.component'; +import { GeometryPolygonComponent } from './geom/geometrypolygon.component'; +import { GeometryMultiPointComponent } from './geom/geometrymultipoint.component'; +import { GeometryMultiLinestringComponent } from './geom/geometrymultilinestring.component'; +import { GeometryMultiPolygonComponent } from './geom/geometrymultipolygon.component'; import { Coordinate } from 'ol/coordinate'; import { transform } from 'ol/proj'; -import { GeometryLinestringComponent } from './geom/geometrylinestring.component'; -import { GeometryMultiLinestringComponent } from './geom/geometrymultilinestring.component'; -import { GeometryMultiPointComponent } from './geom/geometrymultipoint.component'; -import { GeometryMultiPolygonComponent } from './geom/geometrymultipolygon.component'; -import { GeometryPolygonComponent } from './geom/geometrypolygon.component'; -import { MapComponent } from './map.component'; @Component({ selector: 'aol-collection-coordinates', diff --git a/projects/ngx-openlayers/src/lib/content.component.ts b/projects/ng-openlayers/src/lib/content.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/content.component.ts rename to projects/ng-openlayers/src/lib/content.component.ts diff --git a/projects/ngx-openlayers/src/lib/controls/attribution.component.ts b/projects/ng-openlayers/src/lib/controls/attribution.component.ts similarity index 83% rename from projects/ngx-openlayers/src/lib/controls/attribution.component.ts rename to projects/ng-openlayers/src/lib/controls/attribution.component.ts index fd6c8a5..33fbce9 100644 --- a/projects/ngx-openlayers/src/lib/controls/attribution.component.ts +++ b/projects/ng-openlayers/src/lib/controls/attribution.component.ts @@ -10,11 +10,14 @@ export class ControlAttributionComponent implements OnInit, OnDestroy { @Input() collapsible: boolean; - componentType = 'control'; + public componentType = 'control'; instance: Attribution; - target: Element; + target: HTMLElement; - constructor(private map: MapComponent, private element: ElementRef) {} + constructor( + private map: MapComponent, + private element: ElementRef + ) {} ngOnInit() { this.target = this.element.nativeElement; diff --git a/projects/ngx-openlayers/src/lib/controls/control.component.ts b/projects/ng-openlayers/src/lib/controls/control.component.ts similarity index 93% rename from projects/ngx-openlayers/src/lib/controls/control.component.ts rename to projects/ng-openlayers/src/lib/controls/control.component.ts index ef686d5..2ff6489 100644 --- a/projects/ngx-openlayers/src/lib/controls/control.component.ts +++ b/projects/ng-openlayers/src/lib/controls/control.component.ts @@ -1,7 +1,7 @@ import { Component, ContentChild, OnDestroy, OnInit } from '@angular/core'; import { Control } from 'ol/control'; -import { ContentComponent } from '../content.component'; import { MapComponent } from '../map.component'; +import { ContentComponent } from '../content.component'; @Component({ selector: 'aol-control', @@ -11,9 +11,9 @@ export class ControlComponent implements OnInit, OnDestroy { @ContentChild(ContentComponent, { static: true }) content: ContentComponent; - componentType = 'control'; + public componentType = 'control'; instance: Control; - element: Element; + element: HTMLElement; constructor(private map: MapComponent) {} diff --git a/projects/ngx-openlayers/src/lib/controls/default.component.ts b/projects/ng-openlayers/src/lib/controls/default.component.ts similarity index 94% rename from projects/ngx-openlayers/src/lib/controls/default.component.ts rename to projects/ng-openlayers/src/lib/controls/default.component.ts index f98afee..ebb9ebd 100644 --- a/projects/ngx-openlayers/src/lib/controls/default.component.ts +++ b/projects/ng-openlayers/src/lib/controls/default.component.ts @@ -1,6 +1,6 @@ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; -import { Collection } from 'ol'; +import { Component, OnDestroy, OnInit, Input } from '@angular/core'; import { Control, defaults } from 'ol/control'; +import { Collection } from 'ol'; import { Options as AttributionOptions } from 'ol/control/Attribution'; import { Options as RotateOptions } from 'ol/control/Rotate'; import { Options as ZoomOptions } from 'ol/control/Zoom'; diff --git a/projects/ngx-openlayers/src/lib/controls/fullscreen.component.ts b/projects/ng-openlayers/src/lib/controls/fullscreen.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/controls/fullscreen.component.ts rename to projects/ng-openlayers/src/lib/controls/fullscreen.component.ts diff --git a/projects/ngx-openlayers/src/lib/controls/mouseposition.component.ts b/projects/ng-openlayers/src/lib/controls/mouseposition.component.ts similarity index 89% rename from projects/ngx-openlayers/src/lib/controls/mouseposition.component.ts rename to projects/ng-openlayers/src/lib/controls/mouseposition.component.ts index ab7ee08..35479a4 100644 --- a/projects/ngx-openlayers/src/lib/controls/mouseposition.component.ts +++ b/projects/ng-openlayers/src/lib/controls/mouseposition.component.ts @@ -1,8 +1,8 @@ import { Component, ElementRef, Input, OnDestroy, OnInit } from '@angular/core'; import MousePosition from 'ol/control/MousePosition'; +import { MapComponent } from '../map.component'; import { CoordinateFormat } from 'ol/coordinate'; import { ProjectionLike } from 'ol/proj'; -import { MapComponent } from '../map.component'; @Component({ selector: 'aol-control-mouseposition', @@ -13,11 +13,14 @@ export class ControlMousePositionComponent implements OnInit, OnDestroy { coordinateFormat: CoordinateFormat; @Input() projection: ProjectionLike; - target: Element; instance: MousePosition; + target: HTMLElement; - constructor(private map: MapComponent, private element: ElementRef) {} + constructor( + private map: MapComponent, + private element: ElementRef + ) {} ngOnInit() { this.target = this.element.nativeElement; diff --git a/projects/ngx-openlayers/src/lib/controls/overviewmap.component.ts b/projects/ng-openlayers/src/lib/controls/overviewmap.component.ts similarity index 93% rename from projects/ngx-openlayers/src/lib/controls/overviewmap.component.ts rename to projects/ng-openlayers/src/lib/controls/overviewmap.component.ts index 984e33c..42ef072 100644 --- a/projects/ngx-openlayers/src/lib/controls/overviewmap.component.ts +++ b/projects/ng-openlayers/src/lib/controls/overviewmap.component.ts @@ -1,7 +1,7 @@ -import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; +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 { Layer } from 'ol/layer'; import { MapComponent } from '../map.component'; @Component({ @@ -20,7 +20,7 @@ export class ControlOverviewMapComponent implements OnInit, OnChanges, OnDestroy @Input() layers: Layer[]; @Input() - target: Element; + target: HTMLElement; @Input() tipLabel: string; @Input() diff --git a/projects/ngx-openlayers/src/lib/controls/rotate.component.ts b/projects/ng-openlayers/src/lib/controls/rotate.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/controls/rotate.component.ts rename to projects/ng-openlayers/src/lib/controls/rotate.component.ts diff --git a/projects/ngx-openlayers/src/lib/controls/scaleline.component.ts b/projects/ng-openlayers/src/lib/controls/scaleline.component.ts similarity index 75% rename from projects/ngx-openlayers/src/lib/controls/scaleline.component.ts rename to projects/ng-openlayers/src/lib/controls/scaleline.component.ts index 4f86891..7853959 100644 --- a/projects/ngx-openlayers/src/lib/controls/scaleline.component.ts +++ b/projects/ng-openlayers/src/lib/controls/scaleline.component.ts @@ -1,6 +1,7 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import { ScaleLine } from 'ol/control'; import { MapComponent } from '../map.component'; +import { Units } from 'ol/control/ScaleLine'; @Component({ selector: 'aol-control-scaleline', @@ -8,13 +9,11 @@ import { MapComponent } from '../map.component'; }) export class ControlScaleLineComponent implements OnInit, OnDestroy { @Input() - units: string; + units: Units; instance: ScaleLine; - constructor(private map: MapComponent) { - // console.log('instancing aol-control-scaleline'); - } + constructor(private map: MapComponent) {} ngOnInit() { this.instance = new ScaleLine(this); @@ -22,7 +21,6 @@ export class ControlScaleLineComponent implements OnInit, OnDestroy { } ngOnDestroy() { - // console.log('removing aol-control-scaleline'); this.map.instance.removeControl(this.instance); } } diff --git a/projects/ngx-openlayers/src/lib/controls/zoom.component.ts b/projects/ng-openlayers/src/lib/controls/zoom.component.ts similarity index 91% rename from projects/ngx-openlayers/src/lib/controls/zoom.component.ts rename to projects/ng-openlayers/src/lib/controls/zoom.component.ts index 4c1e934..0aee170 100644 --- a/projects/ngx-openlayers/src/lib/controls/zoom.component.ts +++ b/projects/ng-openlayers/src/lib/controls/zoom.component.ts @@ -10,9 +10,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() diff --git a/projects/ngx-openlayers/src/lib/controls/zoomslider.component.ts b/projects/ng-openlayers/src/lib/controls/zoomslider.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/controls/zoomslider.component.ts rename to projects/ng-openlayers/src/lib/controls/zoomslider.component.ts diff --git a/projects/ngx-openlayers/src/lib/controls/zoomtoextent.component.ts b/projects/ng-openlayers/src/lib/controls/zoomtoextent.component.ts similarity index 96% rename from projects/ngx-openlayers/src/lib/controls/zoomtoextent.component.ts rename to projects/ng-openlayers/src/lib/controls/zoomtoextent.component.ts index e484be0..f53f7b1 100644 --- a/projects/ngx-openlayers/src/lib/controls/zoomtoextent.component.ts +++ b/projects/ng-openlayers/src/lib/controls/zoomtoextent.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import { ZoomToExtent } from 'ol/control'; -import { Extent } from 'ol/extent'; import { MapComponent } from '../map.component'; +import { Extent } from 'ol/extent'; @Component({ selector: 'aol-control-zoomtoextent', @@ -11,7 +11,7 @@ export class ControlZoomToExtentComponent implements OnInit, OnDestroy { @Input() className: string; @Input() - label: string | Node; + label: string | HTMLElement; @Input() tipLabel: string; @Input() diff --git a/projects/ngx-openlayers/src/lib/coordinate.component.ts b/projects/ng-openlayers/src/lib/coordinate.component.ts similarity index 96% rename from projects/ngx-openlayers/src/lib/coordinate.component.ts rename to projects/ng-openlayers/src/lib/coordinate.component.ts index 17f3a38..38d5dc2 100644 --- a/projects/ngx-openlayers/src/lib/coordinate.component.ts +++ b/projects/ng-openlayers/src/lib/coordinate.component.ts @@ -1,10 +1,10 @@ -import { Component, Input, OnChanges, OnInit, Optional, SimpleChanges } from '@angular/core'; +import { Component, Optional, OnChanges, Input, SimpleChanges, OnInit } from '@angular/core'; import { transform } from 'ol/proj'; -import { GeometryCircleComponent } from './geom/geometrycircle.component'; -import { GeometryPointComponent } from './geom/geometrypoint.component'; import { MapComponent } from './map.component'; -import { OverlayComponent } from './overlay.component'; +import { GeometryPointComponent } from './geom/geometrypoint.component'; +import { GeometryCircleComponent } from './geom/geometrycircle.component'; import { ViewComponent } from './view.component'; +import { OverlayComponent } from './overlay.component'; @Component({ selector: 'aol-coordinate', diff --git a/projects/ngx-openlayers/src/lib/feature.component.ts b/projects/ng-openlayers/src/lib/feature.component.ts similarity index 85% rename from projects/ngx-openlayers/src/lib/feature.component.ts rename to projects/ng-openlayers/src/lib/feature.component.ts index d6a5acf..03c7313 100644 --- a/projects/ngx-openlayers/src/lib/feature.component.ts +++ b/projects/ng-openlayers/src/lib/feature.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; +import { Component, OnInit, OnDestroy, OnChanges, Input, SimpleChanges } from '@angular/core'; import { Feature } from 'ol'; import { SourceVectorComponent } from './sources/vector.component'; @@ -10,8 +10,8 @@ export class FeatureComponent implements OnInit, OnDestroy, OnChanges { @Input() id: string | number | undefined; - componentType = 'feature'; - instance: Feature; + public componentType = 'feature'; + public instance: Feature; constructor(private host: SourceVectorComponent) {} diff --git a/projects/ngx-openlayers/src/lib/formats/format.component.ts b/projects/ng-openlayers/src/lib/formats/format.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/formats/format.component.ts rename to projects/ng-openlayers/src/lib/formats/format.component.ts diff --git a/projects/ngx-openlayers/src/lib/formats/mvt.component.ts b/projects/ng-openlayers/src/lib/formats/mvt.component.ts similarity index 68% rename from projects/ngx-openlayers/src/lib/formats/mvt.component.ts rename to projects/ng-openlayers/src/lib/formats/mvt.component.ts index 25a5e7a..0d880c2 100644 --- a/projects/ngx-openlayers/src/lib/formats/mvt.component.ts +++ b/projects/ng-openlayers/src/lib/formats/mvt.component.ts @@ -1,8 +1,7 @@ import { Component, forwardRef, Input } from '@angular/core'; -import { MVT } from 'ol/format'; -import { Geometry } from 'ol/geom'; -import GeometryType from 'ol/geom/GeometryType'; import { FormatComponent } from './format.component'; +import { MVT } from 'ol/format'; +import { FeatureClass } from 'ol/Feature'; @Component({ selector: 'aol-format-mvt', @@ -11,9 +10,7 @@ import { FormatComponent } from './format.component'; }) export class FormatMVTComponent extends FormatComponent { @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() diff --git a/projects/ngx-openlayers/src/lib/geom/geometrycircle.component.ts b/projects/ng-openlayers/src/lib/geom/geometrycircle.component.ts similarity index 91% rename from projects/ngx-openlayers/src/lib/geom/geometrycircle.component.ts rename to projects/ng-openlayers/src/lib/geom/geometrycircle.component.ts index 439a3b7..cdccb1d 100644 --- a/projects/ngx-openlayers/src/lib/geom/geometrycircle.component.ts +++ b/projects/ng-openlayers/src/lib/geom/geometrycircle.component.ts @@ -1,23 +1,14 @@ import { Component, Input, OnInit } from '@angular/core'; -import { Circle } from 'ol/geom'; import { FeatureComponent } from '../feature.component'; -import { MapComponent } from '../map.component'; +import { Circle } from 'ol/geom'; import { SimpleGeometryComponent } from './simplegeometry.component'; +import { MapComponent } from '../map.component'; @Component({ selector: 'aol-geometry-circle', template: ` `, }) export class GeometryCircleComponent extends SimpleGeometryComponent implements OnInit { - componentType = 'geometry-circle'; - instance: Circle; - - constructor(map: MapComponent, host: FeatureComponent) { - super(map, host); - // defaulting coordinates to [0,0]. To be overridden in child component. - this.instance = new Circle([0, 0]); - } - @Input() get radius(): number { return this.instance.getRadius(); @@ -25,4 +16,13 @@ export class GeometryCircleComponent extends SimpleGeometryComponent implements set radius(radius: number) { this.instance.setRadius(radius); } + + public componentType = 'geometry-circle'; + public instance: Circle; + + constructor(map: MapComponent, host: FeatureComponent) { + super(map, host); + // defaulting coordinates to [0,0]. To be overridden in child component. + this.instance = new Circle([0, 0]); + } } diff --git a/projects/ngx-openlayers/src/lib/geom/geometrylinestring.component.ts b/projects/ng-openlayers/src/lib/geom/geometrylinestring.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/geom/geometrylinestring.component.ts rename to projects/ng-openlayers/src/lib/geom/geometrylinestring.component.ts diff --git a/projects/ngx-openlayers/src/lib/geom/geometrymultilinestring.component.ts b/projects/ng-openlayers/src/lib/geom/geometrymultilinestring.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/geom/geometrymultilinestring.component.ts rename to projects/ng-openlayers/src/lib/geom/geometrymultilinestring.component.ts diff --git a/projects/ngx-openlayers/src/lib/geom/geometrymultipoint.component.ts b/projects/ng-openlayers/src/lib/geom/geometrymultipoint.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/geom/geometrymultipoint.component.ts rename to projects/ng-openlayers/src/lib/geom/geometrymultipoint.component.ts diff --git a/projects/ngx-openlayers/src/lib/geom/geometrymultipolygon.component.ts b/projects/ng-openlayers/src/lib/geom/geometrymultipolygon.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/geom/geometrymultipolygon.component.ts rename to projects/ng-openlayers/src/lib/geom/geometrymultipolygon.component.ts diff --git a/projects/ngx-openlayers/src/lib/geom/geometrypoint.component.ts b/projects/ng-openlayers/src/lib/geom/geometrypoint.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/geom/geometrypoint.component.ts rename to projects/ng-openlayers/src/lib/geom/geometrypoint.component.ts diff --git a/projects/ngx-openlayers/src/lib/geom/geometrypolygon.component.ts b/projects/ng-openlayers/src/lib/geom/geometrypolygon.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/geom/geometrypolygon.component.ts rename to projects/ng-openlayers/src/lib/geom/geometrypolygon.component.ts diff --git a/projects/ngx-openlayers/src/lib/geom/simplegeometry.component.ts b/projects/ng-openlayers/src/lib/geom/simplegeometry.component.ts similarity index 52% rename from projects/ngx-openlayers/src/lib/geom/simplegeometry.component.ts rename to projects/ng-openlayers/src/lib/geom/simplegeometry.component.ts index 0c7c8a9..909da83 100644 --- a/projects/ngx-openlayers/src/lib/geom/simplegeometry.component.ts +++ b/projects/ng-openlayers/src/lib/geom/simplegeometry.component.ts @@ -1,16 +1,20 @@ -import { Directive, Input, OnInit } from '@angular/core'; -import SimpleGeometry from 'ol/geom/SimpleGeometry'; +import { Input, OnInit, Directive } from '@angular/core'; import { FeatureComponent } from '../feature.component'; import { MapComponent } from '../map.component'; +import SimpleGeometry from 'ol/geom/SimpleGeometry'; @Directive() +// eslint-disable-next-line @angular-eslint/directive-class-suffix export abstract class SimpleGeometryComponent implements OnInit { @Input() srid: string; - instance: SimpleGeometry; - componentType = 'simple-geometry'; + public instance: SimpleGeometry; + public componentType = 'simple-geometry'; - constructor(protected map: MapComponent, protected host: FeatureComponent) {} + protected constructor( + protected map: MapComponent, + protected host: FeatureComponent + ) {} ngOnInit() { this.host.instance.setGeometry(this.instance); diff --git a/projects/ngx-openlayers/src/lib/graticule.component.ts b/projects/ng-openlayers/src/lib/graticule.component.ts similarity index 89% rename from projects/ngx-openlayers/src/lib/graticule.component.ts rename to projects/ng-openlayers/src/lib/graticule.component.ts index db7c48e..36fcb3f 100644 --- a/projects/ngx-openlayers/src/lib/graticule.component.ts +++ b/projects/ng-openlayers/src/lib/graticule.component.ts @@ -1,4 +1,4 @@ -import { AfterContentInit, Component, Input, OnChanges, OnDestroy, SimpleChanges } from '@angular/core'; +import { Component, Input, AfterContentInit, OnChanges, SimpleChanges, OnDestroy } from '@angular/core'; import { Graticule } from 'ol'; import { Stroke } from 'ol/style'; import { MapComponent } from './map.component'; @@ -18,7 +18,7 @@ export class GraticuleComponent implements AfterContentInit, OnChanges, OnDestro latLabelPosition: number; instance: any; - componentType = 'graticule'; + public componentType = 'graticule'; constructor(private map: MapComponent) {} diff --git a/projects/ngx-openlayers/src/lib/interactions/default.component.ts b/projects/ng-openlayers/src/lib/interactions/default.component.ts similarity index 52% rename from projects/ngx-openlayers/src/lib/interactions/default.component.ts rename to projects/ng-openlayers/src/lib/interactions/default.component.ts index e0a44e2..842f072 100644 --- a/projects/ngx-openlayers/src/lib/interactions/default.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/default.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import { defaults, Interaction } from 'ol/interaction'; import { Collection } from 'ol'; import { MapComponent } from '../map.component'; @@ -8,12 +8,35 @@ import { MapComponent } from '../map.component'; template: '', }) export class DefaultInteractionComponent implements OnInit, OnDestroy { + @Input() + altShiftDragRotate: boolean; + @Input() + onFocusOnly: boolean; + @Input() + doubleClickZoom: boolean; + @Input() + keyboard: boolean; + @Input() + mouseWheelZoom: boolean; + @Input() + shiftDragZoom: boolean; + @Input() + dragPan: boolean; + @Input() + pinchRotate: boolean; + @Input() + pinchZoom: boolean; + @Input() + zoomDelta: number; + @Input() + zoomDuration: number; + instance: Collection; constructor(private map: MapComponent) {} ngOnInit() { - this.instance = defaults(); + this.instance = defaults(this); this.instance.forEach((i) => this.map.instance.addInteraction(i)); } diff --git a/projects/ngx-openlayers/src/lib/interactions/doubleclickzoom.component.ts b/projects/ng-openlayers/src/lib/interactions/doubleclickzoom.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/interactions/doubleclickzoom.component.ts rename to projects/ng-openlayers/src/lib/interactions/doubleclickzoom.component.ts diff --git a/projects/ngx-openlayers/src/lib/interactions/draganddrop.component.ts b/projects/ng-openlayers/src/lib/interactions/draganddrop.component.ts similarity index 86% rename from projects/ngx-openlayers/src/lib/interactions/draganddrop.component.ts rename to projects/ng-openlayers/src/lib/interactions/draganddrop.component.ts index 7bc72e6..9ecc6f9 100644 --- a/projects/ngx-openlayers/src/lib/interactions/draganddrop.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/draganddrop.component.ts @@ -1,8 +1,8 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core'; -import Feature from 'ol/format/Feature'; import { DragAndDrop } from 'ol/interaction'; -import { ProjectionLike } from 'ol/proj'; +import FeatureFormat from 'ol/format/Feature'; import { MapComponent } from '../map.component'; +import { ProjectionLike } from 'ol/proj'; @Component({ selector: 'aol-interaction-draganddrop', @@ -10,11 +10,11 @@ import { MapComponent } from '../map.component'; }) export class DragAndDropInteractionComponent implements OnInit, OnDestroy { @Input() - formatConstructors: ((n: Feature) => any)[]; + formatConstructors: FeatureFormat[]; @Input() projection: ProjectionLike; @Input() - target: Element; + target: HTMLElement; instance: DragAndDrop; diff --git a/projects/ngx-openlayers/src/lib/interactions/dragbox.component.ts b/projects/ng-openlayers/src/lib/interactions/dragbox.component.ts similarity index 91% rename from projects/ngx-openlayers/src/lib/interactions/dragbox.component.ts rename to projects/ng-openlayers/src/lib/interactions/dragbox.component.ts index d25b116..18b3374 100644 --- a/projects/ngx-openlayers/src/lib/interactions/dragbox.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/dragbox.component.ts @@ -1,8 +1,8 @@ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; -import { Condition } from 'ol/events/condition'; +import { Component, OnDestroy, OnInit, Input } from '@angular/core'; import { DragBox } from 'ol/interaction'; -import { EndCondition } from 'ol/interaction/DragBox'; import { MapComponent } from '../map.component'; +import { Condition } from 'ol/events/condition'; +import { EndCondition } from 'ol/interaction/DragBox'; @Component({ selector: 'aol-interaction-dragbox', diff --git a/projects/ngx-openlayers/src/lib/interactions/dragpan.component.ts b/projects/ng-openlayers/src/lib/interactions/dragpan.component.ts similarity index 91% rename from projects/ngx-openlayers/src/lib/interactions/dragpan.component.ts rename to projects/ng-openlayers/src/lib/interactions/dragpan.component.ts index 9e521e6..857d7d5 100644 --- a/projects/ngx-openlayers/src/lib/interactions/dragpan.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/dragpan.component.ts @@ -1,8 +1,8 @@ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; -import Kinetic from 'ol/Kinetic'; -import { Condition } from 'ol/events/condition'; +import { Component, OnDestroy, OnInit, Input } from '@angular/core'; import { DragPan } from 'ol/interaction'; +import Kinetic from 'ol/Kinetic'; import { MapComponent } from '../map.component'; +import { Condition } from 'ol/events/condition'; @Component({ selector: 'aol-interaction-dragpan', diff --git a/projects/ngx-openlayers/src/lib/interactions/dragrotate.component.ts b/projects/ng-openlayers/src/lib/interactions/dragrotate.component.ts similarity index 90% rename from projects/ngx-openlayers/src/lib/interactions/dragrotate.component.ts rename to projects/ng-openlayers/src/lib/interactions/dragrotate.component.ts index 9b34a9b..f1324d8 100644 --- a/projects/ngx-openlayers/src/lib/interactions/dragrotate.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/dragrotate.component.ts @@ -1,7 +1,7 @@ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; -import { Condition } from 'ol/events/condition'; +import { Component, OnDestroy, OnInit, Input } from '@angular/core'; import { DragRotate } from 'ol/interaction'; import { MapComponent } from '../map.component'; +import { Condition } from 'ol/events/condition'; @Component({ selector: 'aol-interaction-dragrotate', diff --git a/projects/ngx-openlayers/src/lib/interactions/dragrotateandzoom.component.ts b/projects/ng-openlayers/src/lib/interactions/dragrotateandzoom.component.ts similarity index 91% rename from projects/ngx-openlayers/src/lib/interactions/dragrotateandzoom.component.ts rename to projects/ng-openlayers/src/lib/interactions/dragrotateandzoom.component.ts index 263259a..779f042 100644 --- a/projects/ngx-openlayers/src/lib/interactions/dragrotateandzoom.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/dragrotateandzoom.component.ts @@ -1,7 +1,7 @@ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; -import { Condition } from 'ol/events/condition'; +import { Component, OnDestroy, OnInit, Input } from '@angular/core'; import { DragRotateAndZoom } from 'ol/interaction'; import { MapComponent } from '../map.component'; +import { Condition } from 'ol/events/condition'; @Component({ selector: 'aol-interaction-dragrotateandzoom', diff --git a/projects/ngx-openlayers/src/lib/interactions/dragzoom.component.ts b/projects/ng-openlayers/src/lib/interactions/dragzoom.component.ts similarity index 91% rename from projects/ngx-openlayers/src/lib/interactions/dragzoom.component.ts rename to projects/ng-openlayers/src/lib/interactions/dragzoom.component.ts index 3d13b1a..4454f3e 100644 --- a/projects/ngx-openlayers/src/lib/interactions/dragzoom.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/dragzoom.component.ts @@ -1,7 +1,7 @@ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; -import { Condition } from 'ol/events/condition'; +import { Component, OnDestroy, OnInit, Input } from '@angular/core'; import { DragZoom } from 'ol/interaction'; import { MapComponent } from '../map.component'; +import { Condition } from 'ol/events/condition'; @Component({ selector: 'aol-interaction-dragzoom', diff --git a/projects/ngx-openlayers/src/lib/interactions/draw.component.ts b/projects/ng-openlayers/src/lib/interactions/draw.component.ts similarity index 69% rename from projects/ngx-openlayers/src/lib/interactions/draw.component.ts rename to projects/ng-openlayers/src/lib/interactions/draw.component.ts index 3323c21..afc3fcb 100644 --- a/projects/ngx-openlayers/src/lib/interactions/draw.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/draw.component.ts @@ -1,13 +1,15 @@ -import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; -import { Collection, Feature } from 'ol'; -import { Condition } from 'ol/events/condition'; -import GeometryType from 'ol/geom/GeometryType'; +import { Component, Input, OnDestroy, OnInit, EventEmitter, Output } from '@angular/core'; +import { MapComponent } from '../map.component'; import { Draw } from 'ol/interaction'; -import { DrawEvent, GeometryFunction } from 'ol/interaction/Draw'; +import { Collection, Feature } from 'ol'; import { Vector } from 'ol/source'; import { Style } from 'ol/style'; +import { DrawEvent, GeometryFunction } from 'ol/interaction/Draw'; import { StyleFunction } from 'ol/style/Style'; -import { MapComponent } from '../map.component'; +import { Condition } from 'ol/events/condition'; +import { Type } from 'ol/geom/Geometry'; +import { ObjectEvent } from 'ol/Object'; +import BaseEvent from 'ol/events/Event'; @Component({ selector: 'aol-interaction-draw', @@ -23,7 +25,7 @@ export class DrawInteractionComponent implements OnInit, OnDestroy { @Input() snapTolerance?: number; @Input() - type: GeometryType; + type: Type; @Input() maxPoints?: number; @Input() @@ -48,13 +50,17 @@ export class DrawInteractionComponent implements OnInit, OnDestroy { @Output() olChange = new EventEmitter(); @Output() - olChangeActive = new EventEmitter(); + olChangeActive = new EventEmitter(); + @Output() + olDrawAbort = new EventEmitter(); @Output() drawEnd = new EventEmitter(); @Output() drawStart = new EventEmitter(); @Output() - propertyChange = new EventEmitter(); + olError = new EventEmitter(); + @Output() + propertyChange = new EventEmitter(); instance: Draw; @@ -63,10 +69,12 @@ export class DrawInteractionComponent implements OnInit, OnDestroy { ngOnInit() { this.instance = new Draw(this); this.instance.on('change', (event: DrawEvent) => this.olChange.emit(event)); - this.instance.on('change:active', (event: DrawEvent) => this.olChangeActive.emit(event)); + this.instance.on('change:active', (event: ObjectEvent) => this.olChangeActive.emit(event)); + this.instance.on('drawabort', (event: DrawEvent) => this.olDrawAbort.emit(event)); this.instance.on('drawend', (event: DrawEvent) => this.drawEnd.emit(event)); this.instance.on('drawstart', (event: DrawEvent) => this.drawStart.emit(event)); - this.instance.on('propertychange', (event: DrawEvent) => this.propertyChange.emit(event)); + this.instance.on('error', (event: BaseEvent) => this.olError.emit(event)); + this.instance.on('propertychange', (event: ObjectEvent) => this.propertyChange.emit(event)); this.map.instance.addInteraction(this.instance); } diff --git a/projects/ng-openlayers/src/lib/interactions/keyboardpan.component.ts b/projects/ng-openlayers/src/lib/interactions/keyboardpan.component.ts new file mode 100644 index 0000000..3ccd5fc --- /dev/null +++ b/projects/ng-openlayers/src/lib/interactions/keyboardpan.component.ts @@ -0,0 +1,27 @@ +import { Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { KeyboardPan } from 'ol/interaction'; +import { MapComponent } from '../map.component'; + +@Component({ + selector: 'aol-interaction-keyboardpan', + template: '', +}) +export class KeyboardPanInteractionComponent implements OnInit, OnDestroy { + @Input() + duration: number; + @Input() + pixelDelta: number; + + instance: KeyboardPan; + + constructor(private map: MapComponent) {} + + ngOnInit() { + this.instance = new KeyboardPan(this); + this.map.instance.addInteraction(this.instance); + } + + ngOnDestroy() { + this.map.instance.removeInteraction(this.instance); + } +} diff --git a/projects/ng-openlayers/src/lib/interactions/keyboardzoom.component.ts b/projects/ng-openlayers/src/lib/interactions/keyboardzoom.component.ts new file mode 100644 index 0000000..cab5a4d --- /dev/null +++ b/projects/ng-openlayers/src/lib/interactions/keyboardzoom.component.ts @@ -0,0 +1,27 @@ +import { Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { KeyboardZoom } from 'ol/interaction'; +import { MapComponent } from '../map.component'; + +@Component({ + selector: 'aol-interaction-keyboardpan', + template: '', +}) +export class KeyboardZoomInteractionComponent implements OnInit, OnDestroy { + @Input() + duration: number; + @Input() + delta: number; + + instance: KeyboardZoom; + + constructor(private map: MapComponent) {} + + ngOnInit() { + this.instance = new KeyboardZoom(this); + this.map.instance.addInteraction(this.instance); + } + + ngOnDestroy() { + this.map.instance.removeInteraction(this.instance); + } +} diff --git a/projects/ngx-openlayers/src/lib/interactions/modify.component.ts b/projects/ng-openlayers/src/lib/interactions/modify.component.ts similarity index 56% rename from projects/ngx-openlayers/src/lib/interactions/modify.component.ts rename to projects/ng-openlayers/src/lib/interactions/modify.component.ts index c0e3be3..71e307f 100644 --- a/projects/ngx-openlayers/src/lib/interactions/modify.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/modify.component.ts @@ -1,12 +1,15 @@ -import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; -import { Collection, Feature } from 'ol'; -import { Condition } from 'ol/events/condition'; -import { Modify } from 'ol/interaction'; -import { ModifyEvent } from 'ol/interaction/Modify'; -import { Vector } from 'ol/source'; -import { Style } from 'ol/style'; -import { StyleFunction } from 'ol/style/Style'; +import { Component, OnDestroy, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { MapComponent } from '../map.component'; +import { Modify } from 'ol/interaction'; +import { Collection, Feature } from 'ol'; +import { Style } from 'ol/style'; +import { Vector } from 'ol/source'; +import { ModifyEvent } from 'ol/interaction/Modify'; +import { StyleFunction } from 'ol/style/Style'; +import { Condition } from 'ol/events/condition'; +import { ObjectEvent } from 'ol/Object'; +import { DrawEvent } from 'ol/interaction/Draw'; +import BaseEvent from 'ol/events/Event'; @Component({ selector: 'aol-interaction-modify', @@ -29,15 +32,17 @@ export class ModifyInteractionComponent implements OnInit, OnDestroy { source?: Vector; @Output() - modifyEnd = new EventEmitter(); + olChange = new EventEmitter(); @Output() - modifyStart = new EventEmitter(); + olChangeActive = new EventEmitter(); @Output() - olChange = new EventEmitter(); + olError = new EventEmitter(); @Output() - olChangeActive = new EventEmitter(); + olModifyEnd = new EventEmitter(); @Output() - propertyChange = new EventEmitter(); + olModifyStart = new EventEmitter(); + @Output() + propertyChange = new EventEmitter(); instance: Modify; @@ -45,11 +50,12 @@ export class ModifyInteractionComponent implements OnInit, OnDestroy { ngOnInit() { this.instance = new Modify(this); - this.instance.on('change', (event: ModifyEvent) => this.olChange.emit(event)); - this.instance.on('change:active', (event: ModifyEvent) => this.olChangeActive.emit(event)); - this.instance.on('propertychange', (event: ModifyEvent) => this.propertyChange.emit(event)); - this.instance.on('modifyend', (event: ModifyEvent) => this.modifyEnd.emit(event)); - this.instance.on('modifystart', (event: ModifyEvent) => this.modifyStart.emit(event)); + this.instance.on('change', (event: DrawEvent) => this.olChange.emit(event)); + this.instance.on('change:active', (event: ObjectEvent) => this.olChangeActive.emit(event)); + this.instance.on('error', (event: BaseEvent) => this.olError.emit(event)); + this.instance.on('modifyend', (event: ModifyEvent) => this.olModifyEnd.emit(event)); + this.instance.on('modifystart', (event: ModifyEvent) => this.olModifyStart.emit(event)); + this.instance.on('propertychange', (event: ObjectEvent) => this.propertyChange.emit(event)); this.map.instance.addInteraction(this.instance); } diff --git a/projects/ngx-openlayers/src/lib/interactions/mousewheelzoom.component.ts b/projects/ng-openlayers/src/lib/interactions/mousewheelzoom.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/interactions/mousewheelzoom.component.ts rename to projects/ng-openlayers/src/lib/interactions/mousewheelzoom.component.ts diff --git a/projects/ngx-openlayers/src/lib/interactions/pinchzoom.component.ts b/projects/ng-openlayers/src/lib/interactions/pinchzoom.component.ts similarity index 90% rename from projects/ngx-openlayers/src/lib/interactions/pinchzoom.component.ts rename to projects/ng-openlayers/src/lib/interactions/pinchzoom.component.ts index c6811c1..a48eee7 100644 --- a/projects/ngx-openlayers/src/lib/interactions/pinchzoom.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/pinchzoom.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { Component, OnDestroy, OnInit, Input } from '@angular/core'; import { PinchZoom } from 'ol/interaction'; import { MapComponent } from '../map.component'; diff --git a/projects/ngx-openlayers/src/lib/interactions/select.component.ts b/projects/ng-openlayers/src/lib/interactions/select.component.ts similarity index 69% rename from projects/ngx-openlayers/src/lib/interactions/select.component.ts rename to projects/ng-openlayers/src/lib/interactions/select.component.ts index 653eca4..c5f722f 100644 --- a/projects/ngx-openlayers/src/lib/interactions/select.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/select.component.ts @@ -1,12 +1,14 @@ -import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; -import { Collection, Feature } from 'ol'; -import { Condition } from 'ol/events/condition'; +import { Component, OnDestroy, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { MapComponent } from '../map.component'; import { Select } from 'ol/interaction'; -import { FilterFunction, SelectEvent } from 'ol/interaction/Select'; import { Layer } from 'ol/layer'; import { Style } from 'ol/style'; +import { Collection, Feature } from 'ol'; +import { SelectEvent, FilterFunction } from 'ol/interaction/Select'; import { StyleFunction } from 'ol/style/Style'; -import { MapComponent } from '../map.component'; +import { Condition } from 'ol/events/condition'; +import { ObjectEvent } from 'ol/Object'; +import BaseEvent from 'ol/events/Event'; @Component({ selector: 'aol-interaction-select', @@ -33,15 +35,17 @@ export class SelectInteractionComponent implements OnInit, OnDestroy { filter?: FilterFunction; @Input() wrapX?: boolean; - @Input() - hitTolerance?: number; @Output() olChange = new EventEmitter(); @Output() - olSelect = new EventEmitter(); + olChangeActive = new EventEmitter(); @Output() - propertyChange = new EventEmitter(); + olError = new EventEmitter(); + @Output() + propertyChange = new EventEmitter(); + @Output() + olSelect = new EventEmitter(); instance: Select; @@ -51,9 +55,10 @@ export class SelectInteractionComponent implements OnInit, OnDestroy { this.instance = new Select(this); this.instance.on('change', (event: SelectEvent) => this.olChange.emit(event)); + this.instance.on('change:active', (event: ObjectEvent) => this.olChangeActive.emit(event)); + this.instance.on('error', (event: BaseEvent) => this.olError.emit(event)); + this.instance.on('propertychange', (event: ObjectEvent) => this.propertyChange.emit(event)); this.instance.on('select', (event: SelectEvent) => this.olSelect.emit(event)); - this.instance.on('propertychange', (event: SelectEvent) => this.propertyChange.emit(event)); - this.map.instance.addInteraction(this.instance); } diff --git a/projects/ngx-openlayers/src/lib/interactions/translate.component.ts b/projects/ng-openlayers/src/lib/interactions/translate.component.ts similarity index 53% rename from projects/ngx-openlayers/src/lib/interactions/translate.component.ts rename to projects/ng-openlayers/src/lib/interactions/translate.component.ts index b05aef8..70ee6a3 100644 --- a/projects/ngx-openlayers/src/lib/interactions/translate.component.ts +++ b/projects/ng-openlayers/src/lib/interactions/translate.component.ts @@ -1,9 +1,11 @@ -import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; -import { Collection, Feature } from 'ol'; +import { Component, OnDestroy, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { Translate } from 'ol/interaction'; -import { TranslateEvent } from 'ol/interaction/Translate'; +import { Collection, Feature } from 'ol'; import { Layer } from 'ol/layer'; +import { TranslateEvent } from 'ol/interaction/Translate'; import { MapComponent } from '../map.component'; +import BaseEvent from 'ol/events/Event'; +import { ObjectEvent } from 'ol/Object'; @Component({ selector: 'aol-interaction-translate', @@ -18,31 +20,31 @@ export class TranslateInteractionComponent implements OnInit, OnDestroy { hitTolerance?: number; @Output() - olChange: EventEmitter; + olChange = new EventEmitter(); @Output() - propertyChange: EventEmitter; + olChangeActive = new EventEmitter(); @Output() - translateEnd: EventEmitter; + olError = new EventEmitter(); @Output() - translateStart: EventEmitter; + propertyChange = new EventEmitter(); @Output() - translating: EventEmitter; + translateEnd = new EventEmitter(); + @Output() + translateStart = new EventEmitter(); + @Output() + translating = new EventEmitter(); instance: Translate; - constructor(private map: MapComponent) { - this.olChange = new EventEmitter(); - this.propertyChange = new EventEmitter(); - this.translateEnd = new EventEmitter(); - this.translateStart = new EventEmitter(); - this.translating = new EventEmitter(); - } + constructor(private map: MapComponent) {} ngOnInit() { this.instance = new Translate(this); - this.instance.on('change', (event: TranslateEvent) => this.olChange.emit(event)); - this.instance.on('propertychange', (event: TranslateEvent) => this.propertyChange.emit(event)); + this.instance.on('change', (event: BaseEvent) => this.olChange.emit(event)); + this.instance.on('change:active', (event: ObjectEvent) => this.olChangeActive.emit(event)); + this.instance.on('error', (event: BaseEvent) => this.olError.emit(event)); + this.instance.on('propertychange', (event: ObjectEvent) => this.propertyChange.emit(event)); this.instance.on('translateend', (event: TranslateEvent) => this.translateEnd.emit(event)); this.instance.on('translatestart', (event: TranslateEvent) => this.translateStart.emit(event)); this.instance.on('translating', (event: TranslateEvent) => this.translating.emit(event)); diff --git a/projects/ngx-openlayers/src/lib/layers/layer.component.ts b/projects/ng-openlayers/src/lib/layers/layer.component.ts similarity index 83% rename from projects/ngx-openlayers/src/lib/layers/layer.component.ts rename to projects/ng-openlayers/src/lib/layers/layer.component.ts index 5399f9a..7f7f0b9 100644 --- a/projects/ngx-openlayers/src/lib/layers/layer.component.ts +++ b/projects/ng-openlayers/src/lib/layers/layer.component.ts @@ -1,10 +1,11 @@ -import { Directive, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; -import { Event } from 'ol/events'; -import { Extent } from 'ol/extent'; +import { OnDestroy, OnInit, OnChanges, Input, SimpleChanges, Directive } from '@angular/core'; +import Event from 'ol/events/Event'; import { MapComponent } from '../map.component'; import { LayerGroupComponent } from './layergroup.component'; +import { Extent } from 'ol/extent'; @Directive() +// eslint-disable-next-line @angular-eslint/directive-class-suffix export abstract class LayerComponent implements OnInit, OnChanges, OnDestroy { @Input() opacity: number; @@ -24,10 +25,10 @@ export abstract class LayerComponent implements OnInit, OnChanges, OnDestroy { @Input() postrender: (evt: Event) => void; - instance: any; - componentType = 'layer'; + public instance: any; + public componentType = 'layer'; - constructor(protected host: MapComponent | LayerGroupComponent) {} + protected constructor(protected host: MapComponent | LayerGroupComponent) {} ngOnInit() { if (this.prerender !== null && this.prerender !== undefined) { diff --git a/projects/ngx-openlayers/src/lib/layers/layergroup.component.ts b/projects/ng-openlayers/src/lib/layers/layergroup.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/layers/layergroup.component.ts rename to projects/ng-openlayers/src/lib/layers/layergroup.component.ts diff --git a/projects/ngx-openlayers/src/lib/layers/layerimage.component.ts b/projects/ng-openlayers/src/lib/layers/layerimage.component.ts similarity index 98% rename from projects/ngx-openlayers/src/lib/layers/layerimage.component.ts rename to projects/ng-openlayers/src/lib/layers/layerimage.component.ts index 58a6f49..66a6d9c 100644 --- a/projects/ngx-openlayers/src/lib/layers/layerimage.component.ts +++ b/projects/ng-openlayers/src/lib/layers/layerimage.component.ts @@ -1,9 +1,9 @@ import { Component, Input, OnChanges, OnInit, Optional, SimpleChanges } from '@angular/core'; -import { Extent } from 'ol/extent'; import { Image } from 'ol/layer'; import { MapComponent } from '../map.component'; import { LayerComponent } from './layer.component'; import { LayerGroupComponent } from './layergroup.component'; +import { Extent } from 'ol/extent'; @Component({ selector: 'aol-layer-image', @@ -23,8 +23,6 @@ export class LayerImageComponent extends LayerComponent implements OnInit, OnCha @Input() zIndex: number; - source: Image; - constructor(map: MapComponent, @Optional() group?: LayerGroupComponent) { super(group || map); } diff --git a/projects/ngx-openlayers/src/lib/layers/layertile.component.ts b/projects/ng-openlayers/src/lib/layers/layertile.component.ts similarity index 86% rename from projects/ngx-openlayers/src/lib/layers/layertile.component.ts rename to projects/ng-openlayers/src/lib/layers/layertile.component.ts index 0489508..cfffe67 100644 --- a/projects/ngx-openlayers/src/lib/layers/layertile.component.ts +++ b/projects/ng-openlayers/src/lib/layers/layertile.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnChanges, OnDestroy, OnInit, Optional, SimpleChanges } from '@angular/core'; +import { Component, OnDestroy, OnInit, Input, Optional, OnChanges, SimpleChanges } from '@angular/core'; import { Tile } from 'ol/layer'; import { MapComponent } from '../map.component'; import { LayerComponent } from './layer.component'; @@ -14,8 +14,6 @@ export class LayerTileComponent extends LayerComponent implements OnInit, OnDest @Input() useInterimTilesOnError: boolean; - source: Tile; - constructor(map: MapComponent, @Optional() group?: LayerGroupComponent) { super(group || map); } diff --git a/projects/ngx-openlayers/src/lib/layers/layervector.component.ts b/projects/ng-openlayers/src/lib/layers/layervector.component.ts similarity index 88% rename from projects/ngx-openlayers/src/lib/layers/layervector.component.ts rename to projects/ng-openlayers/src/lib/layers/layervector.component.ts index 65c6806..0683909 100644 --- a/projects/ngx-openlayers/src/lib/layers/layervector.component.ts +++ b/projects/ng-openlayers/src/lib/layers/layervector.component.ts @@ -1,8 +1,8 @@ -import { Component, Input, OnChanges, OnDestroy, OnInit, Optional, SimpleChanges } from '@angular/core'; +import { Component, OnDestroy, OnInit, Input, Optional, OnChanges, SimpleChanges } from '@angular/core'; +import { MapComponent } from '../map.component'; import { Vector } from 'ol/layer'; import { Style } from 'ol/style'; import { StyleFunction } from 'ol/style/Style'; -import { MapComponent } from '../map.component'; import { LayerComponent } from './layer.component'; import { LayerGroupComponent } from './layergroup.component'; @@ -23,8 +23,6 @@ export class LayerVectorComponent extends LayerComponent implements OnInit, OnDe @Input() updateWhileInteracting: boolean; - source: Vector; - constructor(map: MapComponent, @Optional() group?: LayerGroupComponent) { super(group || map); } diff --git a/projects/ngx-openlayers/src/lib/layers/layervectortile.component.ts b/projects/ng-openlayers/src/lib/layers/layervectortile.component.ts similarity index 93% rename from projects/ngx-openlayers/src/lib/layers/layervectortile.component.ts rename to projects/ng-openlayers/src/lib/layers/layervectortile.component.ts index c50d8f9..770aa6a 100644 --- a/projects/ngx-openlayers/src/lib/layers/layervectortile.component.ts +++ b/projects/ng-openlayers/src/lib/layers/layervectortile.component.ts @@ -1,6 +1,5 @@ import { Component, OnInit, Input, Optional, SimpleChanges, OnChanges } from '@angular/core'; import { VectorTile } from 'ol/layer'; -import { RenderType } from 'ol/layer/VectorTile'; import { Feature } from 'ol'; import { Style } from 'ol/style'; import { MapComponent } from '../map.component'; @@ -16,7 +15,7 @@ export class LayerVectorTileComponent extends LayerComponent implements OnInit, @Input() renderBuffer: number; @Input() - renderMode: RenderType | string; + renderMode: any | string; /* not marked as optional in the typings */ @Input() renderOrder: (feature1: Feature, feature2: Feature) => number; diff --git a/projects/ng-openlayers/src/lib/map.component.ts b/projects/ng-openlayers/src/lib/map.component.ts new file mode 100644 index 0000000..f6b4e9e --- /dev/null +++ b/projects/ng-openlayers/src/lib/map.component.ts @@ -0,0 +1,142 @@ +import { + Component, + OnInit, + ElementRef, + Input, + Output, + EventEmitter, + AfterViewInit, + SimpleChanges, + OnChanges, +} from '@angular/core'; +import { Map } from 'ol'; +import MapBrowserEvent from 'ol/MapBrowserEvent'; +import MapEvent from 'ol/MapEvent'; +import { ObjectEvent } from 'ol/Object'; +import RenderEvent from 'ol/render/Event'; +import { Control } from 'ol/control'; +import { Interaction } from 'ol/interaction'; +import { DrawEvent } from 'ol/interaction/Draw'; +import BaseEvent from 'ol/events/Event'; + +@Component({ + selector: 'aol-map', + template: ` +
+ + `, +}) +export class MapComponent implements OnInit, AfterViewInit, OnChanges { + @Input() + width = '100%'; + @Input() + height = '100%'; + @Input() + pixelRatio: number; + @Input() + keyboardEventTarget: HTMLElement | string; + @Input() + loadTilesWhileAnimating: boolean; + @Input() + loadTilesWhileInteracting: boolean; + @Input() + logo: string | boolean; + @Input() + renderer: 'canvas' | 'webgl'; + + @Output() + olChange = new EventEmitter(); + @Output() + olChangeLayerGroup = new EventEmitter(); + @Output() + olChangeSize = new EventEmitter(); + @Output() + olChangeTarget = new EventEmitter(); + @Output() + olChangeView = new EventEmitter(); + @Output() + olClick = new EventEmitter>(); + @Output() + dblClick = new EventEmitter>(); + @Output() + olError = new EventEmitter(); + @Output() + loadEnd = new EventEmitter(); + @Output() + loadStart = new EventEmitter(); + @Output() + moveEnd = new EventEmitter(); + @Output() + moveStart = new EventEmitter(); + @Output() + pointerDrag = new EventEmitter>(); + @Output() + pointerMove = new EventEmitter>(); + @Output() + olPostCompose = new EventEmitter(); + @Output() + olPostRender = new EventEmitter(); + @Output() + olPreCompose = new EventEmitter(); + @Output() + olPropertyChange = new EventEmitter(); + @Output() + postRender = new EventEmitter(); + @Output() + propertyChange = new EventEmitter(); + @Output() + singleClick = new EventEmitter>(); + + public instance: Map; + public componentType = 'map'; + + // we pass empty arrays to not get default controls/interactions because we have our own directives + controls: Control[] = []; + interactions: Interaction[] = []; + + constructor(private host: ElementRef) {} + + ngOnInit() { + // console.log('creating ol.Map instance with:', this); + this.instance = new Map(this); + this.instance.setTarget(this.host.nativeElement.firstElementChild); + this.instance.on('change', (event: DrawEvent) => this.olChange.emit(event)); + this.instance.on('change:layergroup', (event: ObjectEvent) => this.olChangeLayerGroup.emit(event)); + this.instance.on('change:size', (event: ObjectEvent) => this.olChangeSize.emit(event)); + this.instance.on('change:target', (event: ObjectEvent) => this.olChangeTarget.emit(event)); + this.instance.on('change:view', (event: ObjectEvent) => this.olChangeView.emit(event)); + this.instance.on('click', (event: MapBrowserEvent) => this.olClick.emit(event)); + this.instance.on('dblclick', (event: MapBrowserEvent) => this.dblClick.emit(event)); + this.instance.on('error', (event: BaseEvent) => this.olError.emit(event)); + this.instance.on('loadend', (event: MapEvent) => this.loadEnd.emit(event)); + this.instance.on('loadstart', (event: MapEvent) => this.loadStart.emit(event)); + this.instance.on('moveend', (event: MapEvent) => this.moveEnd.emit(event)); + this.instance.on('movestart', (event: MapEvent) => this.moveStart.emit(event)); + this.instance.on('pointerdrag', (event: MapBrowserEvent) => this.pointerDrag.emit(event)); + this.instance.on('pointermove', (event: MapBrowserEvent) => this.pointerMove.emit(event)); + this.instance.on('postcompose', (event: RenderEvent) => this.olPostCompose.emit(event)); + this.instance.on('postrender', (event: RenderEvent) => this.olPostRender.emit(event)); + this.instance.on('postrender', (event: MapEvent) => this.postRender.emit(event)); + this.instance.on('precompose', (event: RenderEvent) => this.olPreCompose.emit(event)); + this.instance.on('propertychange', (event: ObjectEvent) => this.olPropertyChange.emit(event)); + this.instance.on('singleclick', (event: MapBrowserEvent) => this.singleClick.emit(event)); + } + + ngOnChanges(changes: SimpleChanges) { + const properties: { [index: string]: any } = {}; + if (!this.instance) { + return; + } + for (const key in changes) { + if (changes.hasOwnProperty(key)) { + properties[key] = changes[key].currentValue; + } + } + // console.log('changes detected in aol-map, setting new properties: ', properties); + this.instance.setProperties(properties, false); + } + + ngAfterViewInit() { + this.instance.updateSize(); + } +} diff --git a/projects/ngx-openlayers/src/lib/overlay.component.ts b/projects/ng-openlayers/src/lib/overlay.component.ts similarity index 86% rename from projects/ngx-openlayers/src/lib/overlay.component.ts rename to projects/ng-openlayers/src/lib/overlay.component.ts index 6cea458..55a98d2 100644 --- a/projects/ngx-openlayers/src/lib/overlay.component.ts +++ b/projects/ng-openlayers/src/lib/overlay.component.ts @@ -1,8 +1,7 @@ import { Component, ContentChild, Input, OnDestroy, OnInit } from '@angular/core'; -import { Overlay, PanOptions } from 'ol'; -import OverlayPositioning from 'ol/OverlayPositioning'; -import { ContentComponent } from './content.component'; import { MapComponent } from './map.component'; +import Overlay, { PanOptions, Positioning } from 'ol/Overlay'; +import { ContentComponent } from './content.component'; @Component({ selector: 'aol-overlay', @@ -17,7 +16,7 @@ export class OverlayComponent implements OnInit, OnDestroy { @Input() offset: number[]; @Input() - positioning: OverlayPositioning | string; + positioning: Positioning; @Input() stopEvent: boolean; @Input() @@ -31,7 +30,7 @@ export class OverlayComponent implements OnInit, OnDestroy { componentType = 'overlay'; instance: Overlay; - element: Element; + element: HTMLElement; constructor(private map: MapComponent) {} diff --git a/projects/ngx-openlayers/src/lib/sources/bingmaps.component.ts b/projects/ng-openlayers/src/lib/sources/bingmaps.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/sources/bingmaps.component.ts rename to projects/ng-openlayers/src/lib/sources/bingmaps.component.ts index 1eeb7d1..fd50eb9 100644 --- a/projects/ngx-openlayers/src/lib/sources/bingmaps.component.ts +++ b/projects/ng-openlayers/src/lib/sources/bingmaps.component.ts @@ -1,8 +1,8 @@ import { Component, Host, Input, OnInit, forwardRef } from '@angular/core'; -import { LoadFunction } from 'ol/Tile'; import { BingMaps } from 'ol/source'; -import { LayerTileComponent } from '../layers/layertile.component'; import { SourceComponent } from './source.component'; +import { LayerTileComponent } from '../layers/layertile.component'; +import { LoadFunction } from 'ol/Tile'; @Component({ selector: 'aol-source-bingmaps', diff --git a/projects/ngx-openlayers/src/lib/sources/cluster.component.ts b/projects/ng-openlayers/src/lib/sources/cluster.component.ts similarity index 95% rename from projects/ngx-openlayers/src/lib/sources/cluster.component.ts rename to projects/ng-openlayers/src/lib/sources/cluster.component.ts index b732a8c..4d041f9 100644 --- a/projects/ngx-openlayers/src/lib/sources/cluster.component.ts +++ b/projects/ng-openlayers/src/lib/sources/cluster.component.ts @@ -29,10 +29,11 @@ export class SourceClusterComponent extends SourceComponent implements AfterCont @Input() wrapX?: boolean; - @ContentChild(SourceVectorComponent) + @ContentChild(SourceVectorComponent, { static: false }) sourceVectorComponent: SourceVectorComponent; - source: Vector; + instance: Cluster; + source: Vector; constructor(@Host() layer: LayerVectorComponent) { super(layer); diff --git a/projects/ngx-openlayers/src/lib/sources/geojson.component.ts b/projects/ng-openlayers/src/lib/sources/geojson.component.ts similarity index 93% rename from projects/ngx-openlayers/src/lib/sources/geojson.component.ts rename to projects/ng-openlayers/src/lib/sources/geojson.component.ts index 5f9f734..834899c 100644 --- a/projects/ngx-openlayers/src/lib/sources/geojson.component.ts +++ b/projects/ng-openlayers/src/lib/sources/geojson.component.ts @@ -1,10 +1,10 @@ import { Component, Host, Input, OnInit, forwardRef } from '@angular/core'; -import { Feature } from 'ol'; -import { GeoJSON } from 'ol/format'; -import { ProjectionLike } from 'ol/proj'; -import { Vector } from 'ol/source'; import { LayerVectorComponent } from '../layers/layervector.component'; import { SourceComponent } from './source.component'; +import FeatureFormat from 'ol/format/Feature'; +import { Vector } from 'ol/source'; +import { GeoJSON } from 'ol/format'; +import { ProjectionLike } from 'ol/proj'; @Component({ selector: 'aol-source-geojson', @@ -22,7 +22,7 @@ export class SourceGeoJSONComponent extends SourceComponent implements OnInit { url: string; instance: Vector; - format: Feature; + format: FeatureFormat; constructor(@Host() layer: LayerVectorComponent) { super(layer); diff --git a/projects/ngx-openlayers/src/lib/sources/imagearcgisrest.component.ts b/projects/ng-openlayers/src/lib/sources/imagearcgisrest.component.ts similarity index 95% rename from projects/ngx-openlayers/src/lib/sources/imagearcgisrest.component.ts rename to projects/ng-openlayers/src/lib/sources/imagearcgisrest.component.ts index 9d964f0..1da725b 100644 --- a/projects/ngx-openlayers/src/lib/sources/imagearcgisrest.component.ts +++ b/projects/ng-openlayers/src/lib/sources/imagearcgisrest.component.ts @@ -9,13 +9,13 @@ import { Output, SimpleChanges, } from '@angular/core'; -import { LoadFunction } from 'ol/Image'; -import { ProjectionLike } from 'ol/proj'; -import { ImageArcGISRest } from 'ol/source'; -import { ImageSourceEvent } from 'ol/source/Image'; -import { AttributionLike } from 'ol/source/Source'; +import ImageArcGISRest from 'ol/source/ImageArcGISRest'; import { LayerImageComponent } from '../layers/layerimage.component'; import { SourceComponent } from './source.component'; +import { ProjectionLike } from 'ol/proj'; +import { AttributionLike } from 'ol/source/Source'; +import { LoadFunction } from 'ol/Image'; +import { ImageSourceEvent } from 'ol/source/Image'; @Component({ selector: 'aol-source-imagearcgisrest', @@ -25,7 +25,7 @@ import { SourceComponent } from './source.component'; export class SourceImageArcGISRestComponent extends SourceComponent implements OnInit, OnChanges { @Input() projection: ProjectionLike | string; @Input() url: string; - @Input() attributions: AttributionLike[]; + @Input() attributions: AttributionLike; @Input() crossOrigin?: string; @Input() imageLoadFunction?: LoadFunction; @Input() params?: { [k: string]: any }; diff --git a/projects/ngx-openlayers/src/lib/sources/imagestatic.component.ts b/projects/ng-openlayers/src/lib/sources/imagestatic.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/sources/imagestatic.component.ts rename to projects/ng-openlayers/src/lib/sources/imagestatic.component.ts index 0df3044..c3ab7e3 100644 --- a/projects/ngx-openlayers/src/lib/sources/imagestatic.component.ts +++ b/projects/ng-openlayers/src/lib/sources/imagestatic.component.ts @@ -1,23 +1,23 @@ import { Component, - EventEmitter, Host, Input, - OnChanges, - OnInit, - Output, - SimpleChanges, forwardRef, + Output, + EventEmitter, + OnChanges, + SimpleChanges, + OnInit, } from '@angular/core'; -import { LoadFunction } from 'ol/Image'; -import { Extent } from 'ol/extent'; -import { ProjectionLike } from 'ol/proj'; -import { Size } from 'ol/size'; import { ImageStatic } from 'ol/source'; -import { ImageSourceEvent } from 'ol/source/Image'; -import { AttributionLike } from 'ol/source/Source'; -import { LayerImageComponent } from '../layers/layerimage.component'; import { SourceComponent } from './source.component'; +import { LayerImageComponent } from '../layers/layerimage.component'; +import { ProjectionLike } from 'ol/proj'; +import { Extent } from 'ol/extent'; +import { AttributionLike } from 'ol/source/Source'; +import { LoadFunction } from 'ol/Image'; +import { Size } from 'ol/size'; +import { ImageSourceEvent } from 'ol/source/Image'; @Component({ selector: 'aol-source-imagestatic', diff --git a/projects/ngx-openlayers/src/lib/sources/imagewms.component.ts b/projects/ng-openlayers/src/lib/sources/imagewms.component.ts similarity index 96% rename from projects/ngx-openlayers/src/lib/sources/imagewms.component.ts rename to projects/ng-openlayers/src/lib/sources/imagewms.component.ts index 2fc085d..286a770 100644 --- a/projects/ngx-openlayers/src/lib/sources/imagewms.component.ts +++ b/projects/ng-openlayers/src/lib/sources/imagewms.component.ts @@ -16,6 +16,7 @@ import { ProjectionLike } from 'ol/proj'; import { AttributionLike } from 'ol/source/Source'; import { LoadFunction } from 'ol/Image'; import { ImageSourceEvent } from 'ol/source/Image'; +import { ServerType } from 'ol/source/WMSServerType'; @Component({ selector: 'aol-source-imagewms', @@ -30,7 +31,7 @@ export class SourceImageWMSComponent extends SourceComponent implements OnChange @Input() hidpi: boolean; @Input() - serverType: string; + serverType: ServerType; @Input() imageLoadFunction?: LoadFunction; @Input() diff --git a/projects/ngx-openlayers/src/lib/sources/osm.component.ts b/projects/ng-openlayers/src/lib/sources/osm.component.ts similarity index 85% rename from projects/ngx-openlayers/src/lib/sources/osm.component.ts rename to projects/ng-openlayers/src/lib/sources/osm.component.ts index 62cf7c4..d768643 100644 --- a/projects/ngx-openlayers/src/lib/sources/osm.component.ts +++ b/projects/ng-openlayers/src/lib/sources/osm.component.ts @@ -33,11 +33,11 @@ export class SourceOsmComponent extends SourceXYZComponent implements AfterConte wrapX: boolean; @Output() - tileLoadStart: EventEmitter = new EventEmitter(); + tileLoadStart = new EventEmitter(); @Output() - tileLoadEnd: EventEmitter = new EventEmitter(); + tileLoadEnd = new EventEmitter(); @Output() - tileLoadError: EventEmitter = new EventEmitter(); + tileLoadError = new EventEmitter(); instance: OSM; @@ -53,12 +53,10 @@ export class SourceOsmComponent extends SourceXYZComponent implements AfterConte if (this.tileGridXYZ) { this.tileGrid = this.tileGridXYZ.instance; } - this.instance = new OSM(this); - this.instance.on('tileloadstart', (event: TileSourceEvent) => this.tileLoadStart.emit(event)); this.instance.on('tileloadend', (event: TileSourceEvent) => this.tileLoadEnd.emit(event)); this.instance.on('tileloaderror', (event: TileSourceEvent) => this.tileLoadError.emit(event)); - this._register(this.instance); + this.register(this.instance); } } diff --git a/projects/ngx-openlayers/src/lib/sources/raster.component.ts b/projects/ng-openlayers/src/lib/sources/raster.component.ts similarity index 78% rename from projects/ngx-openlayers/src/lib/sources/raster.component.ts rename to projects/ng-openlayers/src/lib/sources/raster.component.ts index b091aa5..b65073b 100644 --- a/projects/ngx-openlayers/src/lib/sources/raster.component.ts +++ b/projects/ng-openlayers/src/lib/sources/raster.component.ts @@ -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'; @@ -32,21 +32,17 @@ export class SourceRasterComponent extends SourceComponent implements AfterConte @Input() lib?: any; @Input() - operationType?: RasterOperationType; + operationType?: 'pixel' | 'image'; @Output() - beforeOperations: EventEmitter = new EventEmitter(); + beforeOperations = new EventEmitter(); @Output() - afterOperations: EventEmitter = new EventEmitter(); + afterOperations = new EventEmitter(); instance: Raster; sources: Source[] = []; - constructor(@Host() layer: LayerImageComponent) { - super(layer); - } - - @ContentChild(SourceComponent) + @ContentChild(SourceComponent, { static: false }) set source(sourceComponent: SourceComponent) { this.sources = [sourceComponent.instance]; if (this.instance) { @@ -55,6 +51,10 @@ export class SourceRasterComponent extends SourceComponent implements AfterConte } } + constructor(@Host() layer: LayerImageComponent) { + super(layer); + } + ngAfterContentInit() { this.init(); } @@ -63,6 +63,6 @@ export class SourceRasterComponent extends SourceComponent implements AfterConte this.instance = new Raster(this); this.instance.on('beforeoperations', (event: RasterSourceEvent) => this.beforeOperations.emit(event)); this.instance.on('afteroperations', (event: RasterSourceEvent) => this.afterOperations.emit(event)); - this._register(this.instance); + this.register(this.instance); } } diff --git a/projects/ngx-openlayers/src/lib/sources/source.component.ts b/projects/ng-openlayers/src/lib/sources/source.component.ts similarity index 61% rename from projects/ngx-openlayers/src/lib/sources/source.component.ts rename to projects/ng-openlayers/src/lib/sources/source.component.ts index 252339c..22e7201 100644 --- a/projects/ngx-openlayers/src/lib/sources/source.component.ts +++ b/projects/ng-openlayers/src/lib/sources/source.component.ts @@ -1,9 +1,10 @@ -import { Directive, Input, OnDestroy } from '@angular/core'; -import { Source } from 'ol'; +import { Input, OnDestroy, Directive } from '@angular/core'; +import Source from 'ol/source/Source'; import { LayerComponent } from '../layers/layer.component'; @Directive() +// eslint-disable-next-line @angular-eslint/directive-class-suffix export abstract class SourceComponent implements OnDestroy { @Input() attributions: any; @@ -11,7 +12,7 @@ export abstract class SourceComponent implements OnDestroy { public instance: Source; public componentType = 'source'; - constructor(protected host: LayerComponent) {} + protected constructor(protected host: LayerComponent) {} ngOnDestroy() { if (this.host && this.host.instance) { @@ -19,7 +20,7 @@ export abstract class SourceComponent implements OnDestroy { } } - protected _register(s: Source) { + protected register(s: Source) { if (this.host) { this.host.instance.setSource(s); } diff --git a/projects/ngx-openlayers/src/lib/sources/tilejson.component.ts b/projects/ng-openlayers/src/lib/sources/tilejson.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/sources/tilejson.component.ts rename to projects/ng-openlayers/src/lib/sources/tilejson.component.ts diff --git a/projects/ngx-openlayers/src/lib/sources/tilewms.component.ts b/projects/ng-openlayers/src/lib/sources/tilewms.component.ts similarity index 91% rename from projects/ngx-openlayers/src/lib/sources/tilewms.component.ts rename to projects/ng-openlayers/src/lib/sources/tilewms.component.ts index c2fe0fc..702f393 100644 --- a/projects/ngx-openlayers/src/lib/sources/tilewms.component.ts +++ b/projects/ng-openlayers/src/lib/sources/tilewms.component.ts @@ -2,8 +2,9 @@ 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'; +import { ServerType } from 'ol/source/WMSServerType'; @Component({ selector: 'aol-source-tilewms', @@ -26,7 +27,7 @@ export class SourceTileWMSComponent extends SourceComponent implements OnChanges @Input() reprojectionErrorThreshold: number; @Input() - serverType: string; + serverType: ServerType; @Input() tileGrid: TileGrid; @Input() diff --git a/projects/ngx-openlayers/src/lib/sources/tilewmts.component.ts b/projects/ng-openlayers/src/lib/sources/tilewmts.component.ts similarity index 82% rename from projects/ngx-openlayers/src/lib/sources/tilewmts.component.ts rename to projects/ng-openlayers/src/lib/sources/tilewmts.component.ts index 1cbf51c..d352c9d 100644 --- a/projects/ngx-openlayers/src/lib/sources/tilewmts.component.ts +++ b/projects/ng-openlayers/src/lib/sources/tilewmts.component.ts @@ -13,12 +13,12 @@ import { 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 { WMTS as SourceWMTS } from 'ol/source'; +import WMTS from 'ol/tilegrid/WMTS'; import { ProjectionLike } from 'ol/proj'; import { LoadFunction } from 'ol/Tile'; import { TileSourceEvent } from 'ol/source/Tile'; +import { RequestEncoding } from 'ol/source/WMTS'; @Component({ selector: 'aol-source-tilewmts', @@ -31,13 +31,13 @@ export class SourceTileWMTSComponent extends SourceComponent implements AfterCon @Input() crossOrigin?: string; @Input() - tileGrid: TileGridWMTS; + tileGrid: WMTS; @Input() projection: ProjectionLike; @Input() reprojectionErrorThreshold?: number; @Input() - requestEncoding?: WMTSRequestEncoding | string; + requestEncoding?: RequestEncoding | undefined; @Input() layer: string; @Input() @@ -64,16 +64,16 @@ export class SourceTileWMTSComponent extends SourceComponent implements AfterCon wrapX?: boolean; @Output() - tileLoadStart: EventEmitter = new EventEmitter(); + tileLoadStart = new EventEmitter(); @Output() - tileLoadEnd: EventEmitter = new EventEmitter(); + tileLoadEnd = new EventEmitter(); @Output() - tileLoadError: EventEmitter = new EventEmitter(); + tileLoadError = new EventEmitter(); - @ContentChild(TileGridWMTSComponent) + @ContentChild(TileGridWMTSComponent, { static: false }) tileGridWMTS: TileGridWMTSComponent; - instance: WMTS; + instance: SourceWMTS; constructor(@Host() layer: LayerTileComponent) { super(layer); @@ -101,7 +101,7 @@ export class SourceTileWMTSComponent extends SourceComponent implements AfterCon } setLayerSource(): void { - this.instance = new WMTS(this); + this.instance = new SourceWMTS(this); this.instance.on('tileloadstart', (event: TileSourceEvent) => this.tileLoadStart.emit(event)); this.instance.on('tileloadend', (event: TileSourceEvent) => this.tileLoadEnd.emit(event)); this.instance.on('tileloaderror', (event: TileSourceEvent) => this.tileLoadError.emit(event)); diff --git a/projects/ngx-openlayers/src/lib/sources/utfgrid.component.ts b/projects/ng-openlayers/src/lib/sources/utfgrid.component.ts similarity index 90% rename from projects/ngx-openlayers/src/lib/sources/utfgrid.component.ts rename to projects/ng-openlayers/src/lib/sources/utfgrid.component.ts index 6dfa57c..ba79294 100644 --- a/projects/ngx-openlayers/src/lib/sources/utfgrid.component.ts +++ b/projects/ng-openlayers/src/lib/sources/utfgrid.component.ts @@ -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', @@ -9,7 +10,7 @@ import { UTFGrid } from 'ol/source'; providers: [{ provide: SourceComponent, useExisting: forwardRef(() => SourceUTFGridComponent) }], }) export class SourceUTFGridComponent extends SourceComponent implements OnInit { - @Input() tileJSON: JSON; + @Input() tileJSON: Config; @Input() url: string; instance: UTFGrid; diff --git a/projects/ngx-openlayers/src/lib/sources/vector.component.ts b/projects/ng-openlayers/src/lib/sources/vector.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/sources/vector.component.ts rename to projects/ng-openlayers/src/lib/sources/vector.component.ts diff --git a/projects/ngx-openlayers/src/lib/sources/vectortile.component.ts b/projects/ng-openlayers/src/lib/sources/vectortile.component.ts similarity index 90% rename from projects/ngx-openlayers/src/lib/sources/vectortile.component.ts rename to projects/ng-openlayers/src/lib/sources/vectortile.component.ts index 75ba2c9..e3ce85e 100644 --- a/projects/ngx-openlayers/src/lib/sources/vectortile.component.ts +++ b/projects/ng-openlayers/src/lib/sources/vectortile.component.ts @@ -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'; @@ -32,16 +32,15 @@ export class SourceVectorTileComponent extends SourceComponent implements AfterC @Input() wrapX: boolean; - @ContentChild(FormatComponent) + @ContentChild(FormatComponent, { static: false }) formatComponent: FormatComponent; - @ContentChild(TileGridComponent) + @ContentChild(TileGridComponent, { static: false }) tileGridComponent: TileGridComponent; + public instance: VectorTile; format: Feature; tileGrid: TileGrid; - instance: VectorTile; - constructor(@Host() layer: LayerVectorTileComponent) { super(layer); } diff --git a/projects/ngx-openlayers/src/lib/sources/xyz.component.ts b/projects/ng-openlayers/src/lib/sources/xyz.component.ts similarity index 88% rename from projects/ngx-openlayers/src/lib/sources/xyz.component.ts rename to projects/ng-openlayers/src/lib/sources/xyz.component.ts index fd869e3..a6478ff 100644 --- a/projects/ngx-openlayers/src/lib/sources/xyz.component.ts +++ b/projects/ng-openlayers/src/lib/sources/xyz.component.ts @@ -58,15 +58,15 @@ export class SourceXYZComponent extends SourceComponent implements AfterContentI @Input() wrapX: boolean; - @ContentChild(TileGridComponent) + @ContentChild(TileGridComponent, { static: false }) tileGridXYZ: TileGridComponent; @Output() - tileLoadStart: EventEmitter = new EventEmitter(); + tileLoadStart = new EventEmitter(); @Output() - tileLoadEnd: EventEmitter = new EventEmitter(); + tileLoadEnd = new EventEmitter(); @Output() - tileLoadError: EventEmitter = new EventEmitter(); + tileLoadError = new EventEmitter(); instance: XYZ; @@ -110,6 +110,6 @@ export class SourceXYZComponent extends SourceComponent implements AfterContentI this.instance.on('tileloadend', (event: TileSourceEvent) => this.tileLoadEnd.emit(event)); this.instance.on('tileloaderror', (event: TileSourceEvent) => this.tileLoadError.emit(event)); - this._register(this.instance); + this.register(this.instance); } } diff --git a/projects/ngx-openlayers/src/lib/styles/circle.component.ts b/projects/ng-openlayers/src/lib/styles/circle.component.ts similarity index 90% rename from projects/ngx-openlayers/src/lib/styles/circle.component.ts rename to projects/ng-openlayers/src/lib/styles/circle.component.ts index 78c5586..dc4d1a1 100644 --- a/projects/ngx-openlayers/src/lib/styles/circle.component.ts +++ b/projects/ng-openlayers/src/lib/styles/circle.component.ts @@ -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({ @@ -15,11 +15,9 @@ export class StyleCircleComponent implements AfterContentInit, OnChanges, OnDest snapToPixel: boolean; @Input() stroke: Stroke; - @Input() - atlasManager: AtlasManager; - componentType = 'style-circle'; - instance: Circle; + public componentType = 'style-circle'; + public instance: Circle; constructor(@Host() private host: StyleComponent) {} diff --git a/projects/ngx-openlayers/src/lib/styles/fill.component.ts b/projects/ng-openlayers/src/lib/styles/fill.component.ts similarity index 90% rename from projects/ngx-openlayers/src/lib/styles/fill.component.ts rename to projects/ng-openlayers/src/lib/styles/fill.component.ts index a577716..38caace 100644 --- a/projects/ngx-openlayers/src/lib/styles/fill.component.ts +++ b/projects/ng-openlayers/src/lib/styles/fill.component.ts @@ -14,9 +14,8 @@ export class StyleFillComponent implements OnInit, OnChanges { @Input() color: Color | ColorLike; - instance: Fill; - /* the typings do not have the setters */ - private host: /*StyleComponent|StyleCircleComponent|StyleTextComponent*/ any; + public instance: Fill; + private readonly host: StyleComponent | StyleCircleComponent | StyleTextComponent; constructor( @Optional() styleHost: StyleComponent, @@ -48,12 +47,11 @@ export class StyleFillComponent implements OnInit, OnChanges { this.host.instance.setFill(this.instance); break; case 'style-circle': - this.host.fill = this.instance; + (this.host as StyleCircleComponent).fill = this.instance; // console.log('setting ol.style.circle instance\'s fill:', this.host); break; default: throw new Error('unknown host type: ' + this.host); - // break; } } diff --git a/projects/ngx-openlayers/src/lib/styles/icon.component.ts b/projects/ng-openlayers/src/lib/styles/icon.component.ts similarity index 85% rename from projects/ngx-openlayers/src/lib/styles/icon.component.ts rename to projects/ng-openlayers/src/lib/styles/icon.component.ts index d9e7731..ed67c2a 100644 --- a/projects/ngx-openlayers/src/lib/styles/icon.component.ts +++ b/projects/ng-openlayers/src/lib/styles/icon.component.ts @@ -1,8 +1,11 @@ import { Component, Input, Host, OnInit, OnChanges, SimpleChanges } from '@angular/core'; import { Icon } from 'ol/style'; -import IconAnchorUnits from 'ol/style/IconAnchorUnits'; -import IconOrigin from 'ol/style/IconOrigin'; + +// TODO https://github.com/openlayers/openlayers/issues/12694 +// import IconAnchorUnits from 'ol/style/IconAnchorUnits'; +// import IconOrigin from 'ol/style/IconOrigin'; import { StyleComponent } from './style.component'; +import { IconAnchorUnits, IconOrigin } from 'ol/style/Icon'; @Component({ selector: 'aol-style-icon', @@ -22,7 +25,7 @@ export class StyleIconComponent implements OnInit, OnChanges { @Input() crossOrigin: IconOrigin; @Input() - img: string; + img: HTMLCanvasElement | HTMLImageElement; @Input() offset: [number, number]; @Input() @@ -44,7 +47,7 @@ export class StyleIconComponent implements OnInit, OnChanges { @Input() src: string; - instance: Icon; + public instance: Icon; constructor(@Host() private host: StyleComponent) {} diff --git a/projects/ngx-openlayers/src/lib/styles/stroke.component.ts b/projects/ng-openlayers/src/lib/styles/stroke.component.ts similarity index 91% rename from projects/ngx-openlayers/src/lib/styles/stroke.component.ts rename to projects/ng-openlayers/src/lib/styles/stroke.component.ts index fa0afd0..a67bfe7 100644 --- a/projects/ngx-openlayers/src/lib/styles/stroke.component.ts +++ b/projects/ng-openlayers/src/lib/styles/stroke.component.ts @@ -14,19 +14,19 @@ export class StyleStrokeComponent implements OnInit, OnChanges { @Input() color: Color | ColorLike; @Input() - lineCap: string; + lineCap: CanvasLineCap | undefined; @Input() lineDash: number[]; @Input() - lineJoin: string; + lineJoin: CanvasLineJoin | undefined; @Input() miterLimit: number; @Input() width: number; - instance: Stroke; + public instance: Stroke; /* the typings do not have the setters */ - host: /*StyleComponent|StyleCircleComponent|StyleTextComponent*/ any; + private readonly host: StyleComponent | StyleCircleComponent | StyleTextComponent; constructor( @Optional() styleHost: StyleComponent, @@ -58,7 +58,7 @@ export class StyleStrokeComponent implements OnInit, OnChanges { this.host.instance.setStroke(this.instance); break; case 'style-circle': - this.host.stroke = this.instance; + (this.host as StyleCircleComponent).stroke = this.instance; // console.log('setting ol.style.circle instance\'s stroke:', this.host); break; default: diff --git a/projects/ngx-openlayers/src/lib/styles/style.component.ts b/projects/ng-openlayers/src/lib/styles/style.component.ts similarity index 90% rename from projects/ngx-openlayers/src/lib/styles/style.component.ts rename to projects/ng-openlayers/src/lib/styles/style.component.ts index 92cec3d..7952886 100644 --- a/projects/ngx-openlayers/src/lib/styles/style.component.ts +++ b/projects/ng-openlayers/src/lib/styles/style.component.ts @@ -23,9 +23,9 @@ export class StyleComponent implements OnInit { @Input() zIndex: number; - instance: Style; - componentType = 'style'; - private host: FeatureComponent | LayerVectorComponent; + public instance: Style; + public componentType = 'style'; + private readonly host: FeatureComponent | LayerVectorComponent; constructor(@Optional() featureHost: FeatureComponent, @Optional() layerHost: LayerVectorComponent) { // console.log('creating aol-style'); diff --git a/projects/ngx-openlayers/src/lib/styles/text.component.ts b/projects/ng-openlayers/src/lib/styles/text.component.ts similarity index 94% rename from projects/ngx-openlayers/src/lib/styles/text.component.ts rename to projects/ng-openlayers/src/lib/styles/text.component.ts index f6848bd..3412214 100644 --- a/projects/ngx-openlayers/src/lib/styles/text.component.ts +++ b/projects/ng-openlayers/src/lib/styles/text.component.ts @@ -22,12 +22,12 @@ export class StyleTextComponent implements OnInit, OnChanges { @Input() text: string | undefined; @Input() - textAlign: string | undefined; + textAlign: CanvasTextAlign | undefined; @Input() textBaseLine: string | undefined; - instance: Text; - componentType = 'style-text'; + public instance: Text; + public componentType = 'style-text'; constructor(@Optional() private host: StyleComponent) { if (!host) { @@ -73,4 +73,6 @@ export class StyleTextComponent implements OnInit, OnChanges { this.host.update(); // console.log('changes detected in aol-style-text, setting new properties: ', changes); } + + update() {} } diff --git a/projects/ngx-openlayers/src/lib/tilegrid.component.ts b/projects/ng-openlayers/src/lib/tilegrid.component.ts similarity index 100% rename from projects/ngx-openlayers/src/lib/tilegrid.component.ts rename to projects/ng-openlayers/src/lib/tilegrid.component.ts diff --git a/projects/ngx-openlayers/src/lib/tilegridwmts.component.ts b/projects/ng-openlayers/src/lib/tilegridwmts.component.ts similarity index 95% rename from projects/ngx-openlayers/src/lib/tilegridwmts.component.ts rename to projects/ng-openlayers/src/lib/tilegridwmts.component.ts index 5fc658c..d95459d 100644 --- a/projects/ngx-openlayers/src/lib/tilegridwmts.component.ts +++ b/projects/ng-openlayers/src/lib/tilegridwmts.component.ts @@ -20,7 +20,7 @@ export class TileGridWMTSComponent extends TileGridComponent implements OnInit { @Input() sizes?: Size[]; @Input() - tileSizes?: (number | Size)[]; + tileSizes?: Size[]; @Input() widths?: number[]; diff --git a/projects/ngx-openlayers/src/lib/view.component.ts b/projects/ng-openlayers/src/lib/view.component.ts similarity index 76% rename from projects/ngx-openlayers/src/lib/view.component.ts rename to projects/ng-openlayers/src/lib/view.component.ts index b2d6737..ad52505 100644 --- a/projects/ngx-openlayers/src/lib/view.component.ts +++ b/projects/ng-openlayers/src/lib/view.component.ts @@ -1,9 +1,11 @@ import { Component, Input, OnInit, OnChanges, OnDestroy, SimpleChanges, EventEmitter, Output } from '@angular/core'; import View from 'ol/View'; import { MapComponent } from './map.component'; -import { ObjectEvent } from 'ol'; +import { ObjectEvent } from 'ol/Object'; import { Extent } from 'ol/extent'; import { Coordinate } from 'ol/coordinate'; +import { DrawEvent } from 'ol/interaction/Draw'; +import BaseEvent from 'ol/events/Event'; @Component({ selector: 'aol-view', @@ -55,14 +57,20 @@ export class ViewComponent implements OnInit, OnChanges, OnDestroy { zoomAnimation = false; @Output() - changeZoom: EventEmitter = new EventEmitter(); + olChange = new EventEmitter(); @Output() - changeResolution: EventEmitter = new EventEmitter(); + changeCenter = new EventEmitter(); @Output() - changeCenter: EventEmitter = new EventEmitter(); + changeResolution = new EventEmitter(); + @Output() + changeRotation = new EventEmitter(); + @Output() + olError = new EventEmitter(); + @Output() + propertyChange = new EventEmitter(); - instance: View; - componentType = 'view'; + public instance: View; + public componentType = 'view'; constructor(private host: MapComponent) {} @@ -71,9 +79,12 @@ export class ViewComponent implements OnInit, OnChanges, OnDestroy { this.instance = new View(this); this.host.instance.setView(this.instance); - this.instance.on('change:zoom', (event: ObjectEvent) => this.changeZoom.emit(event)); - this.instance.on('change:resolution', (event: ObjectEvent) => this.changeResolution.emit(event)); + this.instance.on('change', (event: DrawEvent) => this.olChange.emit(event)); this.instance.on('change:center', (event: ObjectEvent) => this.changeCenter.emit(event)); + this.instance.on('change:resolution', (event: ObjectEvent) => this.changeResolution.emit(event)); + this.instance.on('change:rotation', (event: ObjectEvent) => this.changeRotation.emit(event)); + this.instance.on('error', (event: BaseEvent) => this.olError.emit(event)); + this.instance.on('propertychange', (event: ObjectEvent) => this.propertyChange.emit(event)); } ngOnChanges(changes: SimpleChanges) { diff --git a/projects/ngx-openlayers/src/public-api.ts b/projects/ng-openlayers/src/public-api.ts similarity index 97% rename from projects/ngx-openlayers/src/public-api.ts rename to projects/ng-openlayers/src/public-api.ts index f682fd0..2ac2fc7 100644 --- a/projects/ngx-openlayers/src/public-api.ts +++ b/projects/ng-openlayers/src/public-api.ts @@ -1,5 +1,5 @@ /* - * Public API Surface of ngx-openlayers + * Public API Surface of ng-openlayers */ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; @@ -68,6 +68,8 @@ import { DragZoomInteractionComponent } from './lib/interactions/dragzoom.compon import { MouseWheelZoomInteractionComponent } from './lib/interactions/mousewheelzoom.component'; import { PinchZoomInteractionComponent } from './lib/interactions/pinchzoom.component'; import { DrawInteractionComponent } from './lib/interactions/draw.component'; +import { KeyboardPanInteractionComponent } from './lib/interactions/keyboardpan.component'; +import { KeyboardZoomInteractionComponent } from './lib/interactions/keyboardzoom.component'; import { SelectInteractionComponent } from './lib/interactions/select.component'; import { ModifyInteractionComponent } from './lib/interactions/modify.component'; import { TranslateInteractionComponent } from './lib/interactions/translate.component'; @@ -146,6 +148,8 @@ export { MouseWheelZoomInteractionComponent, PinchZoomInteractionComponent, DrawInteractionComponent, + KeyboardPanInteractionComponent, + KeyboardZoomInteractionComponent, SelectInteractionComponent, ModifyInteractionComponent, TranslateInteractionComponent, diff --git a/projects/ngx-openlayers/src/test.ts b/projects/ng-openlayers/src/test.ts similarity index 86% rename from projects/ngx-openlayers/src/test.ts rename to projects/ng-openlayers/src/test.ts index 8cd315d..8e2aa10 100644 --- a/projects/ngx-openlayers/src/test.ts +++ b/projects/ng-openlayers/src/test.ts @@ -1,5 +1,6 @@ // This file is required by karma.conf.js and loads recursively all the .spec and framework files +import 'core-js/es7/reflect'; import 'zone.js'; import 'zone.js/testing'; import { getTestBed } from '@angular/core/testing'; @@ -7,5 +8,5 @@ import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@ang // First, initialize the Angular testing environment. getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { - teardown: { destroyAfterEach: true }, + teardown: { destroyAfterEach: false }, }); diff --git a/projects/ng-openlayers/tsconfig.lib.json b/projects/ng-openlayers/tsconfig.lib.json new file mode 100644 index 0000000..95a4337 --- /dev/null +++ b/projects/ng-openlayers/tsconfig.lib.json @@ -0,0 +1,27 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [], + "lib": [ + "dom", + "es2018" + ] + }, + "angularCompilerOptions": { + "skipLibCheck": true, + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "enableResourceInlining": true + }, + "exclude": [ + "src/test.ts", + "**/*.spec.ts" + ], + "include": [ + "**/*.ts" + ] +} diff --git a/projects/ng-openlayers/tsconfig.lib.prod.json b/projects/ng-openlayers/tsconfig.lib.prod.json new file mode 100644 index 0000000..2a2faa8 --- /dev/null +++ b/projects/ng-openlayers/tsconfig.lib.prod.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false + }, + "angularCompilerOptions": { + "compilationMode": "partial" + } +} diff --git a/projects/ngx-openlayers/tsconfig.spec.json b/projects/ng-openlayers/tsconfig.spec.json similarity index 69% rename from projects/ngx-openlayers/tsconfig.spec.json rename to projects/ng-openlayers/tsconfig.spec.json index 16da33d..75c900a 100644 --- a/projects/ngx-openlayers/tsconfig.spec.json +++ b/projects/ng-openlayers/tsconfig.spec.json @@ -1,7 +1,7 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../out-tsc/spec", + "outDir": "../../dist/out-tsc", "types": [ "jasmine", "node" diff --git a/projects/ng-openlayers/tslint-prettier.json b/projects/ng-openlayers/tslint-prettier.json new file mode 100644 index 0000000..12ebab2 --- /dev/null +++ b/projects/ng-openlayers/tslint-prettier.json @@ -0,0 +1,7 @@ +{ + "extends": [ + "./tslint.json", + "tslint-config-prettier", + "tslint-plugin-prettier" + ] +} diff --git a/projects/ngx-openlayers/ngcc.config.js b/projects/ngx-openlayers/ngcc.config.js deleted file mode 100644 index c26aaf1..0000000 --- a/projects/ngx-openlayers/ngcc.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - ignorableDeepImportMatchers: [/ol\//] -}; diff --git a/projects/ngx-openlayers/package-lock.json b/projects/ngx-openlayers/package-lock.json deleted file mode 100644 index b1a2c95..0000000 --- a/projects/ngx-openlayers/package-lock.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "ngx-openlayers", - "version": "2.0.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "ngx-openlayers", - "version": "2.0.0", - "peerDependencies": { - "@angular/common": "^16.2.12", - "@angular/core": "^16.2.12", - "ol": ">=6.3.1" - } - } - } -} diff --git a/projects/ngx-openlayers/package.json b/projects/ngx-openlayers/package.json deleted file mode 100644 index 47cbaa1..0000000 --- a/projects/ngx-openlayers/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "ngx-openlayers", - "version": "2.0.0", - "publishConfig": { - "registry": "https://repository.akkerweb.nl/repository/npm-hosted/" - }, - "peerDependencies": { - "@angular/common": "^16.2.12", - "@angular/core": "^16.2.12", - "ol": ">=6.3.1" - } -} \ No newline at end of file diff --git a/projects/ngx-openlayers/src/lib/map.component.ts b/projects/ngx-openlayers/src/lib/map.component.ts deleted file mode 100644 index 3979c29..0000000 --- a/projects/ngx-openlayers/src/lib/map.component.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { - AfterViewInit, - Component, - ElementRef, - EventEmitter, - Input, - OnChanges, - OnInit, - Output, - SimpleChanges, -} from '@angular/core'; -import Map from 'ol/Map'; -import MapBrowserEvent from 'ol/MapBrowserEvent'; -import MapEvent from 'ol/MapEvent'; -import ObjectEvent from 'ol/Object'; -import { Control } from 'ol/control'; -import { Interaction } from 'ol/interaction'; -import RenderEvent from 'ol/render/Event'; - -@Component({ - selector: 'aol-map', - template: ` -
- - `, -}) -export class MapComponent implements OnInit, AfterViewInit, OnChanges { - @Input() - width = '100%'; - @Input() - height = '100%'; - @Input() - pixelRatio: number; - @Input() - keyboardEventTarget: Element | string; - @Input() - loadTilesWhileAnimating: boolean; - @Input() - loadTilesWhileInteracting: boolean; - @Input() - logo: string | boolean; - @Input() - renderer: 'canvas' | 'webgl'; - - @Output() - olClick: EventEmitter; - @Output() - dblClick: EventEmitter; - @Output() - moveStart: EventEmitter; - @Output() - moveEnd: EventEmitter; - @Output() - pointerDrag: EventEmitter; - @Output() - pointerMove: EventEmitter; - @Output() - onpostrender: EventEmitter; - @Output() - postRender: EventEmitter; - @Output() - onprerender: EventEmitter; - @Output() - propertyChange: EventEmitter; - @Output() - singleClick: EventEmitter; - - instance: Map; - componentType = 'map'; - // we pass empty arrays to not get default controls/interactions because we have our own directives - controls: Control[] = []; - interactions: Interaction[] = []; - - constructor(private host: ElementRef) { - this.olClick = new EventEmitter(); - this.dblClick = new EventEmitter(); - this.moveStart = new EventEmitter(); - this.moveEnd = new EventEmitter(); - this.pointerDrag = new EventEmitter(); - this.pointerMove = new EventEmitter(); - this.onpostrender = new EventEmitter(); - this.postRender = new EventEmitter(); - this.onprerender = new EventEmitter(); - this.propertyChange = new EventEmitter(); - this.singleClick = new EventEmitter(); - } - - ngOnInit() { - // console.log('creating ol.Map instance with:', this); - this.instance = new Map(this); - this.instance.setTarget(this.host.nativeElement.firstElementChild); - this.instance.on('click', (event: MapBrowserEvent) => this.olClick.emit(event)); - this.instance.on('dblclick', (event: MapBrowserEvent) => this.dblClick.emit(event)); - this.instance.on('movestart', (event: MapEvent) => this.moveStart.emit(event)); - this.instance.on('moveend', (event: MapEvent) => this.moveEnd.emit(event)); - this.instance.on('pointerdrag', (event: MapBrowserEvent) => this.pointerDrag.emit(event)); - this.instance.on('pointermove', (event: MapBrowserEvent) => this.pointerMove.emit(event)); - this.instance.on('postrender', (event: RenderEvent) => this.onpostrender.emit(event)); - this.instance.on('postrender', (event: MapEvent) => this.postRender.emit(event)); - this.instance.on('prerender', (event: RenderEvent) => this.onprerender.emit(event)); - this.instance.on('propertychange', (event: ObjectEvent) => this.propertyChange.emit(event)); - this.instance.on('singleclick', (event: MapBrowserEvent) => this.singleClick.emit(event)); - } - - ngOnChanges(changes: SimpleChanges) { - const properties: { [index: string]: any } = {}; - if (!this.instance) { - return; - } - for (const key in changes) { - if (changes.hasOwnProperty(key)) { - properties[key] = changes[key].currentValue; - } - } - // console.log('changes detected in aol-map, setting new properties: ', properties); - this.instance.setProperties(properties, false); - } - - ngAfterViewInit() { - this.instance.updateSize(); - } -} diff --git a/projects/ngx-openlayers/tsconfig.lib.json b/projects/ngx-openlayers/tsconfig.lib.json deleted file mode 100644 index d8b6e76..0000000 --- a/projects/ngx-openlayers/tsconfig.lib.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "../../out-tsc/lib", - "module": "es2015", - "moduleResolution": "node", - "declaration": true, - "sourceMap": true, - "inlineSources": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "importHelpers": true, - "esModuleInterop": true, - "types": [], - "lib": [ - "dom", - "es2018" - ], - "paths": { - "@angular/*": [ - - "node_modules/@angular/*" - - ] - } - }, - "angularCompilerOptions": { - "skipTemplateCodegen": true, - "strictMetadataEmit": true, - "fullTemplateTypeCheck": true, - "strictInjectionParameters": true, - "enableResourceInlining": true, - "compilationMode": "partial" - }, - "exclude": [ - "src/test.ts", - "**/*.spec.ts" - ] -} diff --git a/projects/ngx-openlayers/tsconfig.lib.prod.json b/projects/ngx-openlayers/tsconfig.lib.prod.json deleted file mode 100644 index d8b6e76..0000000 --- a/projects/ngx-openlayers/tsconfig.lib.prod.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "../../out-tsc/lib", - "module": "es2015", - "moduleResolution": "node", - "declaration": true, - "sourceMap": true, - "inlineSources": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "importHelpers": true, - "esModuleInterop": true, - "types": [], - "lib": [ - "dom", - "es2018" - ], - "paths": { - "@angular/*": [ - - "node_modules/@angular/*" - - ] - } - }, - "angularCompilerOptions": { - "skipTemplateCodegen": true, - "strictMetadataEmit": true, - "fullTemplateTypeCheck": true, - "strictInjectionParameters": true, - "enableResourceInlining": true, - "compilationMode": "partial" - }, - "exclude": [ - "src/test.ts", - "**/*.spec.ts" - ] -} diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000..0562629 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,39 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "skipLibCheck": true, + "baseUrl": ".", + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "downlevelIteration": true, + "experimentalDecorators": true, + "module": "es2020", + "moduleResolution": "node", + "importHelpers": true, + "target": "ES2022", + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "es2018", + "dom" + ], + "paths": { + "ng-openlayers": [ + "libs/ng-openlayers/src/public-api.ts" + ] + }, + "useDefineForClassFields": false, + "rootDir": "." + }, + "angularCompilerOptions": { + "skipLibs": true, + "fullTemplateTypeCheck": true, + "strictInjectionParameters": true + }, + "exclude": [ + "node_modules", + "tmp" + ] +} diff --git a/tsconfig.json b/tsconfig.json index 8439a52..ee40eab 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -32,8 +32,8 @@ "dist/common-map3d/common-map3d", "dist/common-map3d" ], - "ngx-openlayers/*": [ - "dist/ngx-openlayers/*" + "ng-openlayers/*": [ + "dist/ng-openlayers/*" ] }, "useDefineForClassFields": false