zoukankan      html  css  js  c++  java
  • 如何用地图经纬度计算给出中心位置

    /**
     * 根据一组点位([纬度,经度])计算出中心点
     * @param pointArray
     * @returns {*[]}
     */
    const calculateCenterPoint=(pointArray)=>{
      const sortedLongitudeArray=pointArray.map(item=>item.lng).sort();
      const sortedLatitudeArray=pointArray.map(item=>item.lat).sort();
      const centerLongitude=((sortedLongitudeArray[0]+sortedLongitudeArray[sortedLongitudeArray.length-1])/2).toFixed(4);
      const centerLatitude=((sortedLatitudeArray[0]+sortedLatitudeArray[sortedLatitudeArray.length-1])/2).toFixed(4);
      return [centerLongitude,centerLatitude];
    };
    
    export default calculateCenterPoint;
  • 相关阅读:
    五一训练礼包 — B
    五一训练礼包—坐标问题
    单链表
    顺序表
    链表
    基础DP(3)
    基础DP(2)
    基础DP(1)
    分治法
    最小表示法
  • 原文地址:https://www.cnblogs.com/art-poet/p/12845807.html
Copyright © 2011-2022 走看看