Mapbox-gl-js: Why is `source-layer` required?

Created on 6 Dec 2017  路  1Comment  路  Source: mapbox/mapbox-gl-js

Exploratory question / feature request:

Why is source-layer required? And, would a PR be accepted that made it optional? By default, we could render all available source layers.

Motivation

The source-layer option when adding vector layers is relatively opaque, in that it's difficult to recognize associated errors, or to know how to fix them. It is a source of silent errors.

Design Alternatives

Why couldn't source-layer be an optional parameter, in which case we could render all source layers by default? Isn't the vector data already "here" at this point anyway? So we might as well make use of the available data? The developer could always add the source-layer parameter later if needed.

Design

TBD

Mock-Up

TBD

Concepts

TBD

Implementation

TBD

Most helpful comment

source-layer is required for layers that use sources of type vector, because it's expected that vector tiles are divided into layers in a way that makes it rare to need to render data from multiple source layers with the same style layer. For instance, vector tile layers typically partition by geometry type, placing point place labels in one layer, road lines in another, and building outlines in a third. You would almost never want to render more than one of those with the same style layer.

We have discussed supporting the less common case where you do want to pull data from multiple source layers into the same style layer. #4362 tracks that request.

Finally, it's worth mentioning that layers that use a geojson source don't require source-layer, as GeoJSON does not have layers.

>All comments

source-layer is required for layers that use sources of type vector, because it's expected that vector tiles are divided into layers in a way that makes it rare to need to render data from multiple source layers with the same style layer. For instance, vector tile layers typically partition by geometry type, placing point place labels in one layer, road lines in another, and building outlines in a third. You would almost never want to render more than one of those with the same style layer.

We have discussed supporting the less common case where you do want to pull data from multiple source layers into the same style layer. #4362 tracks that request.

Finally, it's worth mentioning that layers that use a geojson source don't require source-layer, as GeoJSON does not have layers.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iamdenny picture iamdenny  路  3Comments

stevage picture stevage  路  3Comments

yoursweater picture yoursweater  路  3Comments

muesliq picture muesliq  路  3Comments

aaronlidman picture aaronlidman  路  3Comments