Class: Icon

H.map.Icon

new H.map.Icon (bitmap, opt_options)

A visual representation of the H.map.Marker.

Name Type Description
bitmap string | HTMLImageElement | HTMLCanvasElement

An image URL, an SVG (string), an bitmap image or a canvas.

opt_options H.map.Icon.Options optional

an object containing icon initialization attributes such as width and height, etc.

Throws:

if size, anchor or hitArea is specified with invalid type or values

Type
H.lang.InvalidArgumentError

Extends

Members

H.map.Icon.State static

The state types of an Icon

Properties:
Name Description
ERROR
LOADING
READY

Methods

addEventListener (type, handler, opt_capture, opt_scope) inherited

This method adds a listener for a specific event.

Note that to prevent potential memory leaks, you must either call removeEventListener or dispose on the given object when you no longer need it.

Name Type Description
type string

The name of the event

handler function

An event handler function

opt_capture boolean optional

true indicates that the method should listen in the capture phase (bubble otherwise)

opt_scope Object optional

An object defining the scope for the handler function

addOnDisposeCallback (callback, opt_scope) inherited

This method adds a callback which is triggered when the EventTarget object is being disposed.

Name Type Description
callback function

The callback function.

opt_scope Object optional

An optional scope for the callback function

dispatchEvent (evt) inherited

This method dispatches an event on the EventTarget object.

Name Type Description
evt H.util.Event | string

An object representing the event or a string with the event name

dispose () inherited

This method removes listeners from the given object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.

getAnchor ()H.math.Point

Retrieves the anchor point of the given icon or null if an anchor was not specified in the constructor options and the state of this icon is not H.map.Icon.State.READY.

Returns:
Type Description
H.math.Point

getBitmap ()HTMLImageElement | HTMLCanvasElement

Retrieves the bitmap of the give icon or null if the bitmap is not yet ready (see H.map.Icon#getState)

Returns:
Type Description
HTMLImageElement | HTMLCanvasElement

getHitArea ()H.map.HitArea

Retrieves the hit area of the icon.

Returns:
Type Description
H.map.HitArea The the hit area of the icon or null if no hit area is specified.

getSize ()H.math.Size

Retrieves the size of the given icon or null if a size was not specified in the constructor options and the state of the icon is not H.map.Icon.State.READY

Returns:
Type Description
H.math.Size

getState ()H.map.Icon.State

Retrieves the bitmap loading state of the given icon object.

Returns:
Type Description
H.map.Icon.State A value indicating the icon loading state.

removeEventListener (type, handler, opt_capture, opt_scope) inherited

This method removes a previously added listener from the EventTarget instance.

Name Type Description
type string

The name of the event

handler function

A previously added event handler

opt_capture boolean optional

true indicates that the method should listen in the capture phase (bubble otherwise)

opt_scope Object optional

An object defining the scope for the handler function

Type Definitions

H.map.Icon.Options Object

Options used to initialize an Icon object.

Properties:
Name Type Argument Description
size H.math.ISize <optional>

The size in pixels of the icon, the default is the natural size of the bitmap.

anchor H.math.IPoint <optional>

The anchor point in pixels, the default is bottom-center.

hitArea H.map.HitArea <optional>

The area to use for hit detection. If omitted the whole rectangular area of the icon is used. If specified, the top-left corner of the icon area is used as origin for the coordinates of the hitArea.

crossOrigin string <optional>
<nullable>

The value to use for the crossOrigin attribute of the icon image, if omitted the attribute is set to "anonymous". For more details see MDN web docs.

stickHeight number <optional>

When specified, the icon is elevated in the screen space's Y axis according to the current tilt angle of the map. A straight line (stick) is rendered to connect the elevated and the original anchor points. The specified value must be positive and indicates the stick's maximum height in pixels on a 90° tilt. On tilt angle of 0° the icon is not elevated and therefore the stick not visible.

stickColor string <optional>

The color of the line (stick), the default is "white".

Events

statechange

Event fired when the icon bitmap loading state changes, see H.map.Icon#getState

Type: