How to highlight a feature while being processed in ol3

المشرف العام

Administrator
طاقم الإدارة
I have written the following code where I check the newly added line to a vector layer for the possible intersection with other lines in that layer.

//vector2 layer is defined and added to the mapvar select = new ol.interaction.Select();var selectedFeatures = select.getFeatures();var temIntersectionPointsSource = new ol.source.Vector();var temIntersectionPointsLayer = new ol.layer.Vector({source:..., //with a defined style});function checkIntersection(currentFeature){ var featurelist = vector2.getSource().getFeatures(); var geoJSON = new ol.format.GeoJSON(); geoJSONText = geoJSON.writeFeature(currentFeature); var currentFeatureCoords= currentFeature.getGeometry().getCoordinates(); var turfCurrentFeature = turf.linestring(currentFeatureCoords); var tempFeatures = []; for (i=0; (featurelist.length)>i;i++){if (featurelist!== currentFeature){tempFeatures.push(featurelist);}} var features1=[currentFeature]; for (i=0; (tempFeatures.length)>i;i++){ var feature = tempFeatures; var features2=[feature]; var featureCoords= feature.getGeometry().getCoordinates(); var turfFeature = turf.linestring(featureCoords); var intersectionStatus = turf.intersect(turfCurrentFeature,turfFeature); var intersect=false; if (!!intersectionStatus){ //in case two lines intersect more than once the intersection //result will be a multi-point feature which we need to //explode it to single points var intersectionPointFeature = geoJSON.readFeature(intersectionStatus); var intersectionCoordinates = intersectionPointFeature.getGeometry().getCoordinates(); var intersectionPoints = []; for (m=0;m
 
أعلى