Control Area Tolerance for a Marker
Problem
=======
For better area tolerance, it may be necessary to set up an instance of H.map.HitArea of type CIRCLE while creating H.map.Marker object.
Solution
========
The H.map.Icon class includes a hitArea option that is used to adjust the selection area tolerance for an icon or marker.
For more information on these classes and their usage, see H.map.HitArea.<br />// 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]);<br />
The example below demonstrates how to declare a hitArea of shape type CIRCLE. Note that the second parameter of the hitArea constructor is an array of the coordinates and the radius of the circle - [0, 0, 20] in the example below.<br />var marker = new H.map.Marker( <br /> location <br /> , { icon: new H.map.Icon( <br /> "/Content/images/anchordot.png" <br /> , { size: { w: 20, h: 20 } , anchor: { x: 10, y: 10 } <br /> , hitArea: new H.map.HitArea( <br /> H.map.HitArea.ShapeType.CIRCLE <br /> , [0,0,20] <br /> ) <br /> } <br /> ) <br /> } <br /> );<br />