Class: HitArea

H.map.HitArea

new H.map.HitArea (shapeType, opt_coords)

This class represents an area that objects, such as a marker, occupy in the screen space. Such objects can be probed and returned by H.Map@getObjectsAt method.

Name Type Description
shapeType H.map.HitArea.ShapeType

The shape type of the HitArea. The shape type NONE can be used to prevent positive probes for the whole area. The types (RECT, CIRCLE, POLYGON) specify a geometrical shape for positive at this shape.

opt_coords Array.<number> optional

The coordinates to define the geometry of the shape. All values are treated as CSS pixels in screen space. The x-coordinates increase to the right; y-coordinates increase from top to bottom. Every shapeType requires its own format for the opt_coords value:
- NONE: The value is ignored and can be omitted.
- RECT: The mandatory value is two x,y pairs: left, top, right, bottom.
- CIRCLE: The mandatory value is x,y,r where x,y is a pair specifying the center of the circle and r is a value for the radius.
- POLYGON: The mandatory value is a set of x,y pairs for each point in the polygon: x1,y1,x2,y2,x3,y3 and so on.

Throws:

if the shapeType is not supported or the opt_coords is invalid for the specified type.

Type
H.lang.InvalidArgumentError
Example
// No positive probe for the whole area:
new H.map.HitArea(H.map.HitArea.ShapeType.NONE);

// A rectangular area with a left-top corner at (10, 10) and a right-bottom corner at (30, 30):
new H.map.HitArea(H.map.HitArea.ShapeType.RECT, [10, 10, 30, 30]);

// A circular area with center at (20, 20) and a radius of 10:
new H.map.HitArea(H.map.HitArea.ShapeType.CIRCLE, [20, 20, 10]);

// A polygonal area, a triangle with corner points at (20, 10), (30, 20) and (10, 20):
new H.map.HitArea(H.map.HitArea.ShapeType.POLYGON, [20, 10, 30, 20, 10, 20]);

Members

H.map.HitArea.ShapeType number static

The possible shape types that are supported by HitArea.

Properties:
Name Description
NONE

No hit area, any probe is negative

RECT

A rectangular hit area, any probe at this area is positive

CIRCLE

A circular hit area, any probe at this area is positive

POLYGON

An arbitrary polygonal hit area, any probe at this area is positive