我有一个使用OL3的JS代码。我想做的是绘制线条并进行捕捉和分裂。到目前为止,我已经做到了这一切,但有一件小事。我想强调应该被捕捉的点或线被打破的点。但是,由于此过程在添加新行后立即完成,因此当前添加的行仍会突出显示。我想在突出显示节点之前取消选择它。
以下是我的代码片段:
var addFeatureEventListener = vector2.getSource().on('addfeature', addFeatureFunction);
function addFeatureFunction(e){
map.removeInteraction(lineStringdraw);
vector2.getSource().unByKey(addFeatureEventListener);
//console.info("the listener is deactivated now....");
var currentFeture = vector2.getSource().getFeatures()[vector2.getSource().getFeatures().length-1];
if(!undone){
var featureGeom = currentFeture.getGeometry();
console.info(featureGeom.getCoordinates().toString())
var endNodeCoordinates = featureGeom.getLastCoordinate();
snapIndex= endNodeCoordinates.length-1;
selectedFeatures.clear();
map.renderSync();
checkSnapping(nodes, endNodeCoordinates, currentFeture);
if(snap){
var featureCoordinates = featureGeom.getCoordinates();
featureCoordinates[featureCoordinates.length-1]= snapToNode;
featureGeom.setCoordinates(featureCoordinates);
currentFeture.setGeometry(featureGeom);
currentFeture.changed();
snap=false;
}
var isPartOf = addSegment(featureID-1);
currentFeture.getProperties().partOf[isPartOf[0]]=isPartOf[1];
drawing = false;
drawing_feature = null;
}
if (!sorting){
var newLines = checkIntersection(currentFeture);
}
map.addInteraction(lineStringdraw);
addFeatureEventListener = vector2.getSource().on('addfeature', addFeatureFunction)
}
将特征添加到图层(addFeatureEventListener)时,我不得不删除绘制交互。但这删除了该功能。有没有办法可以取消选择该功能。
提示:要突出显示一个节点或一行,我有一个selectFeatures,一个ol.interaction.Select()的对象,我将所需的特征添加到地图中并进行渲染。