Coloring a country in lat-long highmap

2019-03-06 09:20发布

I am working with highmaps and got stuck in one requirement .

I want to color a country with a particular color in lat-long world-map .

Let's say I need US color to be blue and Russia color to be Red on the following map fiddle .

Is there any API in highmaps to support the same ?

`http://jsfiddle.net/dnbtkmyz/`

Thanks

1条回答
冷血范
2楼-- · 2019-03-06 09:27

You could do this with manipulation of load events like this:

chart: {
  events: {
    load: function() {
      this.series[0].data = this.series[0].data.map((el) => {
        if (el['hc-key'] == "us") {
          el.color = "#ff0000";
          return el;
        }
        if (el['hc-key'] == "ru") {
          el.color = "#0000ff";
          return el;
        }
        return el
      })

      this.update({
        series: [{
          data: this.series[0].data
        }]
      })
    }
  }
}

Working example: http://jsfiddle.net/ewolden/dnbtkmyz/42/

查看更多
登录 后发表回答