Click events in maps

Hello!

I am working with maps. So far I’ve been able to display the data and the information which is shown on hover is correct.

Now I am looking at click events. I’d like to bind functions to click events in a way that it matters on which country I click.
Currently, I can bind a function to a click anywhere in the map. Is there a way to detect click events in a country-specific way?

Cheers!

Have you taken a look at https://plot.ly/javascript/click-events/ ?

I did but not sure how to apply that to a choropleth map.

like this: https://codepen.io/etpinard/pen/rpQOaX?editors=0011

Yep… that’s what I mean. I got to that point. The question is if it is possible to distinguish between the different countries. In your example, that you bind one function to Canada, and another to USA and a third one to Russia.

see https://codepen.io/etpinard/pen/VyVepE?editors=0011

1 Like

Perfect. That’s exactly what I meant.
Thanks a lot Etienne for sharing how it can be done!
I appreciate it!