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
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import * as MapColors from "./map-colors-local";
import { legendInverted, ratiosBetweenGrades } from "./results-map-settings";
import { NbToastrService, NbDialogService } from "@nebular/theme";
import { Simulation } from "../utils/data/simulation";
import { NetworkService } from "../utils/services/network.service";
@Component({
selector: "ngx-results-map",
......@@ -39,13 +40,18 @@ export class ResultsMapComponent implements OnChanges {
constructor(
private simulationService: SimulationService,
private toastrService: NbToastrService,
private dialogService: NbDialogService
private dialogService: NbDialogService,
private networkService: NetworkService
) {}
onMapReady(map: L.Map) {
this.map = map;
this.grayscaleChange();
setTimeout(() => {
this.map.invalidateSize();
this.networkService.getMapInfo().subscribe((res) => {
console.log("🚀☢ ~ res", res);
this.setMapPositionAndZoom(res)
});
}, 50);
// setTimeout(() => {
// console.log(
......@@ -72,7 +78,7 @@ export class ResultsMapComponent implements OnChanges {
onLoadClick(selectedKpi: string) {
this.selectedGeojson = selectedKpi;
this.resetLayersAndButton();
this.setMapZoomAndLoadGeojsons();
this.setLoadGeojsons();
if (this.radioButtonLayersControl)
this.radioButtonLayersControl.remove(this.map);
......@@ -613,10 +619,9 @@ export class ResultsMapComponent implements OnChanges {
el.style.filter = "grayscale(" + (100 - this.grayscale) + "%)";
}
setMapZoomAndLoadGeojsons() {
setLoadGeojsons() {
if (this.selectedSimulation != undefined) {
if (this.selectedSimulation["city"]["cityId"] == "amsterdam") {
this.map.setView(new L.LatLng(52.4, 4.9), 9);
this.loadGeojsons = [
{
response: undefined,
......@@ -640,7 +645,6 @@ export class ResultsMapComponent implements OnChanges {
},
];
} else if (this.selectedSimulation["city"]["cityId"] == "bilbao") {
this.map.setView(new L.LatLng(43.3, -2.9), 9);
console.log(
"%c buttons set might not be the right ones for bilbao",
"background: indianred; font-weight: bold; color: black; font-family: serif; padding: 0 10px;"
......@@ -668,10 +672,6 @@ export class ResultsMapComponent implements OnChanges {
},
];
} else if (this.selectedSimulation["city"]["cityId"] == "helsinki") {
this.map.setView(
new L.LatLng(60.16005488265436, 24.920971999284017),
13
);
this.loadGeojsons = [
{
response: undefined,
......@@ -695,10 +695,6 @@ export class ResultsMapComponent implements OnChanges {
},
];
} else if (this.selectedSimulation["city"]["cityId"] == "messina") {
this.map.setView(
new L.LatLng(38.10119097299323, 15.491646372349038),
9
);
console.log(
"%c buttons set might not be the right ones for messina",
"background: magenta; font-weight: bold; color: black; font-family: serif; padding: 0 10px;"
......@@ -765,6 +761,11 @@ export class ResultsMapComponent implements OnChanges {
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 {
})
);
}
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