0

I have a Highmaps-map of the world, and display data for some countries. Getting a click handler for these countries is simple. (see also highmaps get country name on click event)

However, I would like to be able to also detect clicks on countries without data.

I found I can add a generic click handler to the map, but the event does not give me the selected country.

Any hints?

Relevant part of the options:

options: {
    chart: {
        events: {
            click: function (e) { console.log( e);},
Rob Audenaerde
  • 19,195
  • 10
  • 76
  • 121

1 Answers1

2

All points without data are rendered as null points by default, so you need to only enable nullInteraction property:

series: [{
  nullInteraction: true,
  point: {
    events: {
      click: function() {
        console.log(this.name)
      }
    },
  },
  ...
}]

Live demo: https://jsfiddle.net/BlackLabel/wnfrza5j/1/

API Reference: https://api.highcharts.com/highmaps/series.map.nullInteraction

ppotaczek
  • 36,341
  • 2
  • 14
  • 24