I have given this code for intersection:
function intersectPolyByPolyFC(poly,fcPoly){
var fgp=[];//variable for feature group
var bbPoly=turf.bboxPolygon(turf.bbox(poly));//polygon representation of the bounding box of a reference polygon
for(var i=0;i<fcPoly.features.length;i++){//loop through the feature collection of polygons
var bb=turf.bboxPolygon(turf.bbox(fcPoly.features[i]));//variable bb represents each polygon for feature collection
if(turf.intersect(bbPoly,bb)){//condition to check if the two bounding boxes intersect
var int= turf.intersect(poly,fcPoly.features[i]);
if(int){
int.properties=fcPoly.features[i].properties;
fgp.push(int);
}
}
}
return turf.featureCollection(fgp);
}
and the function definition I have given as
var bufline=turf.buffer(line,0.05,{units:"kilometers"});
var intBUOWL= intersectPolyByPolyFC(bufline, lyrBUOWL.toGeoJSON());
L.geoJSON(intBUOWL,{style:{color:'red',weight:5}}).addTo(mymap);
When I am drawing a line over a polygon for intersection I am getting this error
Uncaught TypeError: Cannot read property 'map' of undefined
at Object.t.collect (turf.min.js:1)
at summarizePointsByLine (buffer.html:440)
at NewClass.<anonymous> (buffer.html:155)
at NewClass.fire (Events.js:190)
at NewClass._fireCreatedEvent (leaflet.draw.js:8)
at NewClass._fireCreatedEvent (leaflet.draw.js:8)
at NewClass.completeShape (leaflet.draw.js:8)
at HTMLAnchorElement.handler (DomEvent.js:92)
How can I resolve this error?
summarizePointsByLine
and what is in line 440 of that HTML file?