上代码:
[javascript] view plain copy
1.var point = []
2.var that2
- 6.function drawline() {
- that2.setData({
- polyline: [{
- points: point,
- color: “#99FF00”,
- width: 4,
- dottedLine: false
- }],
- })
- 21.}
22.//获取经纬度
23.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)
- }
- })
- 36.}
- 39.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)
- }
- 88.})