如何在悬停时打开信息气泡

How to open info bubble on hover

我无法找到上述问题的解决方案。 似乎除了官方示例 here.

中提出的方法之外,还有其他一些方法可以向标记添加事件侦听器

有问题的麻烦代码:

    group.addEventListener('mouseover', function (evt) {
    // event target is the marker itself, group is a parent event target
    // for all objects that it contains
    console.log(`Is it working yet?`)
    var bubble =  new H.ui.InfoBubble(evt.target.getPosition(), {
      // read custom data
      content: evt.target.getData()
    });
    // show info bubble
    ui.addBubble(bubble);
  }, false);

你快到了。您要收听的事件称为 pointermove:

group.addEventListener('pointermove', function (evt) {
    // event target is the marker itself, group is a parent event target
    // for all objects that it contains
    console.log(`Is it working yet?`)
    var bubble =  new H.ui.InfoBubble(evt.target.getPosition(), {
      // read custom data
      content: evt.target.getData()
    });
    // show info bubble
    ui.addBubble(bubble);
}, false);

map events guide