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]);
        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());

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?

  • The error happens in a function you did not include. What is summarizePointsByLine and what is in line 440 of that HTML file? Mar 20, 2021 at 16:35
  • There is not enough of code to find out what and why it goes wrong. Please edit your question and add more of relevant code.
    – TomazicM
    Mar 20, 2021 at 18:10
  • summarizepointsByLine function actually tells the details of the points that are intersected by a drawn line through leaflet draw plugin Mar 21, 2021 at 3:17
  • is there any problem with my leaflet draw plugin coz as soon as i draw the line over the polygon the above error is displayed over the screen Mar 21, 2021 at 3:19
  • line is the object passed to the function where line is the drawn line over the polygons with leaflet draw plugin Mar 21, 2021 at 3:20


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.