Skip to content

Commit 438f590

Browse files
BalantahSebastian Balantapre-commit-ci[bot]
authored
docs: add DivIcon text label example to icons guide (#2227)
* docs: add DivIcon text label example to icons guide * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Sebastian Balanta <balantah@javerianacali.edu.co> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent f0c6464 commit 438f590

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

docs/user_guide/ui_elements/icons.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,33 @@ folium.Marker(
5454
5555
m
5656
```
57+
58+
## Text labels with DivIcon
59+
60+
`DivIcon` allows you to add text directly on the map using an HTML `div` element.
61+
This is useful when you want a visible label at a specific location, without
62+
relying on tooltips or popups that only appear on interaction.
63+
64+
```{code-cell} ipython3
65+
m = folium.Map(location=[41, -71], zoom_start=6)
66+
67+
folium.Marker(
68+
location=[41, -71],
69+
icon=folium.DivIcon(
70+
html='<div style="font-size: 14px; color: black; font-weight: bold;">New York</div>',
71+
icon_size=(100, 36),
72+
icon_anchor=(50, 18),
73+
),
74+
).add_to(m)
75+
76+
folium.Marker(
77+
location=[42.36, -71.06],
78+
icon=folium.DivIcon(
79+
html='<div style="font-size: 12px; color: navy;">Boston</div>',
80+
icon_size=(80, 30),
81+
icon_anchor=(40, 15),
82+
),
83+
).add_to(m)
84+
85+
m
86+
```

0 commit comments

Comments
 (0)