Search code examples
leafletgeojson

Rendering overlapping polygons without holes in multipolygon in Leaflet


Is there a way to render overlapping polygons without holes in multipolygon in Leaflet?

I found Leaflet has an open issue.

codesandbox.io

I am asking because I have a bound polygon that contains inner polygons.

enter image description here

I would need to drag them all together, but it doesn't work in canvas mode. It could work if I can render this as a multipolygon. This is a follow-up question on my previous question.


Solution

  • I'll just copy-paste my response to Leaflet bug #6173 :


    I'm reading the OGC's Simple Feature Access specification (again), to remind myself about the formal definitions of Polygons and MultiPolygons. Let me quote page 31:

    6.1.14 MultiPolygon
    A MultiPolygon is a MultiSurface whose elements are Polygons.
    The assertions for MultiPolygons are as follows.
    a) The interiors of 2 Polygons that are elements of a MultiPolygon may not intersect.
    

    Heck, it even comes with pretty pictures: enter image description here So, MultiPolygons which have overlapping members are not valid MultiPolygons. As such, I think Leaflet has no obligation to handle that invalid case.

    See also #3763 (comment) (re: fillRule option for SVG renderer).