mapbox / mapbox/mapbox-gl-draw
Polygon draw mode last vertex click catch before draw.create is fired
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 612
- Avg merge
- 8d 9h
- Merged PRs (30d)
- 5
Description
Thank you for support and good project.
Just trying to prevent polygon creation in case if his area is bigger than n square meters.
Events used:
1. draw.render, there I am able to calculate polygon area.
2. map.on(click) listener I can with this layer id "gl-draw-polygon-and-line-vertex-halo-active.hot".
So i now when vertex is clicked(suppose to close polygon);
---------Actual behavior -------
After click on last vertex with event.StopPropagation() and event.PreventDefault() polygon is being created and added to map, 'draw.create' being fired with feature data.
---------Expected behavior--------
Prevent polygon creation, and addition to map on last vertex click, if some condition returns false
Thank you for your support.
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 by reproducing the last-vertex interaction using the mentioned draw.render, map click, and draw.create events, including the gl-draw-polygon-and-line-vertex-halo-active.hot layer. Trace when polygon finalization occurs relative to event.StopPropagation() and event.PreventDefault(). Done means a failed area condition prevents polygon creation, map addition, and draw.create from firing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100