Spaces:
Sleeping
Sleeping
Added locate control #2
Browse files- apps/timelapse.py +34 -31
apps/timelapse.py
CHANGED
@@ -6,6 +6,7 @@ import folium
|
|
6 |
import streamlit as st
|
7 |
from bokeh.models.widgets import Button
|
8 |
from bokeh.models import CustomJS
|
|
|
9 |
from streamlit_bokeh_events import streamlit_bokeh_events
|
10 |
import geemap.colormaps as cm
|
11 |
import geemap.foliumap as geemap
|
@@ -59,41 +60,43 @@ def app():
|
|
59 |
st.session_state["vis_params"] = None
|
60 |
|
61 |
with row1_col1:
|
62 |
-
m = geemap.Map(
|
|
|
|
|
63 |
m.add_basemap("ROADMAP")
|
64 |
|
65 |
with row1_col2:
|
66 |
|
67 |
-
loc_button = Button(label="Get Device Location", max_width=150)
|
68 |
-
loc_button.js_on_event(
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
)
|
80 |
-
result = streamlit_bokeh_events(
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
)
|
88 |
-
|
89 |
-
if result:
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
|
98 |
keyword = st.text_input("Search for a location:", "")
|
99 |
if keyword:
|
|
|
6 |
import streamlit as st
|
7 |
from bokeh.models.widgets import Button
|
8 |
from bokeh.models import CustomJS
|
9 |
+
from folium import plugins
|
10 |
from streamlit_bokeh_events import streamlit_bokeh_events
|
11 |
import geemap.colormaps as cm
|
12 |
import geemap.foliumap as geemap
|
|
|
60 |
st.session_state["vis_params"] = None
|
61 |
|
62 |
with row1_col1:
|
63 |
+
m = geemap.Map(
|
64 |
+
basemap="HYBRID", plugin_Draw=True, draw_export=True, locate_control=True
|
65 |
+
)
|
66 |
m.add_basemap("ROADMAP")
|
67 |
|
68 |
with row1_col2:
|
69 |
|
70 |
+
# loc_button = Button(label="Get Device Location", max_width=150)
|
71 |
+
# loc_button.js_on_event(
|
72 |
+
# "button_click",
|
73 |
+
# CustomJS(
|
74 |
+
# code="""
|
75 |
+
# navigator.geolocation.getCurrentPosition(
|
76 |
+
# (loc) => {
|
77 |
+
# document.dispatchEvent(new CustomEvent("GET_LOCATION", {detail: {lat: loc.coords.latitude, lon: loc.coords.longitude}}))
|
78 |
+
# }
|
79 |
+
# )
|
80 |
+
# """
|
81 |
+
# ),
|
82 |
+
# )
|
83 |
+
# result = streamlit_bokeh_events(
|
84 |
+
# loc_button,
|
85 |
+
# events="GET_LOCATION",
|
86 |
+
# key="get_location",
|
87 |
+
# refresh_on_update=False,
|
88 |
+
# override_height=75,
|
89 |
+
# debounce_time=0,
|
90 |
+
# )
|
91 |
+
|
92 |
+
# if result:
|
93 |
+
# if "GET_LOCATION" in result:
|
94 |
+
# loc = result.get("GET_LOCATION")
|
95 |
+
# lat = loc.get("lat")
|
96 |
+
# lon = loc.get("lon")
|
97 |
+
# popup = f"lat, lon: {lat}, {lon}"
|
98 |
+
# m.add_marker(location=(lat, lon), popup=popup)
|
99 |
+
# m.set_center(lon, lat, 16)
|
100 |
|
101 |
keyword = st.text_input("Search for a location:", "")
|
102 |
if keyword:
|