Skip to content

Commit

Permalink
feat: support leaflet maps in the theme (#1112)
Browse files Browse the repository at this point in the history
Fix #1110
  • Loading branch information
12rambau authored Jan 9, 2023
1 parent 6b05492 commit 30a0b34
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
14 changes: 13 additions & 1 deletion docs/examples/pydata.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ data = xr.DataArray(
data
```

## `jupyter-sphinx`
## jupyter-sphinx

Another common library is `jupyter-sphinx`.
This section demonstrates a subset of functionality above to make sure it behaves as expected.
Expand All @@ -103,3 +103,15 @@ data = rng.standard_normal((3, 100))
fig, ax = plt.subplots()
ax.scatter(data[0], data[1], c=data[2], s=3)
```

## ipyleaflet

`ipyleaflet` is a **Jupyter**/**Leaflet** bridge enabling interactive maps in the Jupyter notebook environment. this demonstrate how you can integrate maps in your documentation.

```{jupyter-execute}
from ipyleaflet import Map, basemaps
# display a map centered on France
m = Map(basemap=basemaps.Esri.WorldImagery, zoom=5, center=[46.21, 2.21])
m
```
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ doc = [
"sphinx-togglebutton",
# Install nbsphinx in case we want to test it locally even though we can't load
# it at the same time as MyST-NB.
"nbsphinx"
"nbsphinx",
"ipyleaflet",
]
test = [
"pytest",
Expand Down
14 changes: 14 additions & 0 deletions src/pydata_sphinx_theme/assets/styles/extensions/_leaflet.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* style for the various mapping libs based on leaflet (folium, geemap, ipyleaflet)
* mainly ensure the good display of the maps in both themes and avoid the customization
* of the tiles
*/

/**
* avoid border override from pydata-sphinx-theme
* minimal selctor to get the priority
*/
html[data-theme="dark"] .bd-content img.leaflet-tile.leaflet-tile-loaded {
border-radius: 0;
padding: 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
@import "./extensions/sphinx_panels";
@import "./extensions/togglebutton";
@import "./extensions/notebooks";
@import "./extensions/leaflet";

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

0 comments on commit 30a0b34

Please sign in to comment.