deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

[Bug] MVTLayer with `binary: false` moves feature ID into `feature.properties.id`

Open mz8i opened this issue 8 months ago • 1 comments

Description

For an MVTLayer with binary: false, when accessing feature data e.g. in an onClick handler, each feature's id is moved by deck.gl into feature.properties rather than being present as feature.id.

This issue appeared when updating deck.gl from 8.9.28 to 9.1.4.

Flavors

  • [ ] Script tag
  • [x] React
  • [ ] Python/Jupyter notebook
  • [ ] MapboxOverlay
  • [ ] GoogleMapsOverlay
  • [ ] CARTO
  • [ ] ArcGIS

Expected Behavior

When accessing in interaction handlers, accessor functions etc. - MVT features that do have an ID in the original dataset (as contrasted with an id property) should have a feature.id present, rather than a feature.properties.id.

Steps to Reproduce

See https://codesandbox.io/p/devbox/deck-gl-react-map-gl-maplibre-gl-playground-world-capitals-forked-4kls9v

The sandbox shows a sample point dataset. The original MVT features all have IDs.

The MVTLayer has autoHighlight enabled, as well as layer styling that is dependent on the selected feature ID. The UI shows the stringified last clicked feature. There's also toggles for binary and uniqueIdProperty props.

  1. With binary: true:
    • auto-highlight works
    • selection-based styling doesn't work (this is expected because the accessors don't have access to the binary feature data)
    • the clicked features do have an id
  2. After switching to binary: false
    • auto-highlight stops working
    • upon clicking a feature, it can be seen that the id for the feature has now ended up in feature.properties, which is unexpected
    • the selection-based styling still doesn't work because the features now don't have a feature.id
  3. Only after setting uniqueIdProperty: 'id' prop as a workaround:
    • auto highlight works again
    • selection-based styling works

Environment

  • Framework version: 9.1.4
  • Browser:
  • OS:

Logs

No response

mz8i avatar Mar 09 '25 01:03 mz8i

The change in behavior is actually due to a change in loaders.gl MVT loader - filed an issue here: https://github.com/visgl/loaders.gl/issues/3197

mz8i avatar Mar 16 '25 14:03 mz8i