Skip to content
Snippets Groups Projects
Commit ce133fd3 authored by zdenko.vuk@ijs.si's avatar zdenko.vuk@ijs.si
Browse files

This is a combination of 2 commits.

added getMapInfo, but currently getting a cors error

corrected url
parent 8c457db4
Branches
Tags
No related merge requests found
...@@ -5,6 +5,7 @@ import * as MapColors from "./map-colors-local"; ...@@ -5,6 +5,7 @@ import * as MapColors from "./map-colors-local";
import { legendInverted, ratiosBetweenGrades } from "./results-map-settings"; import { legendInverted, ratiosBetweenGrades } from "./results-map-settings";
import { NbToastrService, NbDialogService } from "@nebular/theme"; import { NbToastrService, NbDialogService } from "@nebular/theme";
import { Simulation } from "../utils/data/simulation"; import { Simulation } from "../utils/data/simulation";
import { NetworkService } from "../utils/services/network.service";
@Component({ @Component({
selector: "ngx-results-map", selector: "ngx-results-map",
...@@ -39,13 +40,18 @@ export class ResultsMapComponent implements OnChanges { ...@@ -39,13 +40,18 @@ export class ResultsMapComponent implements OnChanges {
constructor( constructor(
private simulationService: SimulationService, private simulationService: SimulationService,
private toastrService: NbToastrService, private toastrService: NbToastrService,
private dialogService: NbDialogService private dialogService: NbDialogService,
private networkService: NetworkService
) {} ) {}
onMapReady(map: L.Map) { onMapReady(map: L.Map) {
this.map = map; this.map = map;
this.grayscaleChange(); this.grayscaleChange();
setTimeout(() => { setTimeout(() => {
this.map.invalidateSize(); this.map.invalidateSize();
this.networkService.getMapInfo().subscribe((res) => {
console.log("🚀☢ ~ res", res);
this.setMapPositionAndZoom(res)
});
}, 50); }, 50);
// setTimeout(() => { // setTimeout(() => {
// console.log( // console.log(
...@@ -72,7 +78,7 @@ export class ResultsMapComponent implements OnChanges { ...@@ -72,7 +78,7 @@ export class ResultsMapComponent implements OnChanges {
onLoadClick(selectedKpi: string) { onLoadClick(selectedKpi: string) {
this.selectedGeojson = selectedKpi; this.selectedGeojson = selectedKpi;
this.resetLayersAndButton(); this.resetLayersAndButton();
this.setMapZoomAndLoadGeojsons(); this.setLoadGeojsons();
if (this.radioButtonLayersControl) if (this.radioButtonLayersControl)
this.radioButtonLayersControl.remove(this.map); this.radioButtonLayersControl.remove(this.map);
...@@ -613,10 +619,9 @@ export class ResultsMapComponent implements OnChanges { ...@@ -613,10 +619,9 @@ export class ResultsMapComponent implements OnChanges {
el.style.filter = "grayscale(" + (100 - this.grayscale) + "%)"; el.style.filter = "grayscale(" + (100 - this.grayscale) + "%)";
} }
setMapZoomAndLoadGeojsons() { setLoadGeojsons() {
if (this.selectedSimulation != undefined) { if (this.selectedSimulation != undefined) {
if (this.selectedSimulation["city"]["cityId"] == "amsterdam") { if (this.selectedSimulation["city"]["cityId"] == "amsterdam") {
this.map.setView(new L.LatLng(52.4, 4.9), 9);
this.loadGeojsons = [ this.loadGeojsons = [
{ {
response: undefined, response: undefined,
...@@ -640,7 +645,6 @@ export class ResultsMapComponent implements OnChanges { ...@@ -640,7 +645,6 @@ export class ResultsMapComponent implements OnChanges {
}, },
]; ];
} else if (this.selectedSimulation["city"]["cityId"] == "bilbao") { } else if (this.selectedSimulation["city"]["cityId"] == "bilbao") {
this.map.setView(new L.LatLng(43.3, -2.9), 9);
console.log( console.log(
"%c buttons set might not be the right ones for bilbao", "%c buttons set might not be the right ones for bilbao",
"background: indianred; font-weight: bold; color: black; font-family: serif; padding: 0 10px;" "background: indianred; font-weight: bold; color: black; font-family: serif; padding: 0 10px;"
...@@ -668,10 +672,6 @@ export class ResultsMapComponent implements OnChanges { ...@@ -668,10 +672,6 @@ export class ResultsMapComponent implements OnChanges {
}, },
]; ];
} else if (this.selectedSimulation["city"]["cityId"] == "helsinki") { } else if (this.selectedSimulation["city"]["cityId"] == "helsinki") {
this.map.setView(
new L.LatLng(60.16005488265436, 24.920971999284017),
13
);
this.loadGeojsons = [ this.loadGeojsons = [
{ {
response: undefined, response: undefined,
...@@ -695,10 +695,6 @@ export class ResultsMapComponent implements OnChanges { ...@@ -695,10 +695,6 @@ export class ResultsMapComponent implements OnChanges {
}, },
]; ];
} else if (this.selectedSimulation["city"]["cityId"] == "messina") { } else if (this.selectedSimulation["city"]["cityId"] == "messina") {
this.map.setView(
new L.LatLng(38.10119097299323, 15.491646372349038),
9
);
console.log( console.log(
"%c buttons set might not be the right ones for messina", "%c buttons set might not be the right ones for messina",
"background: magenta; font-weight: bold; color: black; font-family: serif; padding: 0 10px;" "background: magenta; font-weight: bold; color: black; font-family: serif; padding: 0 10px;"
...@@ -765,6 +761,11 @@ export class ResultsMapComponent implements OnChanges { ...@@ -765,6 +761,11 @@ export class ResultsMapComponent implements OnChanges {
entry[1]["response"] = undefined; entry[1]["response"] = undefined;
}); });
this.setMapZoomAndLoadGeojsons(); this.setLoadGeojsons();
}
setMapPositionAndZoom(res: Object) {
console.log("🚀☢ ~ res", res)
this.map.setView(new L.LatLng(0, 0), 7);
} }
} }
...@@ -81,4 +81,14 @@ export class NetworkService { ...@@ -81,4 +81,14 @@ export class NetworkService {
}) })
); );
} }
getMapInfo(): Observable<any> {
return this.httpClient.get(`${this.dssUrl}/map-info`).pipe(
map((res) => {
return res;
}),
tapDebugApi,
catchError(this.handleError)
);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment