I am developing an app that takes input from user: source and destination. The user clicks a button and a route between the two points is shown. But the app map page is getting refreshed again and again, as soon as I click on the button after showing the map for few seconds. Can someone please help me out on where the error is?
import streamlit as st
import routing
from streamlit_folium import st_folium
import folium
if "router" not in st.session_state:
st.session_state.router = routing.RoutingClass()
@st.cache(allow_output_mutation=True)
def get_map(source, destination):
route = st.session_state.router.get_path(source, destination)
route_map = st.session_state.router.get_map(route)
return route_map
source = st.text_input("Enter Source")
destination = st.text_input("Enter Destination")
onClick = st.button("Find Path")
if onClick:
st.write("Source: ", st.session_state.router.get_coordinates(source))
st.write("Destination: ", st.session_state.router.get_coordinates(destination))
# get route and create folium map
map_data = st_folium(get_map(source, destination), width=300)
else:
st.write("Please enter source and destination")