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)
}
})
微信小程序地图划线
最新推荐文章于 2024-05-02 00:15:28 发布