mapbox / mapbox/mapbox-gl-draw

Polygon draw mode last vertex click catch before draw.create is fired

Open
#948 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged feature
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.