mapbox / mapbox/mapbox-gl-draw

Update example styles to use Mapbox Expressions rather than older Mapbox Filters

Open
#1,041 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**mapbox-gl-js version**: v2.0.0
**mapbox-gl-draw version**: v1.2.0

### Steps to Trigger Behavior

1. Using any of your examples styles from [Examples.md](https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/EXAMPLES.md) that include references to properties by name rather than using the "get" expression, or those that use "$type", "!has", etc (full list of old Filters [here](https://docs.mapbox.com/mapbox-gl-js/style-spec/other/), scroll to Filters section) with a mixture of the new Expression Syntax.

### Expected Behavior

I would expect examples found in [Examples.md](https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/EXAMPLES.md) to work with up to date Mapbox best practices which is to use the Expression syntax rather than the older Filter syntax.

In the very least it would be helpful to user of the library to call out the fact that the older Style Filter syntax is being show/used in the library material and not the updated Expression language.

### Actual Behavior

The becomes very confusing when you are trying to make sense of special operators like $type which have little documentation. Error given by the Mapbox and Draw do little to clue you into the fact that the Mapbox style interpreter are failing to use Expression syntax alongside the older Filter syntax.

Old Filter Syntax
['all',
['==', 'user_prop', 'myVal'],
['==', '$type', 'Point'],
]

Example Bad Filter using mix of Expression/Filter syntax, non obvious issue
['all',
['==', ['get', 'user_prop'], 'myVal'],
['==', '$type', 'Point'],
]

Corrected Expression Syntax
['all',
['==', ['get, , 'user_prop'], 'myVal'],
['==', ['geometry-type'], 'Point'],
]

Errors Given on failure
"layers.polygon-fill-inactive.hot.filter[3][1]: string expected, array found" -- this gets buried quickly do to the next error throwing repeatedly.

"The layer 'polygon-fill-inactive-noncommissioned.cold' does not exist in the map's style and cannot be queried for features."

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 with docs/EXAMPLES.md and review each example style that uses older Mapbox Filter syntax, including property names, $type, and !has. Compare those examples with the linked Mapbox Filter and Expression documentation. Done means the examples consistently use the current Expression syntax, or clearly identify any remaining legacy syntax for users.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
Half a day
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.