Skip to content

Commit 34e464d

Browse files
authored
docs: add entry on Search plugin with FeatureGroup (#2115)
1 parent 0e76e23 commit 34e464d

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

docs/user_guide/plugins/search.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
The `Search` plugin allows you to search in your `GeoJson`, `TopoJson`, `FeatureGroup` or `MarkerCluster` objects.
44

5-
## Data
5+
## Search in GeoJSON
6+
7+
### Data
68

79
Let's get some JSON data from the web - both a point layer and a polygon GeoJson dataset with some population data.
810

@@ -89,7 +91,7 @@ Ok, now we have a new GeoDataFrame with our top 20 populated cities. Let's see t
8991
pop_ranked_cities.head(5)
9092
```
9193

92-
## Map with Search plugin
94+
### Map with Search plugin and GeoJSON data
9395

9496
Alright, let's build a map!
9597

@@ -149,3 +151,25 @@ colormap.add_to(m)
149151
150152
m
151153
```
154+
155+
## Search in FeatureGroup
156+
157+
Here's an example how to search `Marker`s in a `FeatureGroup`. Note how we
158+
add an extra field to each `Marker` that is then used to search on.
159+
160+
161+
```{code-cell} ipython3
162+
from folium import Map, FeatureGroup, Marker, Icon
163+
from folium.plugins import Search
164+
165+
m = Map((45.5236, -122.5), tiles="carto db positron")
166+
167+
fg = FeatureGroup().add_to(m)
168+
Marker([45.5236, -122.7], icon=Icon(color="red"), title="red").add_to(fg)
169+
Marker([45.5236, -122.5], icon=Icon(color="blue"), title="blue").add_to(fg)
170+
Marker([45.5236, -122.3], icon=Icon(color="green"), title="green").add_to(fg)
171+
172+
Search(fg, search_label="title").add_to(m)
173+
174+
m
175+
```

0 commit comments

Comments
 (0)