Skip to content

Commit

Permalink
Fix #250
Browse files Browse the repository at this point in the history
  • Loading branch information
mhhd2020 committed Apr 21, 2023
1 parent 7c7bf9d commit 214b675
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions client-src/create/form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { PAPER_FORMAT, ORIENTATION, Margin } from "@giscience/ol-print-layout-control";
import {
toLonLat, get as getProjection, transformExtent,
} from "ol/proj";
import { SKETCH_MAP_MARGINS } from "./sketchMapMargins";
import { fillSelectOptions, setDisabled } from "../shared";

Expand Down Expand Up @@ -46,14 +49,18 @@ function bindFormToPrintLayoutControl(printLayoutControl) {
// property: bbox (in webmercator)
document.getElementById("bbox").value = JSON.stringify(printLayoutControl.getBbox());
printLayoutControl.on("change:bbox", (event) => {
const newBbox = event.target.getBbox();
document.getElementById("bbox").value = JSON.stringify(newBbox);
let newBbox = event.target.getBbox();
newBbox = toLonLat(newBbox.slice(0, 2)).concat(toLonLat(newBbox.slice(2, 4))); // See https://github.com/GIScience/sketch-map-tool/issues/250
document.getElementById("bbox").value = JSON.stringify(
transformExtent(newBbox, getProjection("EPSG:4326"), getProjection("EPSG:3857")),
);
});

// property: bboxWGS84 (in wgs84)
document.getElementById("bboxWGS84").value = JSON.stringify(printLayoutControl.getBboxAsLonLat());
printLayoutControl.on("change:bbox", (event) => {
const newBbox = event.target.getBboxAsLonLat();
let newBbox = event.target.getBbox();
newBbox = toLonLat(newBbox.slice(0, 2)).concat(toLonLat(newBbox.slice(2, 4))); // See https://github.com/GIScience/sketch-map-tool/issues/250
document.getElementById("bboxWGS84").value = JSON.stringify(newBbox);
});

Expand Down

0 comments on commit 214b675

Please sign in to comment.