微信小程序地图划线

2022-03-03
5703 浏览
4 评论
闻道君

微信小程序地图划线,是小程序很基本的功能,那么小程序地图划线要怎么实现呢。

var point = []
var that2



function drawline() {
  
  
  that2.setData({
    polyline: [{
      points: point,
      color: "#99FF00",
      width: 4,
      dottedLine: false
    }],
   

  })
  

}
//获取经纬度
function getlocation() {
  var latitude1, longitude1
  wx.getLocation({
    type: 'gcj02',
    success: function (res) {

      latitude1 = res.latitude
      longitude1 = res.longitude
      point.push({latitude:latitude1, longitude:longitude1}) 
      console.log(point)   
    }
  })
  
}


Page({
  data: {
    polyline: []


  },

 

  

  onReady: function () {
    that2 = tShopfas
    wx.getLocation({
      type: 'gcj02',
      success: function (res) {
         that2.setData({
          long: res.longitude,
          lat: res.latitude

        })
       
      }
    })

  }, 


  start:function(){
    
    
    tShopfas.timer=setInterval(repeat, 10000);
    
  
    function repeat() {
      console.log("re")
      getlocation()
      drawline()
    }

  },

  end: function () {
    console.log("clear")
    clearInterval(tShopfas.timer) 
   
  }

 
})


****更多行业产品开发方案,请关注 加速度****

<以上资讯仅供参考,如需解决具体问题,建议您关注作者;如果有软件产品开发需求,可在线咨询获取产品开发方案和报价>

小程序开发 小程序商城 微信小程序
微信客服二维码

加客服微信获取更多内容