OpenLayers layer. When the layer has a source configured,
it will be modified to use the configuration from the glStyle's source
. Options specified on the
layer's source will override those from the glStyle's source
, except for url
and
tileUrlFunction
. When the source projection is the default (EPSG:3857
), the tileGrid
will
also be overridden. If you'd rather not have ol-mapbox-style modify the source, configure applyStyle()
with the updateSource: false
option.
Mapbox/MapLibre Style object.
Optional
sourceOrLayersOrOptions: string | string[] | Options & ApplyStyleOptions = ''Options or
source
key or an array of layer id
s from the Mapbox/MapLibre Style object. When a source
key is
provided, all layers for the specified source will be included in the style function. When layer
id
s are provided, they must be from layers that use the same source. When not provided or a falsey
value, all layers using the first source specified in the glStyle will be rendered.
Optional
optionsOrPath: string | Options & ApplyStyleOptions = {}Deprecated. Options. Alternatively the path of the style file
(only required when a relative path is used for the "sprite"
property of the style).
Optional
resolutions: number[] = undefinedDeprecated. Resolutions for mapping resolution to zoom level. Only needed when working with non-standard tile grids or projections, can also be supplied with options.
Promise which will be resolved when the style can be used for rendering.
Applies a style function to an
ol/layer/VectorTile
orol/layer/Vector
with anol/source/VectorTile
or anol/source/Vector
. If the layer does not have a source yet, it will be created and populated from the information in theglStyle
(unlessupdateSource
is set tofalse
).Example:
The style function will render all layers from the
glStyle
object that use the source of the first layer, the specifiedsource
, or a subset of layers from the same source. The source needs to be a"type": "vector"
or"type": "geojson"
source.Two additional properties will be set on the provided layer:
mapbox-source
: Theid
of the Mapbox/MapLibre Style document's source that the OpenLayers layer was created from. Usuallyapply()
creates one OpenLayers layer per Mapbox/MapLibre Style source, unless the layer stack has layers from different sources in between.mapbox-layers
: Theid
s of the Mapbox/MapLibre Style document's layers that are included in the OpenLayers layer.