Atlaslog
Atlaslog / OpenLayers / API / Style
OpenLayers · API reference

Style

Quick answer

A style container that combines fill, stroke, image (symbol) and text into the appearance of a feature. Pass a Style or a style function to a vector layer to control how each feature is drawn.

Last verified 2026-11-03 · OpenLayers 10.3.1 · Cite this page
Runnable examplesChinese noteAll API topics

new Style(options)

style/Style.js, line 162
Name Type Description
geometry string | Geometry | GeometryFunction | undefined

Feature property or geometry or function returning a geometry to render for this style.

fill Fill | undefined

Fill style.

image ImageStyle | undefined

Image style.

renderer RenderFunction | undefined

Custom renderer. When configured, fill, stroke and image will be ignored, and the provided function will be called with each render frame for each geometry.

hitDetectionRenderer RenderFunction | undefined

Custom renderer for hit detection. If provided will be used in hit detection rendering.

stroke Stroke | undefined

Stroke style.

text Text | undefined

Text style.

zIndex number | undefined

Z index.

Methods

clone(){Style}

style/Style.js, line 236

Clones the style.

Returns:
The cloned style.

getFill(){Fill | null}

style/Style.js, line 320

Get the fill style.

Returns:
Fill style.

getGeometry(){string | Geometry | GeometryFunction | null}

style/Style.js, line 301

Get the geometry to be rendered.

Returns:
Feature property or geometry or function that returns the geometry that will be rendered with this style.

getGeometryFunction(){GeometryFunction}

style/Style.js, line 311

Get the function used to generate a geometry for rendering.

Returns:
Function that is called with a feature and returns the geometry to render instead of the feature's geometry.

getHitDetectionRenderer(){RenderFunction | null}

style/Style.js, line 290

Get the custom renderer function that was configured with #setHitDetectionRenderer or the hitDetectionRenderer constructor option.

Returns:
Custom renderer function.

getImage(){ImageStyle | null}

style/Style.js, line 338

Get the image style.

Returns:
Image style.

getRenderer(){RenderFunction | null}

style/Style.js, line 260

Get the custom renderer function that was configured with #setRenderer or the renderer constructor option.

Returns:
Custom renderer function.

getStroke(){Stroke | null}

style/Style.js, line 356

Get the stroke style.

Returns:
Stroke style.

getText(){Text | null}

style/Style.js, line 374

Get the text style.

Returns:
Text style.

getZIndex(){number | undefined}

style/Style.js, line 392

Get the z-index for the style.

Returns:
ZIndex.

setFill(fill)

style/Style.js, line 329

Set the fill style.

Name Type Description
fill Fill | null

Fill style.

setGeometry(geometry)

style/Style.js, line 404

Set a geometry that is rendered instead of the feature's geometry.

Name Type Description
geometry string | Geometry | GeometryFunction | null

Feature property or geometry or function returning a geometry to render for this style.

setHitDetectionRenderer(renderer)

style/Style.js, line 280

Sets a custom renderer function for this style used in hit detection.

Name Type Description
renderer RenderFunction | null

Custom renderer function.

setImage(image)

style/Style.js, line 347

Set the image style.

Name Type Description
image ImageStyle

Image style.

setRenderer(renderer)

style/Style.js, line 270

Sets a custom renderer function for this style. When set, fill, stroke and image options of the style will be ignored.

Name Type Description
renderer RenderFunction | null

Custom renderer function.

setStroke(stroke)

style/Style.js, line 365

Set the stroke style.

Name Type Description
stroke Stroke | null

Stroke style.

setText(text)

style/Style.js, line 383

Set the text style.

Name Type Description
text Text | null

Text style.

setZIndex(zIndex)

style/Style.js, line 429

Set the z-index.

Name Type Description
zIndex number | undefined

ZIndex.

TutorialsAPI index
English reference text adapted from the official OpenLayers documentation, © OpenLayers contributors, licensed under BSD-2-Clause.
Original page: https://openlayers.org/en/latest/apidoc/module-ol_style_Style-Style.html · Chinese note: /openlayers/api/style.html
Cite this page

Atlaslog (2026). Style. https://www.jingweizhi.com/en/openlayers/api/style.html (accessed 2026-11-03).