You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Control which kinds of data are returned (and which trigger reruns)
* Convert example app into MPA
* Add limited return example
* Standardize layout
* Bump version
* Don't replace functionality of folium_static yet
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!
"Select page", ["Home", "Bi-directional data model", "Plugin: Draw"], index=0
3
+
st.set_page_config(
4
+
page_title="streamlit-folium documentation",
5
+
page_icon=":world_map:️",
6
+
layout="wide",
8
7
)
9
8
10
9
"# streamlit-folium"
11
10
12
-
ifpage=="Home":
13
-
"streamlit-folium integrates two great open-source projects in the Python ecosystem: [Streamlit](https://streamlit.io) and [Folium](https://python-visualization.github.io/folium/)!"
14
-
15
-
"""
16
-
Currently, there are two functions defined:
11
+
"streamlit-folium integrates two great open-source projects in the Python ecosystem: [Streamlit](https://streamlit.io) and [Folium](https://python-visualization.github.io/folium/)!"
17
12
18
-
- `st_folium()`: a bi-directional Component, taking a Folium/Branca object and plotting to the Streamlit app. Upon mount/interaction with the Streamlit app, st_folium() returns a Dict with selected information including the bounding box and items clicked on
19
-
20
-
- `folium_static()`: takes a folium.Map, folium.Figure, or branca.element.Figure object and displays it in a Streamlit app.
21
-
22
-
_Note: `folium_static()` is based on the `_repr_html()` representation created in Folium. This function should be a strict subset the of functionality of the newer `st_folium()` function._
23
-
24
-
It is recommended that users switch to `st_folium()` as soon as possible, as `folium_static()` will likely be deprecated. If there is a reason why `folium_static()` needs to remain, please leave a [GitHub issue](https://github.com/randyzwitch/streamlit-folium/issues) describing your use-case.
25
-
"""
13
+
"""
14
+
Currently, there are two functions defined:
26
15
16
+
- `st_folium()`: a bi-directional Component, taking a Folium/Branca object and plotting to the Streamlit app. Upon mount/interaction with the Streamlit app, st_folium() returns a Dict with selected information including the bounding box and items clicked on
- `folium_static()`: takes a folium.Map, folium.Figure, or branca.element.Figure object and displays it in a Streamlit app.
19
+
"""
44
20
45
-
# call to render Folium map in Streamlit
46
-
st_data=st_folium(m, width=725)
21
+
"""
22
+
On its own, Folium is limited to _display-only_ visualizations; the Folium API generates the proper [leaflet.js](https://leafletjs.com/) specification,
23
+
as HTML and displays it. Some interactivity is provided (depending on how the Folium API is utilized), but the biggest drawback
24
+
is that the interactivity from the visualization isn't passed back to Python, and as such, you can't make full use of the functionality
25
+
provided by the leaflet.js library.
47
26
48
-
elifpage=="Bi-directional data model":
49
-
"""
50
-
On its own, Folium is limited to _display-only_ visualizations; the Folium API generates the proper [leaflet.js](https://leafletjs.com/) specification,
51
-
as HTML and displays it. Some interactivity is provided (depending on how the Folium API is utilized), but the biggest drawback
52
-
is that the interactivity from the visualization isn't passed back to Python, and as such, you can't make full use of the functionality
53
-
provided by the leaflet.js library.
27
+
`streamlit-folium` builds upon the convenient [Folium API](https://python-visualization.github.io/folium/modules.html)
28
+
for building geospatial visualizations by adding a _bi-directional_ data transfer functionality. This not only allows for increased interactivity between
29
+
the web browser and Python, but also the use of larger datasets through intelligent querying.
54
30
55
-
`streamlit-folium` builds upon the convenient [Folium API](https://python-visualization.github.io/folium/modules.html)
56
-
for building geospatial visualizations by adding a _bi-directional_ data transfer functionality. This not only allows for increased interactivity between
57
-
the web browser and Python, but also the use of larger datasets through intelligent querying.
31
+
### Bi-directional data model
32
+
"""
33
+
left, right=st.columns(2)
58
34
59
-
### Bi-directional data model
60
35
61
-
If we take a look at the example from the Home page, it might seem trivial. We define a single point with a marker and pop-up and display it:
36
+
withleft:
37
+
"""
38
+
If we take a look at the example from the Home page, it might seem trivial. We define a single point with a marker and pop-up and display it:
But behind the scenes, a lot more is happening _by default_. The return value of `st_folium` is set to
58
+
But behind the scenes, a lot more is happening _by default_. The return value of `st_folium` is set to
82
59
`st_data`, and within this Python variable is information about what is being displayed on the screen:
83
60
"""
84
61
85
-
withst.expander("Expand to see data returned to Python"):
86
-
st_data
62
+
st_data
87
63
88
64
"""
89
65
As the user interacts with the data visualization, the values for `bounds` are constantly updating, along
90
66
with `zoom`. With these values available in Python, we can now limit queries based on bounding box, change
91
67
the marker size based on the `zoom` value and much more!
92
68
"""
93
-
94
-
elifpage=="Plugin: Draw":
95
-
96
-
"""
97
-
Folium supports some of the [most popular leaflet plugins](https://python-visualization.github.io/folium/plugins.html). In this example,
98
-
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.
99
-
100
-
When a shape is drawn on the map, the coordinates that represent that shape are passed back as a geojson feature via
101
-
the `all_drawings` and `last_active_drawing` data fields.
102
-
103
-
Draw something below to see the return value back to Streamlit!
0 commit comments