Calculate the center point of multiple latitude/longitude coordinate pairs

后端 未结 21 1581
暖寄归人
暖寄归人 2020-11-27 09:27

Given a set of latitude and longitude points, how can I calculate the latitude and longitude of the center point of that set (aka a point that would center a view on all poi

21条回答
  •  感动是毒
    2020-11-27 09:53

    I did this task in javascript like below

    function GetCenterFromDegrees(data){
        // var data = [{lat:22.281610498720003,lng:70.77577162868579},{lat:22.28065743343672,lng:70.77624369747241},{lat:22.280860953131217,lng:70.77672113067706},{lat:22.281863655593973,lng:70.7762061465462}];
        var num_coords = data.length;
        var X = 0.0;
        var Y = 0.0;
        var Z = 0.0;
    
        for(i=0; i

提交回复
热议问题