Advertisement
safwan092

Untitled

Dec 2nd, 2023
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. import folium
  2. import streamlit as st
  3. from streamlit_folium import st_folium
  4.  
  5. # Define the current page
  6. current_page = st.session_state.get("current_page", "map")
  7.  
  8. # Home page
  9. if current_page == "home":
  10. st.title("Home Page")
  11. st.write("Welcome to the Home Page!")
  12.  
  13. # Button to go to the About page
  14. if st.button("Double Click to Go to Map demo Page"):
  15. st.session_state["current_page"] = "map"
  16.  
  17. # About page
  18. elif current_page == "map":
  19. st.title("Map demo")
  20. st.write("This is the Map demo Page!")
  21. # The message and nested widget will remain on the page
  22. m = folium.Map(location=[21.502771, 39.247194], zoom_start=18)
  23. folium.Marker = m.add_child(folium.ClickForMarker("<b>Lat: </b> ${lat}<br/><b>Lon: </b> ${lng}<br><b>Altitude:</b> 10.00 m"))
  24. output = st_folium(m, width=700, height=500)
  25. if output["last_clicked"] is not None:
  26. output["last_clicked"]["alti"] = 10
  27. latitude_1_last_clicked = round(output["last_clicked"]["lat"], 6)
  28. longitude_1_last_clicked = round(output["last_clicked"]["lng"], 6)
  29. altitude_1_last_clicked = output["last_clicked"]["alti"]
  30. st.write("• Latitude:", latitude_1_last_clicked)
  31. st.write("• Latitude:", longitude_1_last_clicked)
  32. st.write("• Altitude:", altitude_1_last_clicked, "meter")
  33. # Button to go back to the Home page
  34. if st.button("Double Click to Go to Home Page"):
  35. st.session_state["current_page"] = "home"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement