diff --git a/src/app/interfaces/nominatim.ts b/src/app/interfaces/nominatim.ts index ffbd6e6..1f59ce9 100644 --- a/src/app/interfaces/nominatim.ts +++ b/src/app/interfaces/nominatim.ts @@ -2,7 +2,7 @@ export interface Nominatim { boundingbox?: Array; category?: string; - display_name: string; + display_name?: string; icon?: string; importance?: number; lat?: string; diff --git a/src/app/search/search.component.css b/src/app/search/search.component.css index e72df43..b5ee381 100644 --- a/src/app/search/search.component.css +++ b/src/app/search/search.component.css @@ -1,3 +1,10 @@ +#inputFrom:focus + .autocomplete-items-from{ + display:block; +} + +#inputTo:focus + .autocomplete-items-to{ + display:block; +} .searchField{ display:block; @@ -24,6 +31,7 @@ } .autocomplete-items { + display:none; position: absolute; border: 1px solid #d4d4d4; border-bottom: none; diff --git a/src/app/search/search.component.html b/src/app/search/search.component.html index ef00636..e483cf5 100644 --- a/src/app/search/search.component.html +++ b/src/app/search/search.component.html @@ -1,7 +1,7 @@
-
+
{{ item.display_name }} @@ -9,8 +9,8 @@
- -
+ +
{{ item.display_name }} diff --git a/src/app/search/search.component.ts b/src/app/search/search.component.ts index fe33456..f949500 100644 --- a/src/app/search/search.component.ts +++ b/src/app/search/search.component.ts @@ -16,24 +16,18 @@ export class SearchComponent implements OnInit { constructor(private nominatimService: NominatimService) { } - updateAutoCompleteList(itemsFrom: Nominatim[], itemsTo: Nominatim[]): void{ - - this.itemsFrom = itemsFrom; - this.itemsTo = itemsTo; - - /*this.autocompleteList.nativeElement.innerHTML = ""; - items.forEach(item => { - this.autocompleteList.nativeElement.innerHTML += '
' + item.display_name + '
' ; - });*/ - } // Gets called in "app.component.html" when an input changes its value getValue(valueFrom:string, valueTo:string): void{ console.log("From " + valueFrom + " to " + valueTo); - this.updateAutoCompleteList([{display_name: 'Hallo'}, {display_name: 'Test2'}], [{display_name: 'Halload'}, {display_name: 'Test4'}]); + + //this.updateAutoCompleteList([{display_name: 'Hallo'}, {display_name: 'Test2'}], [{display_name: 'Halload'}, {display_name: 'Test4'}]); - /*this.nominatimService.sendQueryRequest(valueFrom) - .subscribe((response: Nominatim[]) => this.updateAutoCompleteList(response));*/ + this.nominatimService.sendQueryRequest(valueFrom) + .subscribe((response: Nominatim[]) => this.itemsFrom = response); + + this.nominatimService.sendQueryRequest(valueTo) + .subscribe((response: Nominatim[]) => this.itemsTo = response); } ngOnInit(): void {