3 回答

TA貢獻1780條經(jīng)驗 獲得超4個贊
您可能希望將地圖縮小到 400 像素 x 400 像素的網(wǎng)格。假設您有 alxw 大小的實時地圖,您可以執(zhí)行以下操作:
function positionToPixels(x, y) {
//You may want to parseInt or something
let newX = 400 * x / w;
let newY = 400 * y / l;
return [newX, newY];
}
我們所做的只是說原始對象與邊緣的距離將與映射對象與其邊緣的距離成正比

TA貢獻1712條經(jīng)驗 獲得超3個贊
這取決于英尺的面積。如果以英尺為單位的面積 = 1000x1000,您可以執(zhí)行以下操作:
const areaF = {w: 1000, h: 1000};
const areaP = {w: 400, h: 400};
const locationFeetToPixel (x, y) {
const relativeX = x / areaF.w;
const relativeY = y / areaF.h;
const pX = areaP.w * relativeX;
const pY = areaP.h * relativeY;
return {x: pX, y: pY};
}
添加回答
舉報