Use scattermapbox to populate a dropdown as a chained filter

I have a number of longs and lats for location pins, and I would like to allow the user to select which pins to select for further analysis. The selected locations are used to populate a dropdown with the multiple option.

For example, suppose the scattermapbox shows all the bus stops in a city. The user uses the select box tool to select the bus stops of interest. Because the bus stop names are passed to the dropdown as options, they populate the dropdown. If the user accidentally added a bus stop they didnt want to include, they could deselect it using the little x in the option name.

The selection works well and it populates the drop down as expected, but as soon as the I deselect a bus stop, the drop down empties. This is not what I need. I would like the list of bus stops to persist, but I cant seem to figure out how.

I tried to add persist to the drop down, but that didnt change anything, the options still disappear as soon as I deselect a bus stop in the drop down list.

How do I solve this?


Hi @knorrena

without your code snippet it’s hard to tell. I assume, that deselecting the bus stop leads to a callback which re- populates the dropdown.


There are a couple of ways to keep the selectedData from activating immediately.

1 - Add a button where the user clicks to load the selected data. (Uses the n_clicks of the button as the trigger and the state of the selected data)
2 - A button that enables or disables the selection change effecting whether it loads the new info of not.

I prefer 1, it is easier to implement and more user friendly I feel.