微信小程序地圖劃線
2018-05-30|HiShop
導(dǎo)讀:微信小程序地圖劃線,是小程序很基本的功能,那么小程序地圖劃線要怎么實(shí)現(xiàn)呢。...
微信小程序地圖劃線,是小程序很基本的功能,那么小程序地圖劃線要怎么實(shí)現(xiàn)呢。
var point = [] var that2 function drawline() { that2.setData({ polyline: [{ points: point, color: "#99FF00", width: 4, dottedLine: false }], }) } //獲取經(jīng)緯度 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) } })