From c73eaf9053b46be750cb49674c7260ba42840d27 Mon Sep 17 00:00:00 2001 From: zdenevuk <zdenko.vuk@ijs.si> Date: Thu, 24 Nov 2022 14:47:45 +0100 Subject: [PATCH] improved map zoom and location --- .../results-map/results-map.component.ts | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/app/pages/simulation-wizard/results-map/results-map.component.ts b/src/app/pages/simulation-wizard/results-map/results-map.component.ts index c5584b28..526199be 100644 --- a/src/app/pages/simulation-wizard/results-map/results-map.component.ts +++ b/src/app/pages/simulation-wizard/results-map/results-map.component.ts @@ -625,18 +625,23 @@ export class ResultsMapComponent implements OnChanges { } setMapZoom() { - if (this.selectedSimulation["city"]["cityId"] == "amsterdam") { - this.map.setView(new L.LatLng(52.4, 4.9), 9); - } else if (this.selectedSimulation["city"]["cityId"] == "bilbao") { - this.map.setView(new L.LatLng(43.3, -2.9), 9); - } else if (this.selectedSimulation["city"]["cityId"] == "helsinki") { - this.map.setView(new L.LatLng(60.2, 24.9), 9); - } else if (this.selectedSimulation["city"]["cityId"] == "messina") { - this.map.setView(new L.LatLng(38.2, 15.6), 9); - } else { - this.toastrService.show("Unexpected value for city name.", "Error", { - status: "danger", - }); + if (this.selectedSimulation != undefined) { + if (this.selectedSimulation["city"]["cityId"] == "amsterdam") { + this.map.setView(new L.LatLng(52.4, 4.9), 9); + } else if (this.selectedSimulation["city"]["cityId"] == "bilbao") { + this.map.setView(new L.LatLng(43.3, -2.9), 9); + } else if (this.selectedSimulation["city"]["cityId"] == "helsinki") { + this.map.setView( + new L.LatLng(60.16005488265436, 24.920971999284017), + 13 + ); + } else if (this.selectedSimulation["city"]["cityId"] == "messina") { + this.map.setView(new L.LatLng(38.2, 15.6), 9); + } else { + this.toastrService.show("Unexpected value for city name.", "Error", { + status: "danger", + }); + } } } @@ -671,5 +676,7 @@ export class ResultsMapComponent implements OnChanges { Object.entries(this.loadGeojsons).forEach((entry) => { entry[1]["response"] = undefined; }); + + this.setMapZoom(); } } -- GitLab