|
|
import streamlit as st |
|
|
import folium |
|
|
from streamlit_folium import folium_static |
|
|
from map_handler import MapHandler |
|
|
from wikipedia_handler import WikipediaHandler |
|
|
from utils import get_current_location |
|
|
|
|
|
def main(): |
|
|
st.set_page_config(page_title="Local Landmarks Map", layout="wide") |
|
|
st.title("Discover Local Landmarks") |
|
|
|
|
|
|
|
|
map_handler = MapHandler() |
|
|
wiki_handler = WikipediaHandler() |
|
|
|
|
|
|
|
|
lat, lon = get_current_location() |
|
|
|
|
|
|
|
|
m = map_handler.create_map(lat, lon) |
|
|
|
|
|
|
|
|
map_container = st.empty() |
|
|
|
|
|
|
|
|
with map_container: |
|
|
folium_static(m, width=1000, height=600) |
|
|
|
|
|
|
|
|
bounds = map_handler.get_map_bounds(m) |
|
|
|
|
|
|
|
|
landmarks = wiki_handler.get_landmarks_in_area(bounds) |
|
|
|
|
|
|
|
|
st.write(f"Number of landmarks fetched: {len(landmarks)}") |
|
|
|
|
|
|
|
|
for landmark in landmarks: |
|
|
map_handler.add_landmark_marker(m, landmark) |
|
|
|
|
|
|
|
|
with map_container: |
|
|
folium_static(m, width=1000, height=600) |
|
|
|
|
|
|
|
|
if st.button("Refresh Landmarks"): |
|
|
|
|
|
bounds = map_handler.get_map_bounds(m) |
|
|
|
|
|
landmarks = wiki_handler.get_landmarks_in_area(bounds) |
|
|
|
|
|
st.write(f"Number of landmarks fetched after refresh: {len(landmarks)}") |
|
|
|
|
|
map_handler.clear_markers(m) |
|
|
|
|
|
for landmark in landmarks: |
|
|
map_handler.add_landmark_marker(m, landmark) |
|
|
|
|
|
with map_container: |
|
|
folium_static(m, width=1000, height=600) |
|
|
|
|
|
st.sidebar.header("About") |
|
|
st.sidebar.info("This app displays local landmarks on an interactive map using data from Wikipedia. " |
|
|
"Move around the map to discover new landmarks, and click on markers to learn more about them.") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |
|
|
|