mapbox / mapbox/mapbox-gl-draw

How to add draw on drawed feature?

Open
#1,197 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
1.1k
Forks
612
Avg merge
8d 9h
Merged PRs (30d)
5

Description

Hello mapbox-gl-draw team. How can I add a layer to draw object? I've tried this:
```
let ftr = {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: layer.coordinates[0],
},
properties: []
};
let featureIds = this.draw.add(ftr as Feature);
```
but it throws an error: `ERROR TypeError: Cannot read properties of undefined (reading 'get')`. What's the problem?

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 this.draw.add(ftr as Feature) call in mapbox-gl-draw with the shown Polygon feature and inspect the undefined get error. The issue does not name a source file or test; done means identifying the cause and documenting or correcting the supported way to add a layer or feature.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.