0

我在纬度经度网络墨卡托有两点:

var point1 = [32.043732,-99.563599]

var point2 = [32.591515,-97.630005]

如何在需要 X 点的 javascript 函数中的这两个纬度经度对之间获得 3 个点?

4

1 回答 1

0

线性插值

function getPoints(point1, point2, num) {
    var d0 = (point2[0] - point1[0]) / (num + 1);
    var d1 = (point2[1] - point1[1]) / (num + 1);
    var points = [];
    for (var i = 1; i <= num; i++) {
        points.push({
            x: point1[0] + d0 * i,
            y: point1[1] + d1 * i
        });
    }
    return points;
}

jsfiddle

于 2013-06-27T15:25:46.577 回答