微信小程序地图划线

发布时间:2023-08-03 10:47:12 作者:zhangyi 阅读量:8490

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

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 = this
    wx.getLocation({
      type: 'gcj02',
      success: function (res) {
         that2.setData({
          long: res.longitude,
          lat: res.latitude

        })
       
      }
    })

  }, 


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

  },

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

 
})


***本网站图片,文字之类版权申明,因为网站可以由注册用户自行上传图片或文字,本网站无法鉴别所上传图片或文字的知识版权,如果侵犯,请及时通知我们,本网站将在第一时间及时删除。

我要评论

网友评论


评论时间:2023-09-22 14:00:03

同时在北麻将app开发 京、上海、广州、深圳、武汉、成都、重庆、沈阳等城市开设分支机构,以更好地为广大开发者提供技术支持和运营服务app开发软件排名 服务

回复
秒制作
Catfish(鲶鱼) Blog V 4.7.3