小程序 调用腾讯地图 路线规划

效果

image.png
image.png

image.png

代码

.wxml


  
    
      
经度 纬度

.js

var app = getApp()
Page({
  data: {
    //默认未获取地址
    hasLocation: false
  },
  //获取经纬度
  getLocation: function (e) {
    console.log(e)
    var that = this
    wx.getLocation({
      success: function (res) {
        console.log(res)
        that.setData({
          hasLocation: true,
          location: {
            longitude: res.longitude,
            latitude: res.latitude
          }
        })
      }
    })
  },
  //根据经纬度在地图上显示
  openLocation: function (e) {
    var value = e.detail.value
    wx.openLocation({
      // longitude: Number(value.longitude),
      // latitude: Number(value.latitude)
      longitude: 116.430392,
      latitude: 39.85799,
      name:"今朝装饰",
      address:"丰台区东铁营顺一条8号"
    })
  }
})

你可能感兴趣的:(小程序 调用腾讯地图 路线规划)