Folium map is not constantly showed in all tabs

I have st.tabs with 2 tabs.
I want to show 2 different folium map with different data/marker on those maps.
Sometimes it will show the map on tab 1, sometimes on tab 2.
Do you have suggestions?

x_map = folium.Map(location=[-2, 122], zoom_start=4)
for index, row in x_data.iterrows():
    folium.Marker(
        [row['Lat'], row['Long']],
        tooltip=row['Device'].split(' | ')[1],
        icon=folium.Icon(color='red', icon='map-marker')
    ).add_to(x_map)

y_map = folium.Map(location=[-2, 122], zoom_start=4)
for index, row in y_data.iterrows():
    folium.Marker(
        [row['Lat'], row['Long']],
        tooltip=row['Device'].split(' | ')[1],
        icon=folium.Icon(color='red', icon='map-marker')
    ).add_to(y_map)

tab1, tab2 = st.tabs(["X", "Y"])
with tab1:
      st_folium(x_map, key='x')
with tab2:
      st_folium(y_map, key='y')

Thanks in advance

1 Like