【问题标题】:Highmaps shared tooltip for overlapping locationsHighmaps 共享重叠位置的工具提示
【发布时间】:2017-03-08 16:57:16
【问题描述】:

如果有两个重叠点,如何显示以下地图的共享工具提示。

例如北格拉斯哥和南格拉斯哥 - 我希望能够使用相同或非常接近的地理位置并为两个点显示一个工具提示。

我尝试了共享和拆分工具提示选项,但没有成功。

tooltip: {
    headerFormat: '',
    pointFormat: '<b>{point.name}</b><br>Lat: {point.lat}, Lon: {point.lon}',
    shared: true
},

fiddle

【问题讨论】:

    标签: javascript charts highcharts tooltip highmaps


    【解决方案1】:

    定义一个包含附加信息的点。 您可以将 Glasgow 积分减少为以下积分:

     {
            name: 'Glasgow',
            lat: 55.858,
            lon: -4.259,
            subnames: ['South Glasgow', ['North Glasgow']]
        }
    

    然后您可以访问工具提示格式化程序以获取更多信息:

        formatter: function (tooltip) {
          const subnames = this.point.options.subnames;
          if (subnames) {
            return `
                <b>${subnames[0]}</b><br>
                <b>${subnames[1]}</b><br>
              Lat: ${this.point.lat}, Lon ${this.point.lon}
            `
          }
    
          return tooltip.defaultFormatter.call(this, tooltip);
        }
    

    示例:http://jsfiddle.net/f9wxu2o7/1/

    【讨论】:

    • 谢谢,这很有帮助。我现在只需要重组我的数据。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-04
    • 1970-01-01
    • 1970-01-01
    • 2015-07-11
    • 1970-01-01
    • 1970-01-01
    • 2015-07-14
    相关资源
    最近更新 更多