微信小程序——高德地图展示点、线、圆、多边形

在这里插入图片描述
在这里插入图片描述

  • 点、线、面、圆形的显示
  • 获取周边、天气等

在这里插入图片描述

<view class="map_box">
  <view bindtap="change">点击</view>
  <map class="w100 min100" id="navi_map" longitude="116.451028" latitude="39.949643" scale="12" markers="{{markers}}" polyline="{{polyline}}" circles="{{circles}}" polygons="{{polygons}}" ></map>
</view>
// miniprogram/pages/gao_de/gao_de.js
var amapFile = require('../../libs/amap-wx.js');//如:..­/..­/libs/amap-wx.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    markers: [{ //点
      iconPath: "../../assets/imgs/wx.png",
      latitude: 39.989643,
      longitude: 116.481028,
      width: 20,
      height: 20
    },{
      iconPath: "../../assets/imgs/wx.png",
      latitude: 39.90816,
      longitude: 116.434446,
      width: 20,
      height: 20
    }], 
    polyline: [], // 线
    circles: [{   // 圆(圆心和半径)
      latitude: 39.949643,
      longitude: 116.451028,
      fillColor: "#FFA07A33", // 圆形填充颜色
      strokeColor: "#FFA07A",
      strokeWidth: 2,
      radius: 2000
    }],
    polygons:[{ // 区域(拐点坐标集合)
      points: [
        { latitude: 39.989643, longitude: 116.481028 },
        { latitude: 39.90816, longitude: 116.434446},
        { latitude: 39.889643, longitude: 116.451028 },
        { latitude: 39.919643, longitude: 116.491028 },
      ],
      fillColor: '#FFA07A33',
      strokeColor: '#FFA07A',
      strokeWidth: 2
    }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var myAmapFun = new amapFile.AMapWX({key:'a0ee84c178d16e6045790c612eb51ab9'});
    // 获取周边
    myAmapFun.getPoiAround({
      success: function(data){
        console.log(data)
        //成功回调
      },
      fail: function(info){
        //失败回调
        console.log(info)
      }
    })
    //获取自己所在地址的定位
    myAmapFun.getRegeo({
      success: function(data){
        //成功回调
        console.log(data)
      },
      fail: function(info){
        //失败回调
        console.log(info)
      }
    })

    //获取定位地点天气内容
    myAmapFun.getWeather({
      success: function(data){
        console.log(data,'123')
        //成功回调
      },
      fail: function(info){
        //失败回调
        console.log(info)
      }
    })

    //获取两点之间行车路线
    myAmapFun.getDrivingRoute({
      origin: '116.481028,39.989643',
      destination: '116.434446,39.90816',
      success: function(data){
        var points = [];
        if(data.paths && data.paths[0] && data.paths[0].steps){
          var steps = data.paths[0].steps;
          for(var i = 0; i < steps.length; i++){
            var poLen = steps[i].polyline.split(';');
            for(var j = 0;j < poLen.length; j++){
              points.push({
                longitude: parseFloat(poLen[j].split(',')[0]),
                latitude: parseFloat(poLen[j].split(',')[1])
              })
            } 
          }
        }
        that.setData({
          polyline: [{
            points: points,
            color: "#0091ff",
            width: 6
          }]
        });
        if(data.paths[0] && data.paths[0].distance){
          that.setData({
            distance: data.paths[0].distance + '米'
          });
        }
        if(data.taxi_cost){
          that.setData({
            cost: '打车约' + parseInt(data.taxi_cost) + '元'
          });
        }
          
      },
      fail: function(info){

      }
    })

  }, 
  change(){
    let o = this.data.polygons[0]
    o.points = [ { latitude: 39.989643, longitude: 116.481028 },
      { latitude: 39.90816, longitude: 116.434446},
      { latitude: 39.889643, longitude: 116.451028 },]
    this.setData({
      ['polygons[0]']: o,
    })
  }
})

### 小米音箱集成至Deepseek平台的方法 为了实现小米音箱与Deepseek平台的成功对接,通常需要遵循一系列特定的开发流程和技术指导。这不仅涉及到硬件设备的支持情况确认,还需要深入了解双方提供的API接口以及可能存在的兼容性考量。 针对小米音箱接入第三方服务平台的操作,建议参照官方文档来获取最权威的信息[^1]。一般情况下,此类操作会涉及以下几个方面: #### 一、前期准备 确保拥有必要的开发者权限,并完成相应的注册过程,在此期间需仔细阅读并同意相关协议条款。同时,收集好所需的技术资料,比如产品手册、SDK包等资源文件。 #### 二、环境搭建 安装所需的软件工具链,配置本地测试环境以便后续调试工作顺利开展。对于某些特殊功能模块,则要按照说明进行额外设置。 #### 三、核心逻辑编写 依据Deepseek所提供的API文档来进行编程实践,重在于构建语音交互模型和服务端响应机制。在此过程中可以借鉴其他成功案例的经验分享,提高解决问题效率的同时也降低了项目风险。 ```python import requests def send_command_to_deepseek(command): url = "https://api.deepseek.com/v1/command" headers = { 'Authorization': 'Bearer YOUR_ACCESS_TOKEN', 'Content-Type': 'application/json' } payload = {"command": command} response = requests.post(url, json=payload, headers=headers) return response.json() ``` 上述代码片段展示了如何利用Python发送HTTP请求给Deepseek API服务器执行命令的一个简单例子。实际应用中还需考虑更多细节处理,如错误重试策略、超时控制等。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小曲曲

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值