试图在此处构建地图hitarea对象的例外



H.map.Icon类包含一个hitArea选项,我假设该选项适用于调整图标或标记的选择区域公差。不幸的是,该文档有点稀疏,以下是一个例外:

var marker = new H.map.Marker(location, { icon: new H.map.Icon("/Content/images/anchordot.png", { 
      size: { w: 20, h: 20 }, 
      anchor: { x: 10, y: 10 }, 
      hitArea: new H.map.HitArea(H.map.HitArea.ShapeType.CIRCLE, [20]) }) });

我真的不知道HitArea构造函数需要可选的第二个参数是什么,但是无论有没有该参数,我都会得到一个例外。例外的细节根本没有帮助。

想法?

您将错误的参数传递给数组。对于圆圈,我们需要三个参数 - 即坐标和半径。因此,您的示例应该看起来像下面。愉快的编码!

var marker = new H.map.Marker(location, { icon: new H.map.Icon("/Content/images/anchordot.png", { 
      size: { w: 20, h: 20 }, 
      anchor: { x: 10, y: 10 }, 
      hitArea: new H.map.HitArea(H.map.HitArea.ShapeType.CIRCLE, [0,0,20]) }) });

最新更新