jordancaraballo commited on
Commit
a8bdcd5
β€’
1 Parent(s): cd55fe8

Adding folium page

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -2
  2. pages/pages/2_🌍_Alaska_WRF.py +36 -44
Dockerfile CHANGED
@@ -9,9 +9,8 @@ RUN rm -rf /etc/apt/sources.list.d/*.list && \
9
  RUN python3 -m pip install --upgrade pip setuptools wheel
10
 
11
  COPY requirements.txt .
12
- RUN python3 -m pip install --upgrade pip setuptools wheel cython numpy pyshp six pyproj
13
  RUN python3 -m pip install --upgrade --no-binary :all: shapely
14
- #RUN python3 -m pip install git+https://github.com/SciTools/cartopy.git --upgrade --no-binary :all: cartopy
15
  RUN python3 -m pip install git+https://github.com/SciTools/cartopy.git --upgrade cartopy
16
 
17
  RUN python3 -m pip install --no-cache-dir --compile -r requirements.txt
 
9
  RUN python3 -m pip install --upgrade pip setuptools wheel
10
 
11
  COPY requirements.txt .
12
+ RUN python3 -m pip install --upgrade pip setuptools wheel cython numpy pyshp six pyproj streamlit-folium
13
  RUN python3 -m pip install --upgrade --no-binary :all: shapely
 
14
  RUN python3 -m pip install git+https://github.com/SciTools/cartopy.git --upgrade cartopy
15
 
16
  RUN python3 -m pip install --no-cache-dir --compile -r requirements.txt
pages/pages/2_🌍_Alaska_WRF.py CHANGED
@@ -1,44 +1,36 @@
1
- import ipyleaflet
2
- import solara
3
- import ipywidgets as widgets
4
-
5
- zoom = solara.reactive(2)
6
- center = solara.reactive((20, 0))
7
-
8
-
9
- class Map(ipyleaflet.Map):
10
- def __init__(self, **kwargs):
11
- super().__init__(**kwargs)
12
- self.layout.height = '600px'
13
- # Add what you want below
14
-
15
- label = widgets.Label('Clicked location')
16
- output = widgets.Output()
17
- widget = widgets.VBox([label, output])
18
- control = ipyleaflet.WidgetControl(widget=widget, position='bottomright')
19
- self.add_control(control)
20
-
21
- def handle_interaction(**kwargs):
22
- latlon = kwargs.get("coordinates")
23
- if kwargs.get("type") == "click":
24
- with output:
25
- output.clear_output()
26
- print(latlon)
27
-
28
- self.on_interaction(handle_interaction)
29
-
30
-
31
- @solara.component
32
- def Page():
33
- with solara.Column(style={"min-width": "500px"}):
34
- solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
35
- Map.element(
36
- zoom=zoom.value,
37
- on_zoom=zoom.set,
38
- center=center.value,
39
- on_center=center.set,
40
- scroll_wheel_zoom=True,
41
-
42
- )
43
- solara.Text(f"Zoom: {zoom.value}")
44
- solara.Text(f"Center: {center.value}")
 
1
+ import streamlit as st
2
+
3
+ st.set_page_config(
4
+ page_title="streamlit-folium documentation: Draw Support",
5
+ page_icon=":pencil:",
6
+ layout="wide",
7
+ )
8
+
9
+ """
10
+ # streamlit-folium: Draw Support
11
+
12
+ Folium supports some of the [most popular leaflet plugins](https://python-visualization.github.io/folium/plugins.html). In this example,
13
+ we can add the [`Draw`](https://python-visualization.github.io/folium/plugins.html#folium.plugins.Draw) plugin to our map, which allows for drawing geometric shapes on the map.
14
+
15
+ When a shape is drawn on the map, the coordinates that represent that shape are passed back as a geojson feature via
16
+ the `all_drawings` and `last_active_drawing` data fields.
17
+
18
+ Draw something below to see the return value back to Streamlit!
19
+ """
20
+
21
+ with st.echo(code_location="below"):
22
+ import folium
23
+ import streamlit as st
24
+ from folium.plugins import Draw
25
+
26
+ from streamlit_folium import st_folium
27
+
28
+ m = folium.Map(location=[39.949610, -75.150282], zoom_start=5)
29
+ Draw(export=True).add_to(m)
30
+
31
+ c1, c2 = st.columns(2)
32
+ with c1:
33
+ output = st_folium(m, width=700, height=500)
34
+
35
+ with c2:
36
+ st.write(output)