From 94d5725c42b482dca66d322e1809781ab4c474b1 Mon Sep 17 00:00:00 2001 From: Janis Meister Date: Fri, 14 Jan 2022 12:48:51 +0100 Subject: [PATCH] coodinates are saved in hidden inputs --- src/app/search/search.component.html | 18 ++++++++++-------- src/app/search/search.component.ts | 28 +++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/app/search/search.component.html b/src/app/search/search.component.html index 2efdacb..d512acb 100644 --- a/src/app/search/search.component.html +++ b/src/app/search/search.component.html @@ -1,13 +1,13 @@
- - + + - - + +
- +
@@ -15,14 +15,15 @@
-
+
{{ item.properties.name }} {{item.properties.postcode}} {{item.properties.city}} {{item.properties.countrycode}}
- +
@@ -30,7 +31,8 @@
-
+
{{ 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 3008680..0aeacb4 100644 --- a/src/app/search/search.component.ts +++ b/src/app/search/search.component.ts @@ -19,6 +19,9 @@ export class SearchComponent implements OnInit { photonItemsFrom: Photon[] = []; photonItemsTo: Photon[] = []; + inputFromValue: string; + inputToValue: string; + longFrom: number = 0; latFrom: number = 0; longTo: number = 0; @@ -26,13 +29,28 @@ export class SearchComponent implements OnInit { constructor(private nominatimService: NominatimService, private photonService: PhotonService) { } - changeInputs(isFrom: boolean, long: number, lat: number): void{ + selectPhoton(isFrom: boolean, p: Photon): void{ if(isFrom){ - this.longFrom = long; - this.latFrom = lat; + this.longFrom = p.geometry?.coordinates[0]; + this.latFrom = p.geometry?.coordinates[1]; + this.inputFromValue = p.properties.name + + if(p.properties.postcode){ + this.inputFromValue += " " + p.properties.postcode; + } + + if(p.properties.city){ + this.inputFromValue += " " + p.properties.city; + } + + if(p.properties.countrycode){ + this.inputFromValue += " " + p.properties.countrycode; + } + }else{ - this.longTo = long; - this.latTo = lat; + this.longTo = p.geometry?.coordinates[0]; + this.latTo = p.geometry?.coordinates[1]; + this.inputToValue = p.properties.name + " " + p.properties.countrycode; } } // Gets called in "app.component.html" when an input changes its value