@jeff
感谢,已经搞定了。
点击这个按钮后,会触发画轨迹的方法
carGo: function () {
start = true;
timer = setInterval(this.drawLine,5000);//绘制轨迹
},
//获得了坐标,动态绑定map的参数,就可以实时画轨迹了
drawLine : function() {
var that = this;
wx.getLocation( {
type: ‘gcj02’,
success: function( res ) {
var polyline = that.data.polyline[0];
var points = polyline.points;
var obj = new Object();
obj[“longitude”] = res.longitude;
obj[“latitude”] = res.latitude;
points.push(obj);
console.info(that);
console.info(new Date());
polyline[“points”] = points;
console.info(polyline);
that.setData({
polyline: [polyline],
location: {
longitude: res.longitude,
latitude: res.latitude
}
});
}
});
}