mapbox / mapbox/mapbox-gl-draw

Feature request: customizable source id

Open
#912 6 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The scenario is: I need to create multiple draw instances and tailor them for different purposes, say one for measuring distance/area, one for creating poi geojson.

Yet since all mapbox-gl-draw instances are using the same source id, it throws the following error when adding multiple draw instance to the map:
``There is already a source with this ID``.

My current approach is setting a type property for each feature generated by different draw instance during event ```'draw.create'``` to distinguish them..

I think this can be better implemented by passing a source id parameter to create separated source and layer for each draw instance.

Thank you.

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

No file or test is named in the issue. Start by locating where each draw instance creates its shared source and layers, then trace how a configurable source ID could be applied. Done means multiple draw instances can be added without the duplicate-source error while retaining separate sources and layers.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.