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.DEFAULT_STYLE H.map.SpatialStyle staticconstantnon-null

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

Example
{
  strokeColor: '#05A',
  fillColor: 'rgba(0, 85, 170, 0.4)'
  lineWidth: 1,
  lineCap: 'round',
  lineJoin: 'miter',
  miterLimit: 1,
  lineDash: [ ],
  lineDashOffset: 0,
  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 an even-numbered list of distances produce a line of alternating dashes and spaces. The default is [ ].

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

An image that will be placed inside each dash. Can be used only when the lineDash is specified. Works only when using map engine type H.Map.EngineType['HARP']. If not specified then no image is used.

lineDashOffset number

The phase offset for the line dash pattern The default is 0.

lineHeadCap H.map.SpatialStyle.LineCap | undefined

The cap type of the head of a solid line or, in case of a dashed line, for the head of each dash. If not specified the lineCap property is used.

lineJoin H.map.SpatialStyle.LineJoin non-null

The type of the corner created when two lines meet, the default is "miter".

lineTailCap H.map.SpatialStyle.LineCap | undefined

The cap type of the tail of a solid line or, in case of a dashed line, for the tail of each dash. If not specified then the lineCap property is used.

lineWidth number

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

miterLimit number

The miter length as the distance between the inner corner and the outer corner where two lines meet. The default is 1.

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", "square", "arrow-head" or "arrow-tail".

H.map.SpatialStyle.LineJoin string

The type of the corner created when two lines meet, one of "round", "bevel" or "miter".

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. The type can be overridden by lineTailCap and lineHeadCap.

lineJoin H.map.SpatialStyle.LineJoin <optional>

The type of corner created when two lines meet.

miterLimit number <optional>

The miter length is the distance from the point where the join occurs to the intersection of the line edges on the outside of the join. The miter limit ratio is the maximum allowed ratio of the miter length to half the line width. The default is 1 (see CanvasRenderingContext2D.miterLimit). The maximum supported miter limit is 100.

lineDash Array.<number> <optional>

The line dash pattern as an even-numbered list of distances to alternate lines (dashes) and spaces. If the browser does not support this feature this property is ignored.

lineDashOffset number <optional>

The phase offset of the line dash pattern

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

An image that will be placed inside each dash. Can be used only when the lineDash is specified. Works only when using map engine type H.Map.EngineType['HARP'].

lineTailCap H.map.SpatialStyle.LineCap <optional>

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

lineHeadCap H.map.SpatialStyle.LineCap <optional>

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