mapbox / mapbox/simplespec-to-gl-style

Migrate to data-driven styling

Open
#27 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
34
Forks
3
PR merge metrics
No merged PRs in 30d

Description

This library currently creates a separate layer for each individual geometry or feature in the GeoJSON input in order to style it distinctly. Instead, it should create one each of symbol, line, and fill layers and set each layout or paint property to a property function that looks at the relevant property on each feature. Reducing the number of layers could improve performance and would also give us more flexibility with respect to z-ordering.

The following layout and paint properties would need to support data-driven styling:

* [x] `icon-image`: mapbox/mapbox-gl-native#8592
* [x] `line-color`
* [x] `line-opacity`
* [x] `line-width`: mapbox/mapbox-gl-js#3045
* [x] `fill-color`
* [x] `fill-opacity`

DDS support for `icon-allow-overlap`, `icon-size`, `line-cap`, and `line-join` is unnecessary (although it’s already supported for `icon-size`) because we apply these properties to every symbol or line layer unconditionally.

Incidentally, mapbox/mapbox-gl-js#4087 would make it possible to remove the workaround that clones a path in order to give it both a fill and a stroke with customizable width (`stroke-width`).

/cc @bsudekum @jfirebaugh

Contributor guide

Open the contributing guide

Research direction

Start by locating the code that creates separate layers from GeoJSON features and the handling for the listed layout and paint properties. Check how symbol, line, and fill styles are currently generated, then verify that the supported properties are applied per feature while producing one layer of each type.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 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.