From 1f655c8e4161a0d8a8c8292d2e1b2183478ef4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Tue, 4 Jun 2019 11:23:39 -0400 Subject: [PATCH] fix(*): fix import/export and lint --- demo/src/app/app.module.ts | 2 +- .../src/app/common/action/action.component.ts | 11 +- demo/src/app/common/action/action.module.ts | 6 +- demo/src/app/geo/search/search.component.ts | 38 ++++--- demo/src/app/geo/search/search.module.ts | 10 +- package-lock.json | 103 ++++++++++++++++-- .../context-menu.directive.spec.ts | 23 ++-- .../context-menu/context-menu.directive.ts | 81 ++++++++------ packages/common/src/public_api.ts | 2 + .../feature-details.component.ts | 20 +++- .../geo/src/lib/map/shared/map.service.ts | 1 - .../lib/search/shared/sources/coordinates.ts | 19 ++-- packages/geo/src/lib/utils/googleLinks.ts | 5 +- packages/geo/src/lib/utils/index.ts | 1 + packages/geo/src/public_api.ts | 1 + 15 files changed, 225 insertions(+), 98 deletions(-) create mode 100644 packages/geo/src/lib/utils/index.ts diff --git a/demo/src/app/app.module.ts b/demo/src/app/app.module.ts index 4ef9107466..78ab7a00ae 100644 --- a/demo/src/app/app.module.ts +++ b/demo/src/app/app.module.ts @@ -95,7 +95,7 @@ import { AppComponent } from './app.component'; AppContextModule, - AppRoutingModule, + AppRoutingModule ], bootstrap: [AppComponent] }) diff --git a/demo/src/app/common/action/action.component.ts b/demo/src/app/common/action/action.component.ts index bafe348317..e383d6b922 100644 --- a/demo/src/app/common/action/action.component.ts +++ b/demo/src/app/common/action/action.component.ts @@ -1,12 +1,8 @@ -import { - Component, - OnInit, - OnDestroy -} from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; import { Media, MediaOrientation, MediaService } from '@igo2/core'; import { ActionStore, ActionbarMode } from '@igo2/common'; -import {Overlay} from '@angular/cdk/overlay'; +import { Overlay } from '@angular/cdk/overlay'; @Component({ selector: 'app-action', @@ -14,7 +10,6 @@ import {Overlay} from '@angular/cdk/overlay'; styleUrls: ['./action.component.scss'] }) export class AppActionComponent implements OnInit, OnDestroy { - public store = new ActionStore([]); private added = false; @@ -43,7 +38,7 @@ export class AppActionComponent implements OnInit, OnDestroy { alert('Add!'); this.added = true; this.store.updateActionsAvailability(); - }, + } }, { id: 'edit', diff --git a/demo/src/app/common/action/action.module.ts b/demo/src/app/common/action/action.module.ts index 3d233186ce..d9dea28299 100644 --- a/demo/src/app/common/action/action.module.ts +++ b/demo/src/app/common/action/action.module.ts @@ -1,15 +1,13 @@ import { NgModule } from '@angular/core'; import { MatButtonModule, MatCardModule } from '@angular/material'; -import { IgoActionModule } from '@igo2/common'; +import { IgoActionModule, IgoContextMenuModule } from '@igo2/common'; import { AppActionComponent } from './action.component'; import { AppActionRoutingModule } from './action-routing.module'; -import {IgoContextMenuModule} from '../../../../../packages/common/src/lib/context-menu/context-menu.module'; @NgModule({ - declarations: [ - AppActionComponent], + declarations: [AppActionComponent], imports: [ AppActionRoutingModule, MatButtonModule, diff --git a/demo/src/app/geo/search/search.component.ts b/demo/src/app/geo/search/search.component.ts index 6f5e83233f..3d986834ae 100644 --- a/demo/src/app/geo/search/search.component.ts +++ b/demo/src/app/geo/search/search.component.ts @@ -1,4 +1,10 @@ -import { Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'; +import { + Component, + ElementRef, + OnDestroy, + OnInit, + ViewChild +} from '@angular/core'; import * as proj from 'ol/proj'; import { LanguageService } from '@igo2/core'; @@ -7,6 +13,7 @@ import { FEATURE, Feature, FeatureMotion, + GoogleLinks, IgoMap, LayerService, MapService, @@ -19,7 +26,6 @@ import { } from '@igo2/geo'; import { SearchState } from '@igo2/integration'; -import { GoogleLinks} from '../../../../../packages/geo/src/lib/utils/googleLinks'; @Component({ selector: 'app-search', @@ -27,7 +33,6 @@ import { GoogleLinks} from '../../../../../packages/geo/src/lib/utils/googleLink styleUrls: ['./search.component.scss'] }) export class AppSearchComponent implements OnInit, OnDestroy { - public store = new ActionStore([]); public map = new IgoMap({ @@ -46,7 +51,7 @@ export class AppSearchComponent implements OnInit, OnDestroy { public osmLayer: Layer; - @ViewChild('mapBrowser', {read: ElementRef}) mapBrowser: ElementRef; + @ViewChild('mapBrowser', { read: ElementRef }) mapBrowser: ElementRef; public lonlat; public mapProjection: string; @@ -88,7 +93,7 @@ export class AppSearchComponent implements OnInit, OnDestroy { onSearch(event: { research: Research; results: SearchResult[] }) { const results = event.results; - this.searchStore.state.updateAll({focused: false, selected: false}); + this.searchStore.state.updateAll({ focused: false, selected: false }); const newResults = this.searchStore.entities$.value .filter((result: SearchResult) => result.source !== event.research.source) .concat(results); @@ -151,12 +156,11 @@ export class AppSearchComponent implements OnInit, OnDestroy { } ngOnInit() { - this.store.load([ { id: 'coordinates', title: 'coordinates', - handler: this.onSearchCoordinate.bind(this), + handler: this.onSearchCoordinate.bind(this) }, { id: 'googleMaps', @@ -176,17 +180,23 @@ export class AppSearchComponent implements OnInit, OnDestroy { this.store.destroy(); } - onContextMenuOpen(event: { x: number, y: number }) { + onContextMenuOpen(event: { x: number; y: number }) { const position = this.mapPosition(event); const coord = this.mapService.getMap().ol.getCoordinateFromPixel(position); this.mapProjection = this.mapService.getMap().projection; this.lonlat = proj.transform(coord, this.mapProjection, 'EPSG:4326'); } - mapPosition(event: { x: number, y: number }) { + mapPosition(event: { x: number; y: number }) { const contextmenuPoint = event; - contextmenuPoint.y = contextmenuPoint.y - this.mapBrowser.nativeElement.getBoundingClientRect().top + window.scrollY; - contextmenuPoint.x = contextmenuPoint.x - this.mapBrowser.nativeElement.getBoundingClientRect().left + window.scrollX; + contextmenuPoint.y = + contextmenuPoint.y - + this.mapBrowser.nativeElement.getBoundingClientRect().top + + window.scrollY; + contextmenuPoint.x = + contextmenuPoint.x - + this.mapBrowser.nativeElement.getBoundingClientRect().left + + window.scrollX; const position = [contextmenuPoint.x, contextmenuPoint.y]; return position; } @@ -198,7 +208,7 @@ export class AppSearchComponent implements OnInit, OnDestroy { for (const i in results) { if (results.length > 0) { results[i].request.subscribe((_results: SearchResult[]) => { - this.onSearch({research: results[i], results: _results}); + this.onSearch({ research: results[i], results: _results }); /*if (_results[i].source.options.title === 'Coordinates') { this.onResultSelect(_results[0]); }*/ @@ -213,6 +223,8 @@ export class AppSearchComponent implements OnInit, OnDestroy { } onOpenGoogleStreetView() { - window.open(GoogleLinks.getGoogleStreetViewLink(this.lonlat[0], this.lonlat[1])); + window.open( + GoogleLinks.getGoogleStreetViewLink(this.lonlat[0], this.lonlat[1]) + ); } } diff --git a/demo/src/app/geo/search/search.module.ts b/demo/src/app/geo/search/search.module.ts index 755c44315a..9db87568ee 100644 --- a/demo/src/app/geo/search/search.module.ts +++ b/demo/src/app/geo/search/search.module.ts @@ -8,8 +8,13 @@ import { MatTooltipModule } from '@angular/material'; -import { IgoPanelModule } from '@igo2/common'; import { + IgoPanelModule, + IgoActionbarModule, + IgoContextMenuModule +} from '@igo2/common'; +import { + IgoFeatureModule, IgoMapModule, IgoSearchModule, provideIChercheSearchSource, @@ -23,9 +28,6 @@ import { IgoAppSearchModule } from '@igo2/integration'; import { AppSearchComponent } from './search.component'; import { AppSearchRoutingModule } from './search-routing.module'; -import { IgoActionbarModule } from '../../../../../packages/common/src/lib/action/actionbar/actionbar.module'; -import { IgoContextMenuModule } from '../../../../../packages/common/src/lib/context-menu/context-menu.module'; -import { IgoFeatureModule } from '../../../../../packages/geo/src/lib/feature/feature.module'; @NgModule({ declarations: [AppSearchComponent], diff --git a/package-lock.json b/package-lock.json index 8f423d8161..0c00fa340c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2204,8 +2204,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -8274,7 +8273,6 @@ "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -8443,7 +8441,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -8809,6 +8806,7 @@ "dev": true }, "geojson-rbush": { +<<<<<<< HEAD <<<<<<< HEAD "version": "3.1.2", "resolved": "https://registry.npmjs.org/geojson-rbush/-/geojson-rbush-3.1.2.tgz", @@ -8818,15 +8816,24 @@ "resolved": "https://registry.npmjs.org/geojson-rbush/-/geojson-rbush-3.1.1.tgz", "integrity": "sha512-Bl6U75yDCsERl2P6PiBkvxIoXsSv5SEEiDJy+a7JarcEe17jEm8zamAmi82KLRcIlcuRZxgeVCl1xw5UkxOREw==", >>>>>>> get mapbrowser coordinate +======= + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/geojson-rbush/-/geojson-rbush-3.1.2.tgz", + "integrity": "sha512-grkfdg3HIeTjwTfiJe5FT8+fGU3fABCc+vRJDBwdQz9kkLF0Sbif2gs2JUzjewwgmnvLGy9fInySDeADoNuk7w==", +>>>>>>> fix(*): fix import/export and lint "requires": { "@turf/bbox": "*", "@turf/helpers": "6.x", "@turf/meta": "6.x", +<<<<<<< HEAD <<<<<<< HEAD "rbush": "^2.0.0" ======= "rbush": "*" >>>>>>> get mapbrowser coordinate +======= + "rbush": "^2.0.0" +>>>>>>> fix(*): fix import/export and lint } }, "get-caller-file": { @@ -11798,8 +11805,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -12260,7 +12266,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -13732,6 +13737,88 @@ } } }, + "npm-run-all": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.1.5.tgz", + "integrity": "sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "chalk": "^2.4.1", + "cross-spawn": "^6.0.5", + "memorystream": "^0.3.1", + "minimatch": "^3.0.4", + "pidtree": "^0.3.0", + "read-pkg": "^3.0.0", + "shell-quote": "^1.6.1", + "string.prototype.padend": "^3.0.0" + }, + "dependencies": { + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "load-json-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0", + "strip-bom": "^3.0.0" + } + }, + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, + "requires": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + } + }, + "read-pkg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "dev": true, + "requires": { + "load-json-file": "^4.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^3.0.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + } + } + }, "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -16632,7 +16719,6 @@ "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -16801,7 +16887,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } diff --git a/packages/common/src/lib/context-menu/context-menu.directive.spec.ts b/packages/common/src/lib/context-menu/context-menu.directive.spec.ts index 0f01b3b4a6..316097b561 100644 --- a/packages/common/src/lib/context-menu/context-menu.directive.spec.ts +++ b/packages/common/src/lib/context-menu/context-menu.directive.spec.ts @@ -1,14 +1,21 @@ import { ContextMenuDirective } from './context-menu.directive'; -import {Overlay} from '@angular/cdk/overlay'; -import {ViewContainerRef} from '@angular/core'; -import {inject} from '@angular/core/testing'; -import {MockElementRef} from '../clickout/clickout.directive.spec'; +import { Overlay } from '@angular/cdk/overlay'; +import { ViewContainerRef } from '@angular/core'; +import { inject } from '@angular/core/testing'; +import { MockElementRef } from '../clickout/clickout.directive.spec'; describe('ContextMenuDirective', () => { it('should create an instance', () => { - inject ([Overlay, ViewContainerRef], (overlay: Overlay, viewContainerRef: ViewContainerRef) => { - const directive = new ContextMenuDirective(overlay, viewContainerRef, new MockElementRef({})); - expect(directive).toBeTruthy(); - }); + inject( + [Overlay, ViewContainerRef], + (overlay: Overlay, viewContainerRef: ViewContainerRef) => { + const directive = new ContextMenuDirective( + overlay, + viewContainerRef, + new MockElementRef({}) + ); + expect(directive).toBeTruthy(); + } + ); }); }); diff --git a/packages/common/src/lib/context-menu/context-menu.directive.ts b/packages/common/src/lib/context-menu/context-menu.directive.ts index 121f22235c..9a42bce050 100644 --- a/packages/common/src/lib/context-menu/context-menu.directive.ts +++ b/packages/common/src/lib/context-menu/context-menu.directive.ts @@ -1,14 +1,18 @@ import { - Directive, ElementRef, EventEmitter, + Directive, + ElementRef, + EventEmitter, HostListener, - Input, Output, TemplateRef, + Input, + Output, + TemplateRef, ViewContainerRef } from '@angular/core'; -import {TemplatePortal} from '@angular/cdk/portal'; -import {fromEvent, Subscription} from 'rxjs'; -import {filter, take} from 'rxjs/operators'; -import {Overlay, OverlayRef} from '@angular/cdk/overlay'; +import { TemplatePortal } from '@angular/cdk/portal'; +import { fromEvent, Subscription } from 'rxjs'; +import { filter, take } from 'rxjs/operators'; +import { Overlay, OverlayRef } from '@angular/cdk/overlay'; @Directive({ selector: '[igoContextMenu]' @@ -18,59 +22,72 @@ export class ContextMenuDirective { sub: Subscription; @Input('igoContextMenu') menuContext: TemplateRef; - @Output() menuPosition = new EventEmitter<{x: number, y: number}>(); + @Output() menuPosition = new EventEmitter<{ x: number; y: number }>(); - constructor(public overlay: Overlay, - public viewContainerRef: ViewContainerRef, - private elementRef: ElementRef) {} + constructor( + public overlay: Overlay, + public viewContainerRef: ViewContainerRef, + private elementRef: ElementRef + ) {} @HostListener('contextmenu', ['$event']) - public onContextMenu({x, y}: MouseEvent): void { + public onContextMenu({ x, y }: MouseEvent): void { this.close(); event.preventDefault(); - this.menuPosition.emit({x, y}); + this.menuPosition.emit({ x, y }); this.overlayRef = null; - const positionStrategy = this.overlay.position() - .flexibleConnectedTo({x, y}) + const positionStrategy = this.overlay + .position() + .flexibleConnectedTo({ x, y }) .withPositions([ { originX: 'end', originY: 'bottom', overlayX: 'start', - overlayY: 'top', + overlayY: 'top' } ]); this.overlayRef = this.overlay.create({ positionStrategy, scrollStrategy: this.overlay.scrollStrategies.close() }); - this.overlayRef.attach(new TemplatePortal(this.menuContext, this.viewContainerRef, { - $implicit: undefined - })); + this.overlayRef.attach( + new TemplatePortal(this.menuContext, this.viewContainerRef, { + $implicit: undefined + }) + ); this.sub = fromEvent(document, 'click') .pipe( filter(event => { const clickTarget = event.target as HTMLElement; this.close(); - return !!this.overlayRef && !this.overlayRef.overlayElement.contains(clickTarget); + return ( + !!this.overlayRef && + !this.overlayRef.overlayElement.contains(clickTarget) + ); }), take(1) - ).subscribe(() => this.close()); + ) + .subscribe(() => this.close()); this.sub = fromEvent(document, 'contextmenu') - .pipe( - filter(event => { - const clickTarget = event.target as HTMLElement; - if (clickTarget && !this.elementRef.nativeElement.contains(clickTarget) && - !this.overlayRef.overlayElement.contains(clickTarget)) { - return true; - } else { - event.preventDefault(); - } - }), - take(1) - ).subscribe(() => this.close()); + .pipe( + filter(event => { + const clickTarget = event.target as HTMLElement; + if ( + clickTarget && + !this.elementRef.nativeElement.contains(clickTarget) && + !this.overlayRef.overlayElement.contains(clickTarget) + ) { + return true; + } else { + event.preventDefault(); + } + }), + take(1) + ) + .subscribe(() => this.close()); } close() { if (this.overlayRef) { diff --git a/packages/common/src/public_api.ts b/packages/common/src/public_api.ts index 5680f43747..280f118562 100644 --- a/packages/common/src/public_api.ts +++ b/packages/common/src/public_api.ts @@ -9,6 +9,7 @@ export * from './lib/clickout/clickout.module'; export * from './lib/clone/clone.module'; export * from './lib/collapsible/collapsible.module'; export * from './lib/confirm-dialog/confirm-dialog.module'; +export * from './lib/context-menu/context-menu.module'; export * from './lib/custom-html/custom-html.module'; export * from './lib/drag-drop/drag-drop.module'; export * from './lib/dynamic-component/dynamic-component.module'; @@ -44,6 +45,7 @@ export * from './lib/clickout'; export * from './lib/clone'; export * from './lib/collapsible'; export * from './lib/confirm-dialog'; +export * from './lib/context-menu'; export * from './lib/custom-html'; export * from './lib/drag-drop'; export * from './lib/dynamic-component'; diff --git a/packages/geo/src/lib/feature/feature-details/feature-details.component.ts b/packages/geo/src/lib/feature/feature-details/feature-details.component.ts index 14c13c7c12..e5f70d4cee 100644 --- a/packages/geo/src/lib/feature/feature-details/feature-details.component.ts +++ b/packages/geo/src/lib/feature/feature-details/feature-details.component.ts @@ -30,17 +30,21 @@ export class FeatureDetailsComponent { /** * @internal */ - get title(): string { return getEntityTitle(this.feature); } + get title(): string { + return getEntityTitle(this.feature); + } /** * @internal */ - get icon(): string { return getEntityIcon(this.feature) || 'link'; } + get icon(): string { + return getEntityIcon(this.feature) || 'link'; + } constructor( private cdRef: ChangeDetectorRef, private sanitizer: DomSanitizer - ) { } + ) {} htmlSanitizer(value): SafeResourceUrl { return this.sanitizer.bypassSecurityTrustResourceUrl(value); @@ -51,9 +55,13 @@ export class FeatureDetailsComponent { } isUrl(value) { - if (typeof (value) === 'string') { - return ((value.slice(0, 8) === 'https://') || (value.slice(0, 7) === 'http://')) ; - } else {return false; } + if (typeof value === 'string') { + return ( + value.slice(0, 8) === 'https://' || value.slice(0, 7) === 'http://' + ); + } else { + return false; + } } filterFeatureProperties(feature) { diff --git a/packages/geo/src/lib/map/shared/map.service.ts b/packages/geo/src/lib/map/shared/map.service.ts index 165636471e..3185d65253 100644 --- a/packages/geo/src/lib/map/shared/map.service.ts +++ b/packages/geo/src/lib/map/shared/map.service.ts @@ -26,5 +26,4 @@ export class MapService { setMap(map: IgoMap) { this.map = map; } - } diff --git a/packages/geo/src/lib/search/shared/sources/coordinates.ts b/packages/geo/src/lib/search/shared/sources/coordinates.ts index 656edb9161..cd60bdda91 100644 --- a/packages/geo/src/lib/search/shared/sources/coordinates.ts +++ b/packages/geo/src/lib/search/shared/sources/coordinates.ts @@ -7,13 +7,10 @@ import { FEATURE, Feature } from '../../../feature'; import { SearchResult } from '../search.interfaces'; import { SearchSource, ReverseSearch } from './source'; -import { - SearchSourceOptions, - TextSearchOptions -} from './source.interfaces'; +import { SearchSourceOptions, TextSearchOptions } from './source.interfaces'; -import {LanguageService} from '@igo2/core'; -import {GoogleLinks} from '../../../utils/googleLinks'; +import { LanguageService } from '@igo2/core'; +import { GoogleLinks } from '../../../utils/googleLinks'; @Injectable() export class CoordinatesSearchResultFormatter { @@ -27,7 +24,8 @@ export class CoordinatesSearchResultFormatter { * CoordinatesReverse search source */ @Injectable() -export class CoordinatesReverseSearchSource extends SearchSource implements ReverseSearch { +export class CoordinatesReverseSearchSource extends SearchSource + implements ReverseSearch { static id = 'coordinatesreverse'; static type = FEATURE; @@ -58,7 +56,7 @@ export class CoordinatesReverseSearchSource extends SearchSource implements Reve lonLat: [number, number], options?: TextSearchOptions ): Observable[]> { - return of( [this.dataToResult(lonLat)]); + return of([this.dataToResult(lonLat)]); } private dataToResult(data: [number, number]): SearchResult { @@ -78,7 +76,10 @@ export class CoordinatesReverseSearchSource extends SearchSource implements Reve format: 'degrés decimaux', systemeCoordonnees: 'WGS84', GoogleMaps: GoogleLinks.getGoogleMapsLink(data[0], data[1]), - GoogleStreetView: GoogleLinks.getGoogleStreetViewLink(data[0], data[1]) + GoogleStreetView: GoogleLinks.getGoogleStreetViewLink( + data[0], + data[1] + ) } }, meta: { diff --git a/packages/geo/src/lib/utils/googleLinks.ts b/packages/geo/src/lib/utils/googleLinks.ts index 74343d25a1..582093f270 100644 --- a/packages/geo/src/lib/utils/googleLinks.ts +++ b/packages/geo/src/lib/utils/googleLinks.ts @@ -1,10 +1,9 @@ export class GoogleLinks { - static getGoogleMapsLink(lon, lat) { + static getGoogleMapsLink(lon, lat) { return 'https://www.google.com/maps?q=' + lat + ',' + lon; -} + } static getGoogleStreetViewLink(lon, lat) { return 'https://www.google.com/maps?q=&layer=c&cbll=' + lat + ',' + lon; } - } diff --git a/packages/geo/src/lib/utils/index.ts b/packages/geo/src/lib/utils/index.ts new file mode 100644 index 0000000000..92ff78d9d6 --- /dev/null +++ b/packages/geo/src/lib/utils/index.ts @@ -0,0 +1 @@ +export * from './googleLinks'; diff --git a/packages/geo/src/public_api.ts b/packages/geo/src/public_api.ts index 8bc5735608..f0a73f4b90 100644 --- a/packages/geo/src/public_api.ts +++ b/packages/geo/src/public_api.ts @@ -59,4 +59,5 @@ export * from './lib/query'; export * from './lib/routing'; export * from './lib/search'; export * from './lib/toast'; +export * from './lib/utils'; export * from './lib/wkt';