商城系统 注册

微信小程序地图划线

2018-05-30|HiShop
导读:微信小程序地图划线,是小程序很基本的功能,那么小程序地图划线要怎么实现呢。...

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

微信小程序地图划线
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) 
   
  }

 
})


电话咨询 预约演示 0元开店