Maps API for JavaScript Developer's Guide

H.map.HitArea

Class Summary

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.

[ For full details, see the Class Details ]

Class Description

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.

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]);

Constructor Details

H.map.HitArea(shapeType, opt_coords)

Parameters:
 
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:
 
{H.lang.InvalidArgumentError}
 
if the `shapeType` is not supported or the `opt_coords` is invalid for the specified type.