mapbox / mapbox/mapbox-gl-draw

feature id mismatch vs. mapbox-gl

Open
#787 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

mapbox-gl-js version: 0.45.0
mapbox-gl-draw version: 1.0.9

  1. mapbox-gl only supports uints for feature ids. If a feature id is not an integer it'll be silently removed from queryRenderedFeatures's results.

  2. mapbox-gl-draw is using strings for feature ids, via the hat() library/function.

This means that features where the ids were generated via draw will have missing ids in mapbox-gl / queryRenderedFeatures.

I believe probably hat() should be changed to some kind of random integer instead.

The other issue is that there are actually two locations for ids in draw.

  1. root level as feature.id
  2. inside properties, as feature.properties.id

It's all internal functions where id is used, but maybe draw should only use a root level, integer id.

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 mismatch with mapbox-gl 0.45.0 and mapbox-gl-draw 1.0.9, focusing on queryRenderedFeatures and the hat() ID generation. Inspect how IDs are used at feature.id and feature.properties.id, then establish a consistent ID representation whose generated features retain IDs in mapbox-gl results.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.