mapbox / mapbox-gl-draw

Draw tools for mapbox-gl-js
https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/
ISC License
952 stars 593 forks source link

feature id mismatch vs. mapbox-gl #787

Open hyperknot opened 6 years ago

hyperknot commented 6 years ago

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.

hyperknot commented 6 years ago

https://github.com/mapbox/mapbox-gl-js/issues/6651 https://github.com/mapbox/mapbox-gl-js/issues/2716

mcwhittemore commented 6 years ago

It should be noted that GeoJSON suggestions both numbers and strings for its feature ids. While Draw can move to using random numbers for its auto created ids, we need to support string ids as well. I guess we could create a string to number lib to help with that.

hyperknot commented 6 years ago

I believe https://github.com/mapbox/mapbox-gl-js/issues/2716 is about solving strings.