mapbox / mapbox/mapbox-gl-draw
Not possible to click on overlapping shapes
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 612
- Avg merge
- 8d 9h
- Merged PRs (30d)
- 5
Description
When multiple polygons overlap, clicking on a smaller polygon could select the larger polygon instead. The sortFeatures function was intended to sort polygons by area (smallest first), but area.geometry() is being called with a GeoJSON Feature wrapper instead of the raw geometry object. The area result ends us being always undefined and the sorting logic to fail.
Fix proposal
https://github.com/mapbox/mapbox-gl-draw/pull/1539
Steps to reproduce:
- Draw a large polygon
- Draw o smaller polygon in the middle of the larger polygon
- Select the larger polygon
- Deselect the larger polygon
- Click on the smaller polygon
Expected result
- Smaller polygon is selected
Actual result
- Larger polygon is selected
Video
https://github.com/user-attachments/assets/24541dc7-70eb-409e-9cbd-59c3158351d1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the sortFeatures function and inspect the area calculation described in the issue, especially how GeoJSON Feature wrappers and raw geometry objects are passed. Reproduce the overlapping-polygon steps, then verify that clicking the smaller polygon selects it; PR 1539 contains the proposed fix for comparison.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100