mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

map.queryRenderedFeatures(...) fails to return geojson MutliPolygon features where a MutliPolygon overlaps

Open lemmingapex opened this issue 5 years ago • 4 comments

mapbox-gl-js version: 1.11.1, 1.12.0

browser: google chrome, firefox, safari, etc.

Summary

map.queryRenderedFeatures(...) fails to return geojson MutliPolygon features where a MutliPolygon overlaps.

The following geojson contains a mutlipolygon that contains overlap:

{
  "id": 1,
  "type": "Feature",
  "geometry": {
    "type": "MultiPolygon",
    "coordinates": [
    [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
      [[[100.5, 0.5], [101.5, 0.5], [101.5, 1.5], [100.5, 1.5], [100.5, 0.5]]],
      
    ]
  }
}

Screen Shot 2020-09-02 at 12 11 10 PM

map.queryRenderedFeatures(...) will not return any features where the first polygon in the multipolygon overlaps the second polygon in the multipolygon.

Link to Demonstration

If you have a mapboxgl accessToken, see the demo here: https://jsfiddle.net/5on0krp8/

Expected Behavior

map.queryRenderedFeatures(...) should return MutliPolygon features where a MutliPolygon overlaps.

Actual Behavior

map.queryRenderedFeatures(...) fails to return MutliPolygon features where a MutliPolygon overlaps.

lemmingapex avatar Sep 02 '20 18:09 lemmingapex

I have verified that this bug has existed for a long time, since at least version 0.53.1.

lemmingapex avatar Sep 03 '20 17:09 lemmingapex

Was anyone able to confirm and reproduce this bug?

lemmingapex avatar Sep 09 '20 19:09 lemmingapex

A workaround that may work for some people is to use a type of 'GeometryCollection' with many polygons rather than the 'MultiPolygon' type.

lemmingapex avatar Sep 14 '20 21:09 lemmingapex

I'm currently experiencing this bug. It seems to alternate when it returns features.

I've got 5 overlapping polygons in a MultiPolygon. The 1st polygon returns features, then the 2nd does not, the 3rd does, the 4th does not, and of course the 5th does.

PraedictixIT avatar Mar 21 '24 15:03 PraedictixIT