Open brookjordan opened 1 month ago
Hi @brookjordan,
The StyleLayer
is not intended to be part of the public API, and starting with v3.5.2, Map#getLayer
returns serialized layers instead of the internal StyleLayer
instance.
So both map.getLayer(LAYER_ID).layout
and map.style._layers[LAYER_ID].layout
are considered internal APIs. Could you please share more context on your use case?
Starting with v3.5.2, you can narrow Map#getLayer
return type, e.g.:
mapbox-gl-js version: 3.5.2
browser: Safari, Chrome, Firefox
Steps to Trigger Behavior
map.getLayer(LAYER_ID).layout.get('icon-size').value.value
Link to Demonstration
Expected Behavior
The value of the layer property is returned.
Actual Behavior
An error stating that get is not a function (it is undefined) is thrown.
Other tech details
I found that the computed value is now available under
map.style._layers[LAYER_ID].layout._values['icon-size'].value.value
, but this is both using what looks like an internal value, and the types are not set up well to use like.get()
was with the@types/
library previously.Also,
map.style._layers[LAYER_ID]
has a type ofStyleLayer
, which is a base type, (rather than beingTypedStyleLayer
which is the combined type), so there’s no way to use type guards to narrow it to the type, (SymbolStyleLayer
), required.