生成指定数量的多组经度线数

45 阅读1分钟
// 初始值
[
  [
    [0,0],[0,1]
  ],
]
// 处理后
[
  [
    [0,0],[0,1]
  ],
  [
    [0,1],[0,2] //第二项累加1
  ],
]
// 计算经度
function addLongitude (latlngss) {
  // 初始值
  let result = [...latlngss]; // 复制原始数组
  let currentIndex = 0;
  let latlngssIndex = latlngss.length;
  let currentValue = [];
  latlngss.map((e, index) => {
    // console.log(index, latlngssIndex, "e");
    if (index == latlngssIndex - 1) {
      currentValue = e;
      return currentValue;
    } else {
    }
  });
//   console.log(currentValue, "currentValue");
  let items = [];
  let arr = [];
  currentValue.map((item) => {
    items[0] = item[0];
    items[1] = item[1] + 0.00168;
    arr.push(items);
    items = [];
  });
  result.push(arr);
  arr = [];
  currentIndex++;
  return result;
};
 let longitude = [
        [
          [29.52774, 113.36195],
          [29.55154, 113.36195],
        ],
      ];
      for (let i = 0; i < 14; i++) {
        const newLatlngss = addLongitude(longitude);
        longitude = newLatlngss;
      }