【发布时间】:2016-01-26 15:36:23
【问题描述】:
我想要做的是在绘制后替换或更改特征的几何形状。例如:我画了一条线,画完之后我用Turf.js修改几何图形,在画线周围做一个缓冲区,并显示缓冲的线(多边形)而不是线。
var draw = new ol.interaction.Draw({
source: vectorSource,
type: 'LineString'
});
draw.on('drawend', function(e) {
//Sending the LineString to a Turf function with a buffer value and getting a Polygon in return
var bfc = bufferedFeatureCollection(100, e.feature);
//Replacing the LineString geometry with a Polygon geometry
e.feature.setGeometry(bfc[0].getGeometry());
//Removes and terminates the draw action....
map.removeInteraction(this);
});
现在从console.log(),我可以看到feature.geometry 已从ol.geom.linestring 更改为ol.geom.polygon。但在地图上我仍然看到一条线正在显示。
我做错了什么?
【问题讨论】: