SOURCE

//之前存的是宽高坐标
function changeCoorinate(x,y,w,h){
     const WORLD_WIDTH = 20037508.3427892;
     const maxZoom = Math.ceil(Math.log(Math.max(w, h) / 256) / Math.log(2));
     const worldWidth = Math.pow(2, maxZoom) * 256;
     const projWidth = WORLD_WIDTH * (w / worldWidth);
     const projHeight = WORLD_WIDTH * (h / worldWidth);
    //  const x1 = projWidth * (x/w);
    //  const y1 = projHeight * (y/h);
     const x1 = WORLD_WIDTH * (x/worldWidth);
     const y1 = WORLD_WIDTH * (y/worldWidth);
     return {
        "XPos": x1, 
        "YPos": y1
     }
}
//864 * 768
//1024 * 768
const r = changeCoorinate(-172,-609,864,768);
console.log(r)

//{"XPos":-6026906.806229563,"YPos":-2211170.3542335737}
//{"XPos":-13345293.642365463,"YPos":-4402772.829226142}
// {"XPos":-3365675.229452873,"YPos":-11916838.457772091}
console 命令行工具 X clear

                    
>
console