Custom map styles
- Last UpdatedNov 26, 2024
- 2 minute read
The styles
element provides an easy way to extend the embedded style and reuse it across different layers. The custom style can have style properties pre-set and individual layers can use overrides. The following example demonstrates how to extend the lines
embedded style and create a dashed-line
custom style. In the styles
section, it defines the name of the custom style (dashed-lines
), the name of the default style from which it inherits (the base
section), and the draw
section that describes how geometries with the given style render (and in which properties of the base style you can use them).
For example, see the following style configuration snippet:
The style configuration from the preceding example renders features as shown in the following example:
The following list provides a description of the properties and values that form the configuration style
section.
Style name - A unique string that identifies the custom style. The string is a key in the
styles
section and the value is the style definition. In the following example, there are two custom styles with the namesred_line
andgreen_polygon
.base
-string
(optional) - Defines the name of the style from which the custom style inherits. The possible values can be the names of embedded styles (points
,lines
and so on), or other custom styles. In the following snippet, thered_line
style inherits the width from thethick_line
custom style.draw
(optional) - A block level element that contains the drawing parameters of the given style. The applicable parameters depend on the style that you use as thebase
ormix
. For more information, see Default map styles.mix
(optional) -[...string]
- Creates a mix of several custom styles. In the following example, the new custom style is using the properties from thethick_line
andred_line
styles.
Next steps
For more information on vector map styling, see Practical examples and applications.