MAP组件 有添加覆盖物的方法吗?
找了半天,只有polyline这个属性。可是MAP的参数只是初始化时加载一次。
如果我想实时获取坐标,并进行地图画线,试了下是不行的。
有没有类似百度的添加覆盖物的方法
强烈希望增加此功能
找了半天,只有polyline这个属性。可是MAP的参数只是初始化时加载一次。
如果我想实时获取坐标,并进行地图画线,试了下是不行的。
有没有类似百度的添加覆盖物的方法
var polyline = new BMap.Polyline([ new BMap.Point(116.399, 39.910), new BMap.Point(116.405, 39.920) ],{strokeColor:"blue", strokeWeight:6, strokeOpacity:0.5} );
map.addOverlay(polyline);
强烈希望增加此功能
感谢,已经搞定了。
点击这个按钮后,会触发画轨迹的方法
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
}
});
}
});
}