Skip to content

Leaflet-pip is not working with Leaflet-draw plugin #27

@fab-girard

Description

@fab-girard

Hello,
I've tried to update my app with leaflet 1.0.x and I'm facing up to an incompatibility between 2 plugins:

Since this commit in leaflet-pip, function is_poly is not anymore able to take into account polygons just created with leaflet-draw. I thought leaflet-draw created an incorrect polygon in this issue but I suspect now leaflet-pip is maybe not enough permissive.
I would suggest a PR which updates the is_poly function from your plugin:

function isPoly(l) {
    if (l instanceof L.Polygon) return true;
    return l.feature && l.feature.geometry && l.feature.geometry.type &&
        ['Polygon', 'MultiPolygon'].indexOf(l.feature.geometry.type) !== -1;
}

Indeed layer created by leaflet-draw has no l.feature && l.feature.geometry && l.feature.geometry.type attribute...

And maybe rollback entirely ff2b2f4 for is_poly:

function isPoly(l) {
    return L.MultiPolygon && l instanceof L.MultiPolygon ||
        l instanceof L.Polygon ||
        l.feature && l.feature.geometry && l.feature.geometry.type &&
        ['Polygon', 'MultiPolygon'].indexOf(l.feature.geometry.type) !== -1;
}

What do you thinking about it ?

Fabien

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions