mapbox / mapbox/mapbox-gl-js

Style spec: Pull more than one data source into a layer

Open
#4,362 7 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cross-platform :tv:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Style layers can currently only specify a single data layer. With data driven styling, we're looking at rendering the same data with fewer style layers. I propose adding support for pulling multiple data sources into one style layer. In a data source, the split between putting features into separate data layers vs. putting them in the same data layer and using tags to filter/separate them is somewhat arbitrary. Adding support for multiple data layers also means that they could stem from different sources, e.g. a regular tileset and a GeoJSON file, or runtime annotations.

In terms of style spec change, we could make the `source` field an array that allows specifying multiple data source/layer combinations:

```json
{
"id": "landcover",
"type": "fill",
"source": [
["streets", "landcover"],
["geojson", "glaciers"]
],
...
}
```

Alternatively, we could use a different attribute like `data` and move `source`, `source-layer`, and `filter` to that:

```json
{
"id": "landcover",
"type": "fill",
"data": [
{
"source": "composite",
"source-layer": "landcover",
"filter": [
"all",
["in", "class", "crop", "grass", "scrub", "wood", "snow"]
]
},
{
"source": "glaciers.geojson"
}
],
...
}
```

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 by reviewing the style-layer `source`, `source-layer`, and `filter` fields and the two proposed JSON shapes in the issue. Resolve which representation and compatibility behavior should be adopted; done means the style specification supports multiple data sources in one layer with the chosen format clearly defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.