Class: SpatialStyle

H.map.SpatialStyle

new H.map.SpatialStyle (opt_options)

This class represents a style with which spatial objects such as polylines and polygons are drawn. A SpatialStyle instance is always treated as immutable to avoid inconsistencies and must not modified.

Name Type Description
opt_options H.map.SpatialStyle | H.map.SpatialStyle.Options optional

An object specifying style attributes

Members

H.map.SpatialStyle.DashImage HTMLImageElement static

Object containing a list of images which can be used for lineDashImage.

Properties:
Name Description
ARROW

Arrow image with aspect ratio of 1x1

CIRCLE

Circle image with aspect ratio of 1x1

H.map.SpatialStyle.DashScaleMode static

Object containing a list of values which can be used for lineDashScaleMode.

Properties:
Name Description
CONTINUOUS

Scales dashes continuously with zoom.

DISCRETE

Scales dashes in fixed steps at specific zoom levels.

H.map.SpatialStyle.DEFAULT_STYLE H.map.SpatialStyle staticconstantnon-null

This static member defines the default style for spatial objects on the map. Its value is:

Example
{
  strokeColor: '#05A',
  fillColor: 'rgba(0, 85, 170, 0.4)',
  lineWidth: 2,
  lineCap: 'round',
  lineDash: [ ],
  lineDashImage: undefined
}

H.map.SpatialStyle.MAX_LINE_WIDTH number staticconstant

This constant represents the maximum line width which can be used for rendering.

fillColor string

The filling color in CSS syntax, the default is "rgba(0, 85, 170, 0.4)".

lineCap H.map.SpatialStyle.LineCap non-null

The style of the end caps for a line, the default is "round".

lineDash Array.<number> non-null

The line dash pattern as a list of alternating dash and gap lengths. At most the first 4 elements are used ([dash, gap, dash, gap]). Elements beyond these are ignored. The default is [ ].

lineDashImage HTMLCanvasElement | HTMLImageElement | H.map.SpatialStyle.DashImage | undefined

The image that is placed as dash. It is used only if the lineDash is specified. If not specified then no image is used.

lineDashScaleMode H.map.SpatialStyle.DashScaleMode | undefined

The scaling mode of a dashed line to determine how the dashes and gaps scale when zooming the map. The default is H.map.SpatialStyle.DashScaleMode.CONTINUOUS. It is used only if the lineDash is specified.

lineWidth number

The width of the line in pixels, the default is 2.

strokeColor string

The color of the stroke in CSS syntax, the default is "rgba(0, 85, 170, 0.6)".

Methods

equals (other)boolean

This method checks if the given style object is the same as the style object supplied by the caller. Two style objects are equal if the values of their properties are equal.

Name Type Description
other H.map.SpatialStyle | H.map.SpatialStyle.Options

The style object against which to compare the given style object

Returns:
Type Description
boolean true if the styles are value-equal, otherwise false

getCopy (opt_attributes)H.map.SpatialStyle

This method obtains a copy of the given spatial style object and sets its attributes.

Name Type Description
opt_attributes H.map.SpatialStyle.Options optional

The style attributes to set on the copy of the given style instance

Returns:
Type Description
H.map.SpatialStyle

Type Definitions

H.map.SpatialStyle.LineCap string

The style of the end caps for a line, one of "butt", "round" or "square".

H.map.SpatialStyle.Options Object

Options used to initialize a style. If a property is not set, the default value from H.map.SpatialStyle is taken.

Properties:
Name Type Argument Description
strokeColor string <optional>

The stroke color in CSS syntax.

fillColor string <optional>

The fill color in CSS syntax.

lineWidth number <optional>

The width of the line in pixels, the default is 2. The maximum supported line width is 100.

lineCap H.map.SpatialStyle.LineCap <optional>

The cap type of the tail and head of a solid line or, in case of a dashed line, for the tail and head of each dash.

lineDash Array.<number> <optional>

The line dash pattern as a list of alternating dash and gap lengths. At most the first 4 elements are used ([dash, gap, dash, gap]). Elements beyond these are ignored. If not defined, a solid line is drawn.

lineDashImage HTMLCanvasElement | HTMLImageElement | H.map.SpatialStyle.DashImage <optional>

The image that is placed as dash. It is used only if the lineDash is specified.

lineDashScaleMode H.map.SpatialStyle.DashScaleMode <optional>

The scaling mode of a dashed line to determine how the dashes and gaps scale when zooming the map. The default is H.map.SpatialStyle.DashScaleMode.CONTINUOUS. It is used only if the lineDash is specified. The following values are supported:

  • CONTINUOUS scales dashes smoothly with zoom.
  • DISCRETE scales dashes in fixed steps at specific zoom levels.