Skip to content

Commit 30a0b34

Browse files
authored
feat: support leaflet maps in the theme (#1112)
Fix #1110
1 parent 6b05492 commit 30a0b34

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

docs/examples/pydata.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ data = xr.DataArray(
8989
data
9090
```
9191

92-
## `jupyter-sphinx`
92+
## jupyter-sphinx
9393

9494
Another common library is `jupyter-sphinx`.
9595
This section demonstrates a subset of functionality above to make sure it behaves as expected.
@@ -103,3 +103,15 @@ data = rng.standard_normal((3, 100))
103103
fig, ax = plt.subplots()
104104
ax.scatter(data[0], data[1], c=data[2], s=3)
105105
```
106+
107+
## ipyleaflet
108+
109+
`ipyleaflet` is a **Jupyter**/**Leaflet** bridge enabling interactive maps in the Jupyter notebook environment. this demonstrate how you can integrate maps in your documentation.
110+
111+
```{jupyter-execute}
112+
from ipyleaflet import Map, basemaps
113+
114+
# display a map centered on France
115+
m = Map(basemap=basemaps.Esri.WorldImagery, zoom=5, center=[46.21, 2.21])
116+
m
117+
```

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ doc = [
6565
"sphinx-togglebutton",
6666
# Install nbsphinx in case we want to test it locally even though we can't load
6767
# it at the same time as MyST-NB.
68-
"nbsphinx"
68+
"nbsphinx",
69+
"ipyleaflet",
6970
]
7071
test = [
7172
"pytest",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* style for the various mapping libs based on leaflet (folium, geemap, ipyleaflet)
3+
* mainly ensure the good display of the maps in both themes and avoid the customization
4+
* of the tiles
5+
*/
6+
7+
/**
8+
* avoid border override from pydata-sphinx-theme
9+
* minimal selctor to get the priority
10+
*/
11+
html[data-theme="dark"] .bd-content img.leaflet-tile.leaflet-tile-loaded {
12+
border-radius: 0;
13+
padding: 0;
14+
}

src/pydata_sphinx_theme/assets/styles/pydata-sphinx-theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
@import "./extensions/sphinx_panels";
7070
@import "./extensions/togglebutton";
7171
@import "./extensions/notebooks";
72+
@import "./extensions/leaflet";
7273

7374
// Page-specific CSS
7475
@import "./pages/search";

0 commit comments

Comments
 (0)