利用半径找到经纬度

  //获取经纬度
  getLocation() {
    let self = this;
    let list = [];
    let radius = this.data.currentScope // 获取当前半径
// envelopeList = ['445','666','1002']
    self.data.envelopeList.forEach((item, index) => {
      let rotate = Math.random()*360; //获取随机弧度,需要把弧度转化为度,三角函数获取经纬度
      var x = (Math.round(Math.cos(rotate * Math.PI / 180) * 1000000) / 1000000 * item) * 0.00000899;
      var y = (Math.round(Math.sin(rotate * Math.PI / 180) * 1000000) / 1000000 * item) * 0.00001141;
      let data = {
        'latitude': self.data.latitude + x,
        'longitude': self.data.longitude + y,
        'width': 50,
        'height': 60,
      }
      if (item <= radius) {
         data['id'] = index + 100;
      }else{
        data.id = index
      }
      if (item <= 1000) {
        data.iconPath = self.data.normalIco;
      } else if (item <= 1200) {
        data.iconPath = self.data.mediumIcon
      } else {
        data.iconPath = self.data.advancedIco
        data.width = 75;
        data.height = 60
      }
      list.push(data)
    })
    self.setData({
      markers:list
    })



  },

  

原文地址:https://www.cnblogs.com/linsx/p/9760780.html