如何解决在高地图(highmaps / highcharts)中悬停鼠标时标记重叠的问题?

huangapple go评论139阅读模式
英文:

how to solve the problem with markers overlapping each other when hovering the mouse in highmaps(highcharts)?

问题

如何使默认情况下标记 "莫斯科" 放置在标记 "图拉" 的后面,以及当悬停在标记 "莫斯科" 上时,它仍然位于标记 "图拉" 的后面并部分突出显示?

我的代码:演示

您可以考虑其他放置标记在地图上的方法。

英文:

how to make the marker "moscow" by default be placed behind the marker "tula", and also when hovering over the marker "moscow" it remains behind the marker "tula" and is partially highlighted?

my code: demo

you can consider other approaches to placing markers on the map

答案1

得分: 0

要实现这一点,您需要在图表的load事件、onMouseOver()onMouseOut()函数中覆盖莫斯科(moskva)或图拉(tula)标记的图形元素。

以下是您可以基于的示例修改:

当您遍历点时,添加以下条件:

if (el.id === "tula") {
  el.graphic.attr({
    zIndex: 100,
  });
}

mouseOvermouseOut函数中,以下是带有透明度更改的修改:

if (this.id === "moskva") {
  this.graphic.attr({
    opacity: 0.5,
    zIndex: -100,
  });
}

演示链接:
https://codesandbox.io/s/highcharts-vue-map-employees-project-forked-w7pxnr?file=/src/components/Chart.vue

英文:

To achieve that you need to overwrite the graphic element of the moskva or tula markers at chart load event, onMouseOver() and onMouseOut() functions as well.

Here is the example modification you can base on:

When you loop throught the points add the conditional as follows:

 if (el.id === "tula") {
      el.graphic.attr({
              zIndex: 100,
          });
    }

And at the mouseOver/mouseOut functions the following modification with the opacity change:

 if (this.id === "moskva") {
        this.graphic.attr({
          opacity: 0.5,
          zIndex: -100,
        });
      }

Demo:
https://codesandbox.io/s/highcharts-vue-map-employees-project-forked-w7pxnr?file=/src/components/Chart.vue

huangapple
  • 本文由 发表于 2023年7月13日 15:26:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76676893.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定