25 lines
886 B
JavaScript
25 lines
886 B
JavaScript
function geoportalButtonClick() {
|
|
geoButton.style.background = "gray";
|
|
let XMIN = MapData.X_MIN;
|
|
let YMIN = MapData.Y_MIN;
|
|
let XMAX = MapData.X_MAX;
|
|
let YMAX = MapData.Y_MAX;
|
|
|
|
// let URL = `https://epsg.io/trans?data=${XMIN},${YMIN};${XMAX},${YMAX}&s_srs=2177&t_srs=2180`; stary endpoint
|
|
let URL = `https://api.maptiler.com/coordinates/transform/${XMIN},${YMIN};${XMAX},${YMAX}.json?s_srs=2177&t_srs=2180&key=OZa2pWHGvC94xakI0fVk`;
|
|
|
|
fetch(URL, {
|
|
method: "GET",
|
|
})
|
|
.then((response) => response.json())
|
|
.then((data) => {
|
|
let NXMIN = data.results[0].x;
|
|
let NYMIN = data.results[0].y;
|
|
let NXMAX = data.results[1].x;
|
|
let NYMAX = data.results[1].y;
|
|
let newURL = `https://mapy.geoportal.gov.pl/imap/Imgp_2.html?gpmap=gp0&bbox=${NXMIN},${NYMIN},${NXMAX},${NYMAX}&variant=KATASTER`;
|
|
window.open(newURL, "_blank");
|
|
geoButton.style.background = "none";
|
|
});
|
|
}
|