沿两点之间的一条线获取纬度和经度点,按百分比

Ala*_*lan 1 javascript math geo latitude-longitude leaflet

在下图中,您可以看到从一个点(黑色圆圈)到其 3 个相关点 () 绘制了 3 条线。

图片

在此处输入图片说明

如何使用两点之间距离的百分比计算每条线上点之间的纬度和经度点?

例如,如果我想让位置能够沿着每条线绘制额外的圆圈,差异为 20%?

我现在有什么代码

var data = [
  { "coords" : [ 53.409045, -2.985406 ]},
  { "coords" : [ 53.408747, -2.982862 ]},
  { "coords" : [ 53.407630, -2.984136 ]},
  { "coords" : [ 53.407142, -2.986931 ]}
];


var pointA = new L.LatLng(53.409045, -2.985406);
var pointB; 

data.forEach(function(d) {
  pointB = new L.LatLng(d.coords[0], d.coords[1]);
  L.polyline([pointA, pointB]).addTo(map);
  L.circle([d.coords[0], d.coords[1]], 10).addTo(map);
});
Run Code Online (Sandbox Code Playgroud)

上面的代码唯一要做的就是为每个点画一个圆,并从主圆(点A)到其他圆(点B)画一条线

我非常需要知道如何按距离百分比计算点 A 及其相关点之间的多个坐标。

我需要确保所有绿色圆圈与中心圆圈的距离相同

用于测试的 CODEP

代码笔链接

编辑 - 到目前为止我使用以下正确答案的图像

在此处输入图片说明 在此处输入图片说明

Jus*_*elt 5

请参阅此页面了解您的不同方程式。http://www.movable-type.co.uk/scripts/latlong.html

  1. 获取从起点到终点的距离和方位。
  2. 将百分比转换为适用单位的距离。
  3. 使用#1 的方位、#2 的距离和原点来获得结果位置

    function destination(lat, lon, bearing, distance) {
        var R = 6378.1, lat, lon, latDest, lonDest;
    
        // convert to radians
        lat = lat * (Math.PI / 180);
        lon = lon * (Math.PI / 180);
        bearing = bearing * (Math.PI / 180);
    
        latDest = Math.asin(Math.sin(lat) * Math.cos(distance / R) +
            Math.cos(lat) * Math.sin(distance / R) * Math.cos(bearing));
    
        lonDest = lon + Math.atan2(Math.sin(bearing) * Math.sin(distance / R) * Math.cos(lat),
                Math.cos(distance / R) - Math.sin(lat) * Math.sin(latDest));
    
        return [latDest * (180 / Math.PI), lonDest * (180 / Math.PI)];
    }
    
    Run Code Online (Sandbox Code Playgroud)