From 76a82d2d4d46337f83dacc53ce7a98967dc02687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 2 Oct 2018 15:54:43 -0400 Subject: [PATCH 01/10] feat(*) Prevent zooming on result if already contained im map extent --- demo/src/app/geo/feature/feature.component.ts | 2 +- demo/src/app/geo/search/search.component.ts | 2 +- projects/geo/src/lib/overlay/shared/overlay.directive.ts | 4 ++++ projects/geo/src/lib/overlay/shared/overlay.interface.ts | 2 +- .../lib/search-results-tool/search-results-tool.component.ts | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/demo/src/app/geo/feature/feature.component.ts b/demo/src/app/geo/feature/feature.component.ts index 45910b10e9..41e0e18c18 100644 --- a/demo/src/app/geo/feature/feature.component.ts +++ b/demo/src/app/geo/feature/feature.component.ts @@ -105,6 +105,6 @@ export class AppFeatureComponent { } handleFeatureSelect(feature: Feature) { - this.overlayService.setFeatures([feature], 'zoom'); + this.overlayService.setFeatures([feature], 'zoomif'); } } diff --git a/demo/src/app/geo/search/search.component.ts b/demo/src/app/geo/search/search.component.ts index 58f609aa2d..2ae0fdc752 100644 --- a/demo/src/app/geo/search/search.component.ts +++ b/demo/src/app/geo/search/search.component.ts @@ -70,7 +70,7 @@ export class AppSearchComponent { handleFeatureSelect(feature: Feature) { if (feature.type === FeatureType.Feature) { - this.overlayService.setFeatures([feature], 'zoom'); + this.overlayService.setFeatures([feature], 'zoomif'); } else if (feature.type === FeatureType.DataSource) { this.layerService.createAsyncLayer(feature.layer).subscribe(layer => { this.map.addLayer(layer); diff --git a/projects/geo/src/lib/overlay/shared/overlay.directive.ts b/projects/geo/src/lib/overlay/shared/overlay.directive.ts index 9bf2213ddc..9ebd7ae4ad 100644 --- a/projects/geo/src/lib/overlay/shared/overlay.directive.ts +++ b/projects/geo/src/lib/overlay/shared/overlay.directive.ts @@ -78,6 +78,10 @@ export class OverlayDirective implements OnInit, OnDestroy { this.map.zoomToExtent(extent); } else if (action === 'move') { this.map.moveToExtent(extent); + } else if (action === 'zoomif') { + if (!extent.intersects(featureExtent, this.map.getExtent())) { + this.map.zoomToExtent(extent); + } } } } diff --git a/projects/geo/src/lib/overlay/shared/overlay.interface.ts b/projects/geo/src/lib/overlay/shared/overlay.interface.ts index ef74062675..4e11183412 100644 --- a/projects/geo/src/lib/overlay/shared/overlay.interface.ts +++ b/projects/geo/src/lib/overlay/shared/overlay.interface.ts @@ -1 +1 @@ -export type OverlayAction = 'none' | 'move' | 'zoom'; +export type OverlayAction = 'none' | 'move' | 'zoom' | 'zoomif' ; diff --git a/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts b/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts index 114d703be3..4abecfc522 100644 --- a/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts +++ b/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts @@ -37,7 +37,7 @@ export class SearchResultsToolComponent { handleFeatureSelect(feature: Feature) { if (feature.type === FeatureType.Feature) { - this.overlayService.setFeatures([feature], 'zoom'); + this.overlayService.setFeatures([feature], 'zoomif'); } else if (feature.type === FeatureType.DataSource) { const map = this.mapService.getMap(); From d19f91cfc5fd92edde90d31c79ad74f25b3b97b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 2 Oct 2018 16:39:45 -0400 Subject: [PATCH 02/10] refactor(*) refactor zoomif to zoomIfOutMapExtent & interface to enum --- demo/src/app/geo/feature/feature.component.ts | 3 ++- demo/src/app/geo/search/search.component.ts | 3 ++- projects/geo/src/lib/overlay/shared/index.ts | 2 +- .../geo/src/lib/overlay/shared/overlay.directive.ts | 12 ++++++------ projects/geo/src/lib/overlay/shared/overlay.enum.ts | 6 ++++++ .../geo/src/lib/overlay/shared/overlay.interface.ts | 1 - .../geo/src/lib/overlay/shared/overlay.service.ts | 6 +++--- .../search-results-tool.component.ts | 5 +++-- 8 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 projects/geo/src/lib/overlay/shared/overlay.enum.ts delete mode 100644 projects/geo/src/lib/overlay/shared/overlay.interface.ts diff --git a/demo/src/app/geo/feature/feature.component.ts b/demo/src/app/geo/feature/feature.component.ts index 41e0e18c18..22edc09c89 100644 --- a/demo/src/app/geo/feature/feature.component.ts +++ b/demo/src/app/geo/feature/feature.component.ts @@ -5,6 +5,7 @@ import { IgoMap, DataSourceService, LayerService, + OverlayAction, OverlayService, Feature, FeatureType, @@ -105,6 +106,6 @@ export class AppFeatureComponent { } handleFeatureSelect(feature: Feature) { - this.overlayService.setFeatures([feature], 'zoomif'); + this.overlayService.setFeatures([feature], OverlayAction.zoomIfOutMapExtent); } } diff --git a/demo/src/app/geo/search/search.component.ts b/demo/src/app/geo/search/search.component.ts index 2ae0fdc752..533ac6a223 100644 --- a/demo/src/app/geo/search/search.component.ts +++ b/demo/src/app/geo/search/search.component.ts @@ -9,6 +9,7 @@ import { SearchService, Feature, FeatureType, + OverlayAction, OverlayService } from '@igo2/geo'; @@ -70,7 +71,7 @@ export class AppSearchComponent { handleFeatureSelect(feature: Feature) { if (feature.type === FeatureType.Feature) { - this.overlayService.setFeatures([feature], 'zoomif'); + this.overlayService.setFeatures([feature], OverlayAction.zoomIfOutMapExtent); } else if (feature.type === FeatureType.DataSource) { this.layerService.createAsyncLayer(feature.layer).subscribe(layer => { this.map.addLayer(layer); diff --git a/projects/geo/src/lib/overlay/shared/index.ts b/projects/geo/src/lib/overlay/shared/index.ts index a518239180..1c388bc43e 100644 --- a/projects/geo/src/lib/overlay/shared/index.ts +++ b/projects/geo/src/lib/overlay/shared/index.ts @@ -1,3 +1,3 @@ export * from './overlay.directive'; export * from './overlay.service'; -export * from './overlay.interface'; +export * from './overlay.enum'; diff --git a/projects/geo/src/lib/overlay/shared/overlay.directive.ts b/projects/geo/src/lib/overlay/shared/overlay.directive.ts index 9ebd7ae4ad..43f9f0a42e 100644 --- a/projects/geo/src/lib/overlay/shared/overlay.directive.ts +++ b/projects/geo/src/lib/overlay/shared/overlay.directive.ts @@ -11,7 +11,7 @@ import { SourceFeatureType } from '../../feature/shared/feature.enum'; import { Feature } from '../../feature/shared/feature.interface'; import { OverlayService } from '../shared/overlay.service'; -import { OverlayAction } from '../shared/overlay.interface'; +import { OverlayAction } from '../shared/overlay.enum'; @Directive({ selector: '[igoOverlay]' @@ -68,17 +68,17 @@ export class OverlayDirective implements OnInit, OnDestroy { }, this); if (features[0].sourceType === SourceFeatureType.Click) { if (olextent.intersects(featureExtent, this.map.getExtent())) { - action = 'none'; + action = OverlayAction.none; } else { - action = 'move'; + action = OverlayAction.move; } } if (!olextent.isEmpty(featureExtent)) { - if (action === 'zoom') { + if (action === OverlayAction.zoom) { this.map.zoomToExtent(extent); - } else if (action === 'move') { + } else if (action === OverlayAction.move) { this.map.moveToExtent(extent); - } else if (action === 'zoomif') { + } else if (action === OverlayAction.zoomIfOutMapExtent) { if (!extent.intersects(featureExtent, this.map.getExtent())) { this.map.zoomToExtent(extent); } diff --git a/projects/geo/src/lib/overlay/shared/overlay.enum.ts b/projects/geo/src/lib/overlay/shared/overlay.enum.ts new file mode 100644 index 0000000000..d09dd13698 --- /dev/null +++ b/projects/geo/src/lib/overlay/shared/overlay.enum.ts @@ -0,0 +1,6 @@ +export enum OverlayAction { + none, + move, + zoom, + zoomIfOutMapExtent + } diff --git a/projects/geo/src/lib/overlay/shared/overlay.interface.ts b/projects/geo/src/lib/overlay/shared/overlay.interface.ts deleted file mode 100644 index 4e11183412..0000000000 --- a/projects/geo/src/lib/overlay/shared/overlay.interface.ts +++ /dev/null @@ -1 +0,0 @@ -export type OverlayAction = 'none' | 'move' | 'zoom' | 'zoomif' ; diff --git a/projects/geo/src/lib/overlay/shared/overlay.service.ts b/projects/geo/src/lib/overlay/shared/overlay.service.ts index 4f95c15e89..96de86eb10 100644 --- a/projects/geo/src/lib/overlay/shared/overlay.service.ts +++ b/projects/geo/src/lib/overlay/shared/overlay.service.ts @@ -3,7 +3,7 @@ import { BehaviorSubject } from 'rxjs'; import { Feature } from '../../feature/shared/feature.interface'; -import { OverlayAction } from './overlay.interface'; +import { OverlayAction } from './overlay.enum'; @Injectable({ providedIn: 'root' @@ -16,11 +16,11 @@ export class OverlayService { constructor() {} - setFeatures(features: Feature[], action: OverlayAction = 'none') { + setFeatures(features: Feature[], action: OverlayAction = OverlayAction.none) { this.features$.next([features, action]); } clear() { - this.features$.next([[], 'none']); + this.features$.next([[], OverlayAction.none]); } } diff --git a/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts b/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts index 4abecfc522..520a9d3b73 100644 --- a/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts +++ b/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts @@ -6,6 +6,7 @@ import { MapService, LayerService, OverlayService, + OverlayAction, Feature, FeatureType, AnyDataSourceOptions, @@ -31,13 +32,13 @@ export class SearchResultsToolComponent { handleFeatureFocus(feature: Feature) { if (feature.type === FeatureType.Feature) { - this.overlayService.setFeatures([feature], 'move'); + this.overlayService.setFeatures([feature], OverlayAction.move); } } handleFeatureSelect(feature: Feature) { if (feature.type === FeatureType.Feature) { - this.overlayService.setFeatures([feature], 'zoomif'); + this.overlayService.setFeatures([feature], OverlayAction.zoomIfOutMapExtent); } else if (feature.type === FeatureType.DataSource) { const map = this.mapService.getMap(); From 764b744c9f743de27ea15674a935b8b5c91ecbed Mon Sep 17 00:00:00 2001 From: PE Lord Date: Tue, 2 Oct 2018 20:02:50 -0400 Subject: [PATCH 03/10] fix(overlay) zoom if outside map extent --- projects/geo/src/lib/overlay/shared/overlay.directive.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/geo/src/lib/overlay/shared/overlay.directive.ts b/projects/geo/src/lib/overlay/shared/overlay.directive.ts index 43f9f0a42e..2edb10d456 100644 --- a/projects/geo/src/lib/overlay/shared/overlay.directive.ts +++ b/projects/geo/src/lib/overlay/shared/overlay.directive.ts @@ -79,7 +79,7 @@ export class OverlayDirective implements OnInit, OnDestroy { } else if (action === OverlayAction.move) { this.map.moveToExtent(extent); } else if (action === OverlayAction.zoomIfOutMapExtent) { - if (!extent.intersects(featureExtent, this.map.getExtent())) { + if (!olextent.intersects(featureExtent, this.map.getExtent())) { this.map.zoomToExtent(extent); } } From 422415fc1d7273e3c4719260b9ff2b8097554df8 Mon Sep 17 00:00:00 2001 From: PE Lord Date: Tue, 2 Oct 2018 20:04:23 -0400 Subject: [PATCH 04/10] refactor(demo) set to false because it is not provided in search module. --- demo/src/environments/environment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/src/environments/environment.ts b/demo/src/environments/environment.ts index c0a95815da..816b9b2561 100644 --- a/demo/src/environments/environment.ts +++ b/demo/src/environments/environment.ts @@ -37,7 +37,7 @@ export const environment: Environment = { locateUrl: 'https://ws.mapserver.transports.gouv.qc.ca/swtq', limit: 5, locateLimit: 15, - enabled: true + enabled: false }, icherche: { searchUrl: 'https://geoegl.msp.gouv.qc.ca/icherche/geocode', From cc92670a76098bb6e160e75ee9422d2f32796d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Wed, 3 Oct 2018 09:18:56 -0400 Subject: [PATCH 05/10] Update feature.component.ts --- demo/src/app/geo/feature/feature.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/src/app/geo/feature/feature.component.ts b/demo/src/app/geo/feature/feature.component.ts index 22edc09c89..374e7f3a5d 100644 --- a/demo/src/app/geo/feature/feature.component.ts +++ b/demo/src/app/geo/feature/feature.component.ts @@ -106,6 +106,6 @@ export class AppFeatureComponent { } handleFeatureSelect(feature: Feature) { - this.overlayService.setFeatures([feature], OverlayAction.zoomIfOutMapExtent); + this.overlayService.setFeatures([feature], OverlayAction.ZoomIfOutMapExtent); } } From e95206eaa6a874f72d22376c5e569592fa030917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Wed, 3 Oct 2018 09:19:10 -0400 Subject: [PATCH 06/10] Update search.component.ts --- demo/src/app/geo/search/search.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/src/app/geo/search/search.component.ts b/demo/src/app/geo/search/search.component.ts index 533ac6a223..6568cbb6f4 100644 --- a/demo/src/app/geo/search/search.component.ts +++ b/demo/src/app/geo/search/search.component.ts @@ -71,7 +71,7 @@ export class AppSearchComponent { handleFeatureSelect(feature: Feature) { if (feature.type === FeatureType.Feature) { - this.overlayService.setFeatures([feature], OverlayAction.zoomIfOutMapExtent); + this.overlayService.setFeatures([feature], OverlayAction.ZoomIfOutMapExtent); } else if (feature.type === FeatureType.DataSource) { this.layerService.createAsyncLayer(feature.layer).subscribe(layer => { this.map.addLayer(layer); From dabf07606f5dde36f7d000e873bde9aad92ccf95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Wed, 3 Oct 2018 09:19:55 -0400 Subject: [PATCH 07/10] Update overlay.directive.ts --- .../geo/src/lib/overlay/shared/overlay.directive.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/projects/geo/src/lib/overlay/shared/overlay.directive.ts b/projects/geo/src/lib/overlay/shared/overlay.directive.ts index 2edb10d456..93700900d1 100644 --- a/projects/geo/src/lib/overlay/shared/overlay.directive.ts +++ b/projects/geo/src/lib/overlay/shared/overlay.directive.ts @@ -68,17 +68,17 @@ export class OverlayDirective implements OnInit, OnDestroy { }, this); if (features[0].sourceType === SourceFeatureType.Click) { if (olextent.intersects(featureExtent, this.map.getExtent())) { - action = OverlayAction.none; + action = OverlayAction.None; } else { - action = OverlayAction.move; + action = OverlayAction.Move; } } if (!olextent.isEmpty(featureExtent)) { - if (action === OverlayAction.zoom) { + if (action === OverlayAction.Zoom) { this.map.zoomToExtent(extent); - } else if (action === OverlayAction.move) { + } else if (action === OverlayAction.Move) { this.map.moveToExtent(extent); - } else if (action === OverlayAction.zoomIfOutMapExtent) { + } else if (action === OverlayAction.ZoomIfOutMapExtent) { if (!olextent.intersects(featureExtent, this.map.getExtent())) { this.map.zoomToExtent(extent); } From 120219506ca30183d015c372efd8ed745c2df999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Wed, 3 Oct 2018 09:20:13 -0400 Subject: [PATCH 08/10] Update overlay.service.ts --- projects/geo/src/lib/overlay/shared/overlay.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/geo/src/lib/overlay/shared/overlay.service.ts b/projects/geo/src/lib/overlay/shared/overlay.service.ts index 96de86eb10..2ce10a7ab4 100644 --- a/projects/geo/src/lib/overlay/shared/overlay.service.ts +++ b/projects/geo/src/lib/overlay/shared/overlay.service.ts @@ -16,11 +16,11 @@ export class OverlayService { constructor() {} - setFeatures(features: Feature[], action: OverlayAction = OverlayAction.none) { + setFeatures(features: Feature[], action: OverlayAction = OverlayAction.None) { this.features$.next([features, action]); } clear() { - this.features$.next([[], OverlayAction.none]); + this.features$.next([[], OverlayAction.None]); } } From 5c99be6f1458105bba9ce5416e6eca4d83802a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Wed, 3 Oct 2018 09:20:24 -0400 Subject: [PATCH 09/10] Update search-results-tool.component.ts --- .../lib/search-results-tool/search-results-tool.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts b/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts index 520a9d3b73..e31aa6bfa3 100644 --- a/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts +++ b/projects/tools/src/lib/search-results-tool/search-results-tool.component.ts @@ -32,13 +32,13 @@ export class SearchResultsToolComponent { handleFeatureFocus(feature: Feature) { if (feature.type === FeatureType.Feature) { - this.overlayService.setFeatures([feature], OverlayAction.move); + this.overlayService.setFeatures([feature], OverlayAction.Move); } } handleFeatureSelect(feature: Feature) { if (feature.type === FeatureType.Feature) { - this.overlayService.setFeatures([feature], OverlayAction.zoomIfOutMapExtent); + this.overlayService.setFeatures([feature], OverlayAction.ZoomIfOutMapExtent); } else if (feature.type === FeatureType.DataSource) { const map = this.mapService.getMap(); From 936f063d2258fa8e3df95836260c0de7422f86e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Wed, 3 Oct 2018 09:20:39 -0400 Subject: [PATCH 10/10] Update overlay.enum.ts --- projects/geo/src/lib/overlay/shared/overlay.enum.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/geo/src/lib/overlay/shared/overlay.enum.ts b/projects/geo/src/lib/overlay/shared/overlay.enum.ts index d09dd13698..893c5e1e1a 100644 --- a/projects/geo/src/lib/overlay/shared/overlay.enum.ts +++ b/projects/geo/src/lib/overlay/shared/overlay.enum.ts @@ -1,6 +1,6 @@ export enum OverlayAction { - none, - move, - zoom, - zoomIfOutMapExtent + None, + Move, + Zoom, + ZoomIfOutMapExtent }