利用半径找到经纬度

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  //获取经纬度
  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
    })
 
 
 
  },

  

posted @   boyanh  阅读(364)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示