Style guide for custom layers
- Last UpdatedApr 28, 2025
- 3 minute read
Customize the visual appearance of a custom raster, line, polygon or point layer through the use of custom styles, which can be controlled through a series of APIs along with a JSON-based Style
description.
Note
This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
A Style
is an abstraction of a custom layer style:
- Use the
JsonStyleFactory
to create aStyle
from JSON strings. - Use the
MapLayerBuilder.withStyle(Style)
method to provide a custom style when creating aMapLayer
. - Use the
MapLayer.setStyle(Style)
method to update a custom layer style at runtime.
The JSON style syntax is described in greater detail below.
With the HERE SDK, follow the below steps to customize the visual appearance of a custom layer:
- Create a JSON style string for your custom layers using an appropriate technique.
using the
raster
technique as described in the style techniques reference for a custom raster layer.
using the
line
technique as described in the style techniques reference for a custom line layer.
- Create the custom layer using the newly created
Style
- Or assign the newly created
Style
to an existing custom layer.
Style
Style defines the visual appearance of rendered objects. It does so by providing information about the rendering technique and the technique parameters for every object. Style is defined in a JSON file with a schema described in the following sections.
Style rule
The top-level key styles
contains the style description. The value of styles
is an array of style rules.
Conceptually, each style rule represents a separate draw invocation - two style rules within a layer mean that the layer features are drawn twice.
layer
Each style rule is associated with a layer through the layer
key. A single layer can be associated with multiple style rules.
In the following style, layer1
has two style rules:
Note
Style rules inside
styles
can be arranged in any order.
when
Style Rule applies to an object only if when
filter is true for that object. The when
is optional and if not specified it is always true.
In order to distinguish among objects, when
expression uses object data attributes. A data attribute is a name-value pair attached to an object. Objects can have an arbitrary number of data attributes. The Style system itself does not have any inherent expectations about the presence of certain data attributes. Writing a style for particular data source however heavily depends on data scheme.
Example below contains when
in Style Rule:
The when
value is a boolean expression comparing object data attribute named kind
against a string constant a special kind
.
technique
Every style rule must specify a technique
. The technique
defines how the object's geometry is transformed into a renderable object and how it is rendered - which shader is used and what uniforms are set.
In addition to technique
name, the rule can also provide a set of technique attribute values under the attr
key.
The example above has a technique
set to raster
and a single technique attribute opacity
set to 0.5.
See style techniques reference for a complete list of available techniques and their attributes.
Expressions
Expressions define value of when
filter and technique attribute values
.
Expression is represented in JSON as an array
whereas first argument is an expression name
, and the rest of the entries are expression arguments. Arguments are in most cases also expressions.
Example: 1+2
is written as ["+", 1, 2]
See Expression Reference.
Definitions
Expressions which are used often can be defined once in definitions
and then referenced in any expression, by using ["ref", name]
expression.