finished auto suggestions

This commit is contained in:
Janis Meister
2022-01-14 10:10:34 +01:00
parent 248c274e8a
commit 082ccfef5b
4 changed files with 9 additions and 5 deletions

View File

@@ -13,6 +13,8 @@ interface PhotonProperties{
osm_value?: string;
name?: string;
type?: string;
postcode?: string;
city?: string;
}
export interface Photon{

View File

@@ -13,6 +13,6 @@ export class PhotonService{
// sends a query request to Photon and gets response (https://photon.komoot.io/)
sendQueryRequest(q: string): Observable<PhotonFeatureCollection> {
return this.http.get<PhotonFeatureCollection>("https://photon.komoot.io/api/?q=" + q);
return this.http.get<PhotonFeatureCollection>("https://photon.komoot.io/api/?q=" + q + "&limit=10");
}
}

View File

@@ -8,8 +8,8 @@
<input type="hidden" value="{{ item.display_name }}">
</div>
<div *ngFor="let item of photonItemsTo" >
{{ item.properties.name }}
<div *ngFor="let item of photonItemsFrom" >
{{ item.properties.name }} {{item.properties.postcode}} {{item.properties.city}} {{item.properties.countrycode}}
<input type="hidden" value="{{ item.properties?.name }}">
</div>
@@ -25,7 +25,7 @@
</div>
<div *ngFor="let item of photonItemsTo" >
{{ item.properties.name }}
{{ item.properties.name }} {{item.properties.postcode}} {{item.properties.city}} {{item.properties.countrycode}}
<input type="hidden" value="{{ item.properties?.name }}">
</div>

View File

@@ -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);
}));