(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());
+ }
+ close() {
+ if (this.overlayRef) {
+ this.overlayRef.dispose();
+ this.overlayRef = null;
+ }
+ }
+}
diff --git a/packages/common/src/lib/context-menu/context-menu.module.ts b/packages/common/src/lib/context-menu/context-menu.module.ts
new file mode 100644
index 0000000000..a762987a8e
--- /dev/null
+++ b/packages/common/src/lib/context-menu/context-menu.module.ts
@@ -0,0 +1,16 @@
+import { NgModule, ModuleWithProviders } from '@angular/core';
+import { ContextMenuDirective } from './context-menu.directive';
+
+@NgModule({
+ imports: [],
+ declarations: [ContextMenuDirective],
+ exports: [ContextMenuDirective]
+})
+export class IgoContextMenuModule {
+ static forRoot(): ModuleWithProviders {
+ return {
+ ngModule: IgoContextMenuModule,
+ providers: []
+ };
+ }
+}
diff --git a/packages/common/src/lib/context-menu/index.ts b/packages/common/src/lib/context-menu/index.ts
new file mode 100644
index 0000000000..98e532cbb4
--- /dev/null
+++ b/packages/common/src/lib/context-menu/index.ts
@@ -0,0 +1 @@
+export * from './context-menu.directive';
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.html b/packages/geo/src/lib/feature/feature-details/feature-details.component.html
index 569916435f..fdd1350f8d 100644
--- a/packages/geo/src/lib/feature/feature-details/feature-details.component.html
+++ b/packages/geo/src/lib/feature/feature-details/feature-details.component.html
@@ -14,7 +14,11 @@
{{property.key }}
-
+ |
+ |
+
+
+ {{ 'igo.geo.targetHtmlUrl' | translate }}
|
@@ -23,4 +27,4 @@
-
+
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 416a5f7f70..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,19 +30,23 @@ 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
- ) { }
+ ) {}
- isUrl(value): SafeResourceUrl {
+ htmlSanitizer(value): SafeResourceUrl {
return this.sanitizer.bypassSecurityTrustResourceUrl(value);
}
@@ -50,6 +54,16 @@ export class FeatureDetailsComponent {
return typeof value === 'object';
}
+ isUrl(value) {
+ if (typeof value === 'string') {
+ return (
+ value.slice(0, 8) === 'https://' || value.slice(0, 7) === 'http://'
+ );
+ } else {
+ return false;
+ }
+ }
+
filterFeatureProperties(feature) {
const allowedFieldsAndAlias = feature.meta.alias;
const properties = Object.assign({}, feature.properties);
diff --git a/packages/geo/src/lib/map/shared/map.ts b/packages/geo/src/lib/map/shared/map.ts
index e74f0fa60a..40e7621145 100644
--- a/packages/geo/src/lib/map/shared/map.ts
+++ b/packages/geo/src/lib/map/shared/map.ts
@@ -413,5 +413,4 @@ export class IgoMap {
this.geolocation.setTracking(false);
}
}
-
}
diff --git a/packages/geo/src/lib/search/search.module.ts b/packages/geo/src/lib/search/search.module.ts
index 5115206d73..c22be7f770 100644
--- a/packages/geo/src/lib/search/search.module.ts
+++ b/packages/geo/src/lib/search/search.module.ts
@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
import { provideSearchSourceService } from './shared/search-source-service.providers';
import { provideDefaultIChercheSearchResultFormatter } from './shared/sources/icherche.providers';
+import { provideDefaultCoordinatesSearchResultFormatter } from './shared/sources/coordinates.providers';
import { IgoSearchBarModule } from './search-bar/search-bar.module';
import { IgoSearchSelectorModule } from './search-selector/search-selector.module';
@@ -28,7 +29,8 @@ export class IgoSearchModule {
ngModule: IgoSearchModule,
providers: [
provideSearchSourceService(),
- provideDefaultIChercheSearchResultFormatter()
+ provideDefaultIChercheSearchResultFormatter(),
+ provideDefaultCoordinatesSearchResultFormatter()
]
};
}
diff --git a/packages/geo/src/lib/search/shared/sources/coordinates.interfaces.ts b/packages/geo/src/lib/search/shared/sources/coordinates.interfaces.ts
new file mode 100644
index 0000000000..3f823112e7
--- /dev/null
+++ b/packages/geo/src/lib/search/shared/sources/coordinates.interfaces.ts
@@ -0,0 +1,17 @@
+import { FeatureGeometry } from '../../../feature';
+
+export interface CoordinatesData {
+ coord: [number, number];
+}
+
+export interface CoordinatesResponse {
+ features: CoordinatesData[];
+}
+
+export interface CoordinatesReverseData {
+ coord: [number, number];
+}
+
+export interface CoordinatesReverseResponse {
+ features: CoordinatesData[];
+}
diff --git a/packages/geo/src/lib/search/shared/sources/coordinates.providers.ts b/packages/geo/src/lib/search/shared/sources/coordinates.providers.ts
new file mode 100644
index 0000000000..7e6aeed1a1
--- /dev/null
+++ b/packages/geo/src/lib/search/shared/sources/coordinates.providers.ts
@@ -0,0 +1,56 @@
+import { HttpClient } from '@angular/common/http';
+
+import { ConfigService, LanguageService } from '@igo2/core';
+
+import { SearchSource } from './source';
+import {
+ CoordinatesReverseSearchSource,
+ CoordinatesSearchResultFormatter
+} from './coordinates';
+
+/**
+ * ICherche search result formatter factory
+ * @ignore
+ */
+export function defaultCoordinatesSearchResultFormatterFactory(
+ languageService: LanguageService
+) {
+ return new CoordinatesSearchResultFormatter(languageService);
+}
+
+/**
+ * Function that returns a provider for the ICherche search result formatter
+ */
+export function provideDefaultCoordinatesSearchResultFormatter() {
+ return {
+ provide: CoordinatesSearchResultFormatter,
+ useFactory: defaultCoordinatesSearchResultFormatterFactory,
+ deps: [LanguageService]
+ };
+}
+
+/**
+ * CoordinatesReverse search source factory
+ * @ignore
+ */
+export function CoordinatesReverseSearchSourceFactory(
+ http: HttpClient,
+ config: ConfigService
+) {
+ return new CoordinatesReverseSearchSource(
+ http,
+ config.getConfig(`searchSources.${CoordinatesReverseSearchSource.id}`)
+ );
+}
+
+/**
+ * Function that returns a provider for the IChercheReverse search source
+ */
+export function provideCoordinatesReverseSearchSource() {
+ return {
+ provide: SearchSource,
+ useFactory: CoordinatesReverseSearchSourceFactory,
+ multi: true,
+ deps: [HttpClient, ConfigService]
+ };
+}
diff --git a/packages/geo/src/lib/search/shared/sources/coordinates.ts b/packages/geo/src/lib/search/shared/sources/coordinates.ts
new file mode 100644
index 0000000000..cd60bdda91
--- /dev/null
+++ b/packages/geo/src/lib/search/shared/sources/coordinates.ts
@@ -0,0 +1,93 @@
+import { Injectable, Inject } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
+
+import { Observable, of } from 'rxjs';
+
+import { FEATURE, Feature } from '../../../feature';
+
+import { SearchResult } from '../search.interfaces';
+import { SearchSource, ReverseSearch } from './source';
+import { SearchSourceOptions, TextSearchOptions } from './source.interfaces';
+
+import { LanguageService } from '@igo2/core';
+import { GoogleLinks } from '../../../utils/googleLinks';
+
+@Injectable()
+export class CoordinatesSearchResultFormatter {
+ constructor(private languageService: LanguageService) {}
+
+ formatResult(result: SearchResult): SearchResult {
+ return result;
+ }
+}
+/**
+ * CoordinatesReverse search source
+ */
+@Injectable()
+export class CoordinatesReverseSearchSource extends SearchSource
+ implements ReverseSearch {
+ static id = 'coordinatesreverse';
+ static type = FEATURE;
+
+ constructor(
+ private http: HttpClient,
+ @Inject('options') options: SearchSourceOptions
+ ) {
+ super(options);
+ }
+
+ getId(): string {
+ return CoordinatesReverseSearchSource.id;
+ }
+
+ protected getDefaultOptions(): SearchSourceOptions {
+ return {
+ title: 'Coordinates'
+ };
+ }
+
+ /**
+ * Search a location by coordinates
+ * @param lonLat Location coordinates
+ * @param distance Search raidus around lonLat
+ * @returns Observable of []
+ */
+ reverseSearch(
+ lonLat: [number, number],
+ options?: TextSearchOptions
+ ): Observable[]> {
+ return of([this.dataToResult(lonLat)]);
+ }
+
+ private dataToResult(data: [number, number]): SearchResult {
+ return {
+ source: this,
+ data: {
+ type: FEATURE,
+ projection: 'EPSG:4326',
+ geometry: {
+ type: 'Point',
+ coordinates: [data[0], data[1]]
+ },
+ extent: undefined,
+ properties: {
+ type: 'point',
+ coordonnees: String(data[0]) + ', ' + String(data[1]),
+ format: 'degrés decimaux',
+ systemeCoordonnees: 'WGS84',
+ GoogleMaps: GoogleLinks.getGoogleMapsLink(data[0], data[1]),
+ GoogleStreetView: GoogleLinks.getGoogleStreetViewLink(
+ data[0],
+ data[1]
+ )
+ }
+ },
+ meta: {
+ dataType: FEATURE,
+ id: '1',
+ title: String(data[0]) + ', ' + String(data[1]),
+ icon: 'place'
+ }
+ };
+ }
+}
diff --git a/packages/geo/src/lib/search/shared/sources/index.ts b/packages/geo/src/lib/search/shared/sources/index.ts
index dc6f7cc433..d869d8ab57 100644
--- a/packages/geo/src/lib/search/shared/sources/index.ts
+++ b/packages/geo/src/lib/search/shared/sources/index.ts
@@ -12,3 +12,6 @@ export * from './nominatim.providers';
export * from './storedqueries';
export * from './storedqueries.interfaces';
export * from './storedqueries.providers';
+export * from './coordinates';
+export * from './coordinates.interfaces';
+export * from './coordinates.providers';
diff --git a/packages/geo/src/lib/utils/googleLinks.ts b/packages/geo/src/lib/utils/googleLinks.ts
new file mode 100644
index 0000000000..582093f270
--- /dev/null
+++ b/packages/geo/src/lib/utils/googleLinks.ts
@@ -0,0 +1,9 @@
+export class GoogleLinks {
+ 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 90bf38665f..f0a73f4b90 100644
--- a/packages/geo/src/public_api.ts
+++ b/packages/geo/src/public_api.ts
@@ -35,6 +35,7 @@ export * from './lib/wkt/wkt.module';
export * from './lib/query/shared/query-search-source.providers';
export * from './lib/search/shared/sources/icherche.providers';
+export * from './lib/search/shared/sources/coordinates.providers';
export * from './lib/search/shared/sources/ilayer.providers';
export * from './lib/search/shared/sources/nominatim.providers';
export * from './lib/search/shared/sources/storedqueries.providers';
@@ -58,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';
|