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.
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.
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.
TBD
TBD
TBD
TBD
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.
Most helpful comment
source-layeris required for layers that use sources of typevector, 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.