Skip to content
Advertisement

How to assign multiple inputs and outputs to app.callback with hover_feature or click_feature in dash-leaflet?

I’m having trouble getting multiple inputs and outputs to work in Dash-leaflet. Essentially, I want to do the following: on a mouse click place a marker on the map, and when hovering over a country highlight an area of the map with a polygon and display some information about the country being hovered over in a different pane. I implemented each of those functions in a separate app.callback, as in the below code.

JavaScript

While each of those callbacks works in isolation (i.e. if I comment out the other callbacks), none of them work if I run the code with two or more of them active.

If I combine the two hover_feature functions like the below, they seem to work together.

JavaScript

However, the “map_click” function still does not work along with the “country_hover” function. How can I get all three callbacks to work?

Advertisement

Answer

I found out how to do this, I had to add another dl.LayerGroup to the dl.Map object with a different id, then assigned each function to output to a different layer.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement