Skip to content

Commit 2f8595a

Browse files
Merge pull request #124 from eoda-dev/feature/backend-dependencies
Feature/backend dependencies
2 parents f046bec + 13dc8bc commit 2f8595a

21 files changed

+4168
-3120
lines changed

.github/workflows/pytest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on: [push]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
98
strategy:
109
matrix:
@@ -22,9 +21,10 @@ jobs:
2221
- name: Install Poetry and pytest
2322
run: pip install poetry pytest
2423
- name: Install package
25-
run: poetry install
24+
run: |
25+
poetry lock
26+
poetry install -E ipywidget -E shiny
2627
- name: Test package
2728
run: |
2829
poetry run pytest
2930
poetry run pytest --doctest-modules maplibre --ignore maplibre/ipywidget.py
30-

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,31 @@
1111
MapLibre for Python provides Python bindings for [MapLibre GL JS](https://github.com/maplibre/maplibre-gl-js).
1212
Furthermore, [Deck.GL Layers](https://deck.gl/docs/api-reference/layers) can be mixed with [MapLibre Layers](https://maplibre.org/maplibre-style-spec/layers/).
1313

14-
It integrates seamlessly into [Shiny for Python](https://github.com/posit-dev/py-shiny) and [Jupyter](https://jupyter.org/).
14+
It integrates seamlessly into [Shiny for Python](https://github.com/posit-dev/py-shiny), [Marimo](https://marimo.io/) and [Jupyter](https://jupyter.org/).
1515

1616
## Installation
1717

1818
```bash
1919
# Stable
20-
pip install maplibre
20+
pip install maplibre # minimal
21+
22+
pip install "maplibre[shiny]" # shiny bindings
23+
24+
pip install "maplibre[ipywidget]" # marimo and jupyter bindings
2125

2226
pip install "maplibre[all]"
2327

24-
# Dev
28+
uv add maplibre
29+
30+
uv add "maplibre[all]"
31+
32+
# Unstable
2533
pip install git+https://github.com/eoda-dev/py-maplibregl@dev
2634

2735
pip install "maplibre[all] @ git+https://github.com/eoda-dev/py-maplibregl@dev"
2836

37+
uv add "git+https://github.com/eoda-dev/py-maplibregl@dev[all]"
38+
2939
# Conda
3040
conda install -c conda-forge maplibre
3141
```
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import marimo
2+
3+
__generated_with = "0.10.17"
4+
app = marimo.App(width="medium")
5+
6+
7+
@app.cell
8+
def _():
9+
import marimo as mo
10+
from maplibre import Layer, LayerType, MapOptions
11+
from maplibre.sources import GeoJSONSource, VectorTileSource
12+
from maplibre.ipywidget import MapWidget as Map
13+
from maplibre.controls import NavigationControl, ScaleControl, ControlPosition
14+
from maplibre.expressions import color_match_expr
15+
Map._use_message_queue = False
16+
return (
17+
ControlPosition,
18+
GeoJSONSource,
19+
Layer,
20+
LayerType,
21+
Map,
22+
MapOptions,
23+
NavigationControl,
24+
ScaleControl,
25+
VectorTileSource,
26+
color_match_expr,
27+
mo,
28+
)
29+
30+
31+
@app.cell
32+
def _(VectorTileSource):
33+
blm_sma_source= VectorTileSource(
34+
tiles=["https://tiles.lightfield.ag/blm_national_surface_management_data/{z}/{x}/{y}.mvt"],
35+
min_zoom=0,
36+
max_zoom=9
37+
)
38+
return (blm_sma_source,)
39+
40+
41+
@app.cell
42+
def _(color_match_expr):
43+
fill_color = color_match_expr("ADMIN_DEPT_CODE", ["PVT", "DOD", "DOE", "DOI", "USDA"], "viridis")
44+
# fill_color
45+
return (fill_color,)
46+
47+
48+
@app.cell
49+
def _(Layer, LayerType, blm_sma_source, fill_color):
50+
blm_sma_layer = Layer(
51+
id="blm-sma",
52+
type=LayerType.FILL,
53+
source=blm_sma_source,
54+
source_layer="blm_national_surface_management_data"
55+
).set_paint_props(fill_color=fill_color, fill_outline_color="steelblue")
56+
return (blm_sma_layer,)
57+
58+
59+
@app.cell
60+
def _(Map, NavigationControl, blm_sma_layer):
61+
m = Map(controls=[NavigationControl()], layers=[blm_sma_layer])
62+
return (m,)
63+
64+
65+
@app.cell
66+
def _(m, mo):
67+
widget = mo.ui.anywidget(m)
68+
return (widget,)
69+
70+
71+
@app.cell
72+
def _(widget):
73+
widget
74+
return
75+
76+
77+
@app.cell
78+
def _(color_match_expr, m, mo):
79+
mo.ui.dropdown(
80+
["viridis", "YlOrRd", "Blues"],
81+
label="cmap",
82+
on_change=lambda x: m.set_paint_property(
83+
"blm-sma",
84+
"fill-color",
85+
color_match_expr("ADMIN_DEPT_CODE", ["PVT", "DOD", "DOE", "DOI", "USDA"], cmap=x)
86+
)
87+
)
88+
return
89+
90+
91+
@app.cell
92+
def _(widget):
93+
widget.view_state
94+
return
95+
96+
97+
if __name__ == "__main__":
98+
app.run()

docs/api/basemaps.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@
22
options:
33
docstring_section_style: list
44

5+
::: maplibre.basemaps.OpenFreeMap
6+
options:
7+
docstring_section_style: list
8+
9+
::: maplibre.basemaps.MapTiler
10+
options:
11+
docstring_section_style: list
12+
513
::: maplibre.basemaps.construct_basemap_style

docs/changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog for MapLibre for Python
22

3+
## maplibre v0.3.0 (unreleased)
4+
5+
* Add 3d-buildings example
6+
* Add `basemaps.OpenFreeMap`
7+
* Make `shiny` and `htmltools` dependency optional
8+
* Make `anywidget` dependency optional
9+
* Add Mapbox Draw Ipywidget callbacks for
10+
* `draw.create`
11+
* `draw.update`
12+
* `draw.delete`
13+
314
## maplibre v0.2.8
415

516
* Add Mapbox Draw Shiny callbacks for

docs/index.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ It integrates seamlessly into [Shiny for Python](https://github.com/posit-dev/py
88

99
```bash
1010
# Stable
11-
pip install maplibre
11+
pip install maplibre # minimal
1212

1313
pip install "maplibre[all]"
1414

15-
# Dev
15+
pip install "maplibre[shiny]" # shiny bindings
16+
17+
pip install "maplibre[ipywidget]" # marimo and jupyter bindings
18+
19+
uv add "maplibre[all]"
20+
21+
# Unstable
1622
pip install git+https://github.com/eoda-dev/py-maplibregl@dev
1723
```
1824

examples/basemaps/carto.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from maplibre import Map, MapOptions
2+
from maplibre.basemaps import Carto
3+
4+
m = Map(MapOptions(style=Carto.DARK_MATTER_NOLABELS))
5+
m.save(preview=True)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from maplibre import Map, MapOptions
2+
from maplibre.basemaps import OpenFreeMap
3+
from maplibre.controls import NavigationControl
4+
5+
threed_buildings = {
6+
"id": "3d-buildings",
7+
"source": "openmaptiles",
8+
"source-layer": "building",
9+
"type": "fill-extrusion",
10+
"min-zoom": 15,
11+
"paint": {
12+
"fill-extrusion-color": [
13+
"interpolate",
14+
["linear"],
15+
["get", "render_height"],
16+
0,
17+
"lightgray",
18+
200,
19+
"royalblue",
20+
400,
21+
"lightblue",
22+
],
23+
"fill-extrusion-height": [
24+
"interpolate",
25+
["linear"],
26+
["zoom"],
27+
15,
28+
0,
29+
16,
30+
["get", "render_height"],
31+
],
32+
"fill-extrusion-base": [
33+
"case",
34+
[">=", ["get", "zoom"], 16],
35+
["get", "render_min_height"],
36+
0,
37+
],
38+
},
39+
}
40+
41+
m = Map(
42+
MapOptions(style=OpenFreeMap.BRIGHT, center=(-74.0066, 40.7135), zoom=16, pitch=45, bearing=-17),
43+
controls=[NavigationControl()],
44+
)
45+
m.add_layer(threed_buildings)
46+
m.save(preview=True)

examples/basemaps/openfreemap.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from maplibre import Map, MapOptions
2+
from maplibre.basemaps import OpenFreeMap
3+
4+
m = Map(MapOptions(style=OpenFreeMap.BRIGHT))
5+
m.save(preview=True)

0 commit comments

Comments
 (0)