Files
wtyczka-zms/js/map_providers/lpp.js

31 lines
901 B
JavaScript

function drogiButtonClick() {
drogiButton.style.background = "gray";
let XMIN = Number(MapData.X_MIN);
let YMIN = Number(MapData.Y_MIN);
let XMAX = Number(MapData.X_MAX);
let YMAX = Number(MapData.Y_MAX);
let X = Math.abs((XMAX - XMIN) / 2);
let Y = Math.abs((YMAX - YMIN) / 2);
// let URL = `https://epsg.io/trans?data=${XMIN + X},${
// YMIN + Y
// }&s_srs=2177&t_srs=4326`; stary endpoint
let URL = `https://api.maptiler.com/coordinates/transform/${XMIN + X},${
YMIN + Y
}.json?s_srs=2177&t_srs=4326&key=OZa2pWHGvC94xakI0fVk`;
fetch(URL, {
method: "GET",
})
.then((response) => response.json())
.then((data) => {
console.log(data);
let NX = data.results[0].x;
let NY = data.results[0].y;
let newURL = `https://powiatnowysacz.lp-portal.pl/#mapView=lon:${NX},lat:${NY},zoom:18`;
window.open(newURL, "_blank");
drogiButton.style.background = "none";
});
}