From 082ccfef5b674336b1b83323179a1bc354dff648 Mon Sep 17 00:00:00 2001 From: Janis Meister Date: Fri, 14 Jan 2022 10:10:34 +0100 Subject: [PATCH] finished auto suggestions --- src/app/interfaces/photon.ts | 2 ++ src/app/photon.service.ts | 2 +- src/app/search/search.component.html | 6 +++--- src/app/search/search.component.ts | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/interfaces/photon.ts b/src/app/interfaces/photon.ts index 4a69e29..c4628ed 100644 --- a/src/app/interfaces/photon.ts +++ b/src/app/interfaces/photon.ts @@ -13,6 +13,8 @@ interface PhotonProperties{ osm_value?: string; name?: string; type?: string; + postcode?: string; + city?: string; } export interface Photon{ diff --git a/src/app/photon.service.ts b/src/app/photon.service.ts index 8f98415..42aa3b1 100644 --- a/src/app/photon.service.ts +++ b/src/app/photon.service.ts @@ -13,6 +13,6 @@ export class PhotonService{ // sends a query request to Photon and gets response (https://photon.komoot.io/) sendQueryRequest(q: string): Observable { - return this.http.get("https://photon.komoot.io/api/?q=" + q); + return this.http.get("https://photon.komoot.io/api/?q=" + q + "&limit=10"); } } \ No newline at end of file diff --git a/src/app/search/search.component.html b/src/app/search/search.component.html index 4f500f8..79438e1 100644 --- a/src/app/search/search.component.html +++ b/src/app/search/search.component.html @@ -8,8 +8,8 @@ -
- {{ item.properties.name }} +
+ {{ item.properties.name }} {{item.properties.postcode}} {{item.properties.city}} {{item.properties.countrycode}}
@@ -25,7 +25,7 @@
- {{ item.properties.name }} + {{ item.properties.name }} {{item.properties.postcode}} {{item.properties.city}} {{item.properties.countrycode}}
diff --git a/src/app/search/search.component.ts b/src/app/search/search.component.ts index 21aa988..ae8f326 100644 --- a/src/app/search/search.component.ts +++ b/src/app/search/search.component.ts @@ -35,13 +35,15 @@ export class SearchComponent implements OnInit { this.nominatimService.sendQueryRequest(valueTo) .subscribe((response: Nominatim[]) => this.nominatimItemsTo = response); */ + this.photonItemsFrom = []; + this.photonItemsTo = []; this.photonService.sendQueryRequest(valueFrom) .subscribe((response: PhotonFeatureCollection) => response.features?.forEach(feature => { this.photonItemsFrom.push(feature); })); - this.photonService.sendQueryRequest(valueFrom) + this.photonService.sendQueryRequest(valueTo) .subscribe((response: PhotonFeatureCollection) => response.features?.forEach(feature => { this.photonItemsTo.push(feature); }));