Strange behavior from geemap when having multiple maps cached

Summary

I’m using geemap to display 1 of 3 different maps, depending on the desired option in a selectbox, wich are stored as in cache_resource. First, I’m centering the map on a country, using the centroid coordinates, and then I’m displaying the selected map out of the 3 options.
Here’s the weird behavior:
Sometimes the map centers in the correct coordinates, sometimes it doesn’t.
Sometimes the map shows the correct Map cache_resource, sometimes it doesn’t.
Below is a full example, please select any country and any basemap.

Steps to reproduce

Code snippet:

import streamlit as st
import geopandas as gpd
import json 
import ee
import geemap.foliumap as geemap

@st.cache_resource()
def set_gee():
    with open("thejsonwithmycredentials.json") as f:
        json_object = json.load(f, strict=False)
    service_account = json_object['client_email']
    json_object = json.dumps(json_object)
    credentials = ee.ServiceAccountCredentials(service_account, key_data=json_object)
    ee.Initialize(credentials)
    
set_gee()
places = gpd.read_file("https://raw.githubusercontent.com/gavinr/world-countries-centroids/master/dist/countries.geojson")

@st.cache_resource()
def make_first_map():
    Map = geemap.Map()
    Map.add_basemap('HYBRID')
    return Map

@st.cache_resource()
def make_second_map():
    Map = geemap.Map()
    Map.add_basemap('OpenTopoMap')
    return Map

@st.cache_resource()
def make_third_map():
    Map = geemap.Map()
    Map.add_basemap('CartoDB.Positron')
    return Map

Map_1 = make_first_map()
Map_2 = make_second_map()
Map_3 = make_third_map()


countries = list(places['COUNTRY'].unique())

country = st.selectbox("Select a country", countries, key = "country_")

st.write(st.session_state)

lon = places[places['COUNTRY'] == country]['geometry'].x.item()
lat = places[places['COUNTRY'] == country]['geometry'].y.item()

base = st.selectbox("Select a base", ['hybrid', 'topo', 'carto'])


if base == "hydrid":
    
    Map_1.setCenter(lon, lat, zoom = 9)
    Map_1.to_streamlit(
                        height=600, width = 950
                    )


elif base == "topo":
    
    Map_2.setCenter(lon, lat, zoom = 9)
    Map_2.to_streamlit(
                        height=600, width = 950
                    )  
    
else:
    
    Map_3.setCenter(lon, lat, zoom = 9)
    Map_3.to_streamlit(
                        height=600, width = 950
                    )  

Expected behavior:

I would have expected my desired map and my desired country to show.

Actual behavior:

For some layers, the correct map shows, for other, it doesn’t.
For so

Debug info

  • Streamlit version: 1.22.0
  • Python version: 3.10
  • Using miniconda
  • OS version: macbookpro 2018
  • Browser version:

Requirements file

geopandas==0.13.0
geemap==0.22.1
earthengine-api==0.1.355
streamlit==1.22.0

Links

  • Link to your GitHub repo:
  • Link to your deployed app:

Additional information

If needed, add any other context about the problem here.