import streamlit as st
import folium
from streamlit_folium import folium_static
from folium.plugins import MarkerCluster
import requests
import json
from datetime import datetime
import re
from geopy.distance import geodesic
from typing import Dict, List, Tuple, Optional
import time
import random
# Set page configuration
st.set_page_config(
page_title="GeoVision Pro",
page_icon="🌍",
layout="wide",
initial_sidebar_state="expanded"
)
# Custom CSS for a blue-themed UI without the black strip
st.markdown("""
""", unsafe_allow_html=True)
# Moving 3D Earth Background (Smaller)
st.markdown('''
', unsafe_allow_html=True)
# Query Section
st.markdown('
Query Interface
', unsafe_allow_html=True)
# Function to handle smart location search
def smart_location_search():
st.session_state.query = "Show restaurants near the Eiffel Tower"
st.experimental_rerun
# Query input with a button for smart location search
query = st.text_input("Enter your query:", placeholder="Try: 'Show restaurants near the Eiffel Tower' or 'What's the weather in Tokyo?'", key="query_input")
if st.button("Smart Location Search"):
smart_location_search()
# Function to fetch data from backend
def fetch_data_from_backend(endpoint, params=None):
try:
response = requests.get(f"https://geosapi.onrender.com/{endpoint}", params=params)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
st.error(f"Error fetching data: {e}")
return None
# Features Section
st.markdown('
Features
', unsafe_allow_html=True)
features = [
{"icon": "🌐", "title": "Smart Location Search", "description": "Find places and get directions with natural language queries."},
{"icon": "🌦️", "title": "Real-time Weather", "description": "Get current weather conditions and forecasts for any location."},
{"icon": "🌬️", "title": "Air Quality", "description": "Check air quality levels and pollution data worldwide."},
{"icon": "📍", "title": "Personal Places", "description": "Save and manage your favorite locations with notes and emotions."}
]
for feature in features:
st.markdown(f"""
{feature['icon']} {feature['title']}
{feature['description']}
""", unsafe_allow_html=True)
# Map Section (Placeholder)
st.markdown('
Map Visualization
', unsafe_allow_html=True)
# Example: Fetching data from the backend
if query:
# Example endpoint and parameters
data = fetch_data_from_backend("your-endpoint", params={"query": query})
if data:
st.write("Data from backend:", data)
# Here you would integrate the map visualization
st.markdown('
', unsafe_allow_html=True)
# Button Section
st.markdown('
', unsafe_allow_html=True)
if st.button("Random Place"):
random_queries = [
"Show restaurants in Tokyo",
"Find museums in Berlin",
"Show hospitals in Paris",
"Find parks in New York",
"Show cafes in London",
"Find supermarkets in Rome"
]
st.write(f"Random Query: {random.choice(random_queries)}")
if st.button("Clear Results"):
st.write("Results cleared.")
st.markdown('
', unsafe_allow_html=True)
# Footer Section
st.markdown('', unsafe_allow_html=True)
st.markdown('
', unsafe_allow_html=True)