mapbox / mapbox/mapbox-gl-js

decision expression "in" not working for value 0?

Open
#9,997 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

I use the "in" expression when filtering features in a layer.
each feature has a "level" field, and I check in map.setFilter() whether the level is included in the current "selectedLevels" array. however, it never found the level with the number 0, thus never returned true.
I solved the problem, by starting my levels from 1 - but I thought this might be worth pointing out.

mapbox-gl-js version:
v1.8.1

Steps to Trigger Behavior
       var selectedLevels = [0,1,2]

                    [
                        'in',
                        0,
                        ['get', ['literal', 'selectedLevels']]
                    ],
Expected Behavior

return true

Actual Behavior

return false

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

The issue names map.setFilter() and the "in" expression but no source file or test. Start by reproducing the example on mapbox-gl-js v1.8.1, then trace the expression evaluation path; done means the filter returns true when the selectedLevels array contains 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.