mapbox / mapbox/mapbox-gl-js

Don't throw and crash renderer if `pitch` or `distance-from-center` is used on non-symbol types

Open
#11,439 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

A layer like this will cause the renderer to fail

```js
{
id: 'foo',
type: 'circle',
source: 'composite',
'source-layer': 'poi_label',
filter: [
'all',
['==', ['geometry-type'], 'Symbol'],
['>', ['pitch'], 30] // The culprit
]
}
```

It's technically incorrect ([they are only valid for symbol layers](https://github.com/mapbox/mapbox-gl-js/blob/f6eb04c5019c305548546314809acfb93f7f9ad2/src/style-spec/reference/v8.json#L3237-L3254)) but the result is pretty grim and results in a blank map.

Screen Shot 2022-01-25 at 4 25 58 PM

Could this instead `console.warn` that these expression properties are only supported for symbols and not prevent the map rendering?

---

- **Demo**: https://jsfiddle.net/tristen/p2arnvfh/
- **Version**: `v2.6.1`

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 the linked JSFiddle demo and inspect the expression-property validity described in src/style-spec/reference/v8.json, focusing on the renderer path that handles pitch or distance-from-center for non-symbol layers. Done means the invalid expression produces a console warning rather than crashing, and the map continues rendering.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, 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.