-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
67 lines (47 loc) · 1.53 KB
/
app.py
File metadata and controls
67 lines (47 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import streamlit as st
from streamlit_folium import st_folium
import folium
st.title("1️⃣ Basic Leaflet Map")
# Create map centered on London
m = folium.Map(location=[51.5072, 0.1276], zoom_start=10)
st_folium(m, width=700)
--
import streamlit as st
from streamlit_folium import st_folium
import folium
st.title("2️⃣ Adding a Marker")
m = folium.Map(location=[48.8566, 2.3522], zoom_start=12)
folium.Marker(
[48.8566, 2.3522],
popup="Hello from Paris!",
tooltip="Click me",
icon=folium.Icon(color="red", icon="heart", prefix="fa")
).add_to(m)
st_folium(m, width=700)
--
import streamlit as st
from streamlit_folium import st_folium
import folium
from geopy.geocoders import Nominatim
st.title("🌍 Search a City and Add a Marker")
city_name = st.text_input("Enter a city name:",
placeholder="e.g. Paris, Tokyo, London")
location = [48.8566, 2.3522]
zoom = 4
if city_name:
geolocator = Nominatim(user_agent="streamlit_map_app")
location_data = geolocator.geocode(city_name)
if location_data:
location = [location_data.latitude, location_data.longitude]
zoom = 10
st.success(f"📍 Found: {location_data.address}")
else:
st.error("❌ City not found! Showing default view (Paris).")
m = folium.Map(location=location, zoom_start=zoom)
folium.Marker(
location,
popup=f"Hello from {city_name or 'Paris'}!",
tooltip="Click me",
icon=folium.Icon(color="red", icon="heart", prefix="fa")
).add_to(m)
st_folium(m, width=700, height=500)