调用百度地图画圈并标出属于圈内的点位信息

直接上代码:

fanweiss(){
      // 画圈
  var aaa = this.gaojingData
  debugger
  var map = new BMap.Map("ydmap");            // 创建Map实例
  var mPoint = new BMap.Point(this.gaojingData.longitude, this.gaojingData.latitude);  //中心点
  map.setMapStyle({ style: "midnight" });
  map.enableScrollWheelZoom();
  map.centerAndZoom(mPoint,15);
  let sl = this
  var circle = new BMap.Circle(mPoint,(this.gonglishu)*1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
    map.addOverlay(circle);
    listXiaofangliliang({ xftype: null }).then((response) => {
      response.rows.forEach(el=>{
      var bianjie = new BMap.Point(el.longitude,el.latitude);   
      var distance = map.getDistance(bianjie,mPoint); //计算两点之间的距离、mPoint是圈的中心点
      debugger
      if(distance/1000 < sl.gonglishu){  //gonglishu 这个是半径、判断两点之间的距离是否小于当前圈的半径,小于当前半径说明改点在圈内
          //var marker1 = new BMap.Marker(new BMap.Point(el.longitude, el.latitude));
          // 在地图上添加点标记
          var icon = new BMap.Icon(
            require("./img/zhongdui.gif"),
            new BMap.Size(80, 102),
            {
              //20,30是图片大小
              anchor: new BMap.Size(10, 0), //这个是信息窗口位置(可以改改看看效果)
            }
          );
          if(el.xftype=="7"){
            var marker1 = new BMap.Marker(
              new BMap.Point(el.longitude, el.latitude),
              {
                icon: icon,
              }
            );
            map.addOverlay(marker1);
          }
      }
      })
    })
    
    },

效果:

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我了解了你的问题。首先,你需要使用百度地图的API来获取轨迹点的经纬度信息,然后使用Python的Matplotlib库来绘制轨迹图。 以下是一个简单的步骤: 1. 在百度地图开放平台上创建一个应用,获取到对应的AK(Access Key)。 2. 使用百度地图API的“轨迹纠偏”功能,将原始轨迹点转换为经纬度坐标点,并保存到本地文件中。 3. 使用Python的Matplotlib库,读取保存的经纬度坐标点,绘制轨迹图。 下面是一个简单的代码示例: ```python import requests import json import matplotlib.pyplot as plt # 设置AK ak = 'your_access_key' # 获取轨迹点 url = 'http://api.map.baidu.com/rectify/v1/track?ak={}'.format(ak) data = { "entity_name": "your_entity_name", "start_time": "your_start_time", "end_time": "your_end_time", "is_processed": "1" } response = requests.post(url, data=json.dumps(data)) points = response.json()['points'] # 保存轨迹点到本地文件 with open('points.txt', 'w') as f: for point in points: f.write('{} {}\n'.format(point['x'], point['y'])) # 绘制轨迹图 x = [] y = [] with open('points.txt', 'r') as f: for line in f.readlines(): point = line.strip().split(' ') x.append(float(point[0])) y.append(float(point[1])) plt.plot(x, y) plt.show() ``` 在上述代码中,你需要替换AK、entity_name、start_time和end_time参数为你自己的值。同时,你也可以根据需要自定义轨迹图的样式。 希望这可以帮助到你!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值