mapbox / mapbox/mapbox-gl-draw

Unable to generate midpoints when creating a polygon (just looking for potential suggestions)

Open
#1,084 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged needs information
Dominant language
JavaScript
Stars
1.1k
Forks
612
Avg merge
8d 9h
Merged PRs (30d)
5

Description

Hello,
just looking to gain a little more insight into a particular issue.
I seem to be unable to generate a line or polygon with mid points.

I've gone so far as to try to force the issue by calling the underlying function that handles midpoint creation manually but still no midpoints.
This is a preliminary post as I really don't have enough information to say if i've found a bug. I was hoping to get some insight into what could potentially be causing this to do a bit more research.

This code snippet below shows how I am attempting to insert the drawable on the map.

`

let featureId = draw.add(polygon);

let temp = draw.get(featureId); //sanity checking the polygon is added

draw.changeMode(draw.modes.DIRECT_SELECT, {
featureId,
});

createSupplementaryPoints(temp, {midpoints: true});
`

**mapbox-gl-js version**: "mapbox-gl": "^2.6.1",
**mapbox-gl-draw version**: "@mapbox/mapbox-gl-draw": "^1.3.0",

### Expected Behavior
Midpoints are created on feature added /w direct select

### Actual Behavior

Midpoints not created.

###Additional Info
Map.Draw geometries are overlaid on top of generated colored geometries. You can see that in the image below.
There can be any number of points, lines, and polygons on a map simultaneously.
I don't use the native provided buttons to draw but have created my own which call the same underlying events. (no custom handlers are used).

![image](https://user-images.githubusercontent.com/8607517/144593658-3bbca910-3d5c-43c9-90e0-52d51ec175cc.png)

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 reported behavior with mapbox-gl-js 2.6.1 and mapbox-gl-draw 1.3.0 using the add, DIRECT_SELECT, and createSupplementaryPoints calls shown. Read the createSupplementaryPoints path and direct-select behavior to determine whether midpoints are expected for this feature, then verify whether the expected midpoint display occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.