mapbox / mapbox/mapbox-gl-js

get expression - unclear syntax

Open
#6,481 0 comments 0 reactions 1 assignee View on GitHub

@swoloszynski is already working on this.

Since Jul 9, 2021.

docs :scroll: style-spec
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

mapbox-gl-js version: 0.44.2

Steps to Trigger Behavior

Get expression syntax is not defined well in the documentation: it is not clear when it is necessary to use type expressions (for ex. issue 6479 ).
For now, my code looks like this (and it doesn't work without type expressions):
['get', 'line-opacity', ['object', ['get', ['string', ['get', FeatureProperties.LineType]], ['literal', this.lineStyles]]]]
And it is not clear when I have to use ['object',{...}], ['literal', {...}] or ['string',{...}]. And at the same time, in case expression I can write something like this:
'line-color': [ 'case', ['has', 'line-color'], ['get', 'line-color']]
without this type-casting magic. I would expect expressions to work in the same manner and a better description in the official documentation.

Expected Behavior

The same behavior for all expressions, proper description in the docs

Actual Behavior

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.