Skip to content

Commit adb8c31

Browse files
author
Stefan Kuethe
committed
Add draw control
1 parent cfa8e99 commit adb8c31

File tree

6 files changed

+139
-5
lines changed

6 files changed

+139
-5
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Provides Python bindings for [OpenLayers](https://openlayers.org/), a high-perfo
1414

1515
Pull tiles from OSM, CartoDB, MapTiler and any other XYZ source.
1616

17-
1817
### Vector Layers
1918

2019
Render vector data from GeoJSON, TopoJSON, KML, GML and other formats.
@@ -31,11 +30,13 @@ Render large data sets using WebGL.
3130

3231
Render PMTiles from vector and raster sources.
3332

33+
<a href="https://eoda-dev.github.io/py-openlayers/marimo/pmtiles-vector.html" target="_blank">PMTiles vector source notebook<a>
34+
3435
### Interactions
3536

3637
Drag and drop GPX, GeoJSON, KML or TopoJSON files on to the map. Modify, draw and select features.
3738

38-
<a href="https://eoda-dev.github.io/py-openlayers/marimo/drag-and-drop.html" target="_blank">Drag-and-drop example notebook<a>
39+
<a href="https://eoda-dev.github.io/py-openlayers/marimo/drag-and-drop.html" target="_blank">Drag-and-drop notebook<a>
3940

4041
### GeoPandas Extension
4142

@@ -73,6 +74,8 @@ m = ol.Map()
7374
m.save()
7475
```
7576

77+
<a href="https://eoda-dev.github.io/py-openlayers/marimo/getting-started.html" target="_blank">Getting started notebook<a>
78+
7679
## Documentation
7780

7881
[python-openlayers docs](https://eoda-dev.github.io/py-openlayers/)

_obsolete/geocoding-control.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
3+
import marimo
4+
5+
__generated_with = "0.13.2"
6+
app = marimo.App(width="medium")
7+
8+
9+
@app.cell
10+
def _():
11+
import marimo as mo
12+
import openlayers as ol
13+
return mo, ol
14+
15+
16+
@app.cell(hide_code=True)
17+
def _(mo):
18+
mo.md("""You must set your __MapTiler API key__ to use the geocoding control""")
19+
return
20+
21+
22+
@app.cell
23+
def _():
24+
import os
25+
26+
os.environ["MAPTILER_API_KEY"] = ""
27+
return (os,)
28+
29+
30+
@app.cell
31+
def _(ol):
32+
m = ol.MapWidget()
33+
return (m,)
34+
35+
36+
@app.cell
37+
def _(m, ol, os):
38+
if os.environ["MAPTILER_API_KEY"]:
39+
m.add_control(ol.MapTilerGeocodingControl(api_key=os.environ["MAPTILER_API_KEY"]))
40+
return
41+
42+
43+
@app.cell
44+
def _(m):
45+
m
46+
return
47+
48+
49+
@app.cell
50+
def _(ol):
51+
ol.constants.MAPTILER_API_KEY_ENV_VAR
52+
return
53+
54+
55+
@app.cell
56+
def _(ol, os):
57+
os.environ[ol.constants.MAPTILER_API_KEY_ENV_VAR]
58+
return
59+
60+
61+
@app.cell
62+
def _():
63+
return
64+
65+
66+
if __name__ == "__main__":
67+
app.run()

marimo/drag-and-drop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def _():
1717
def _(mo):
1818
mo.md(
1919
r"""
20-
## Drag and drop GPX, GeoJSON, KML or TopoJSON files on to the map.
20+
## Drag and drop GPX, GeoJSON, KML or TopoJSON files on to the map
2121
2222
Download sample files from here:
2323

marimo/draw-control.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
3+
import marimo
4+
5+
__generated_with = "0.13.2"
6+
app = marimo.App(width="medium")
7+
8+
9+
@app.cell
10+
def _():
11+
import marimo as mo
12+
import openlayers as ol
13+
return mo, ol
14+
15+
16+
@app.cell
17+
def _(ol):
18+
m = ol.MapWidget(controls=[ol.DrawControl()])
19+
return (m,)
20+
21+
22+
@app.cell
23+
def _(m, mo):
24+
widget = mo.ui.anywidget(m)
25+
return (widget,)
26+
27+
28+
@app.cell
29+
def _(widget):
30+
widget
31+
return
32+
33+
34+
@app.cell
35+
def _(widget):
36+
widget.value["features"]
37+
return
38+
39+
40+
@app.cell
41+
def _():
42+
return
43+
44+
45+
if __name__ == "__main__":
46+
app.run()

marimo/export-notebooks.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
output_folder=${1:-dist}
3-
files=("getting-started.py" "pmtiles-vector.py" "drag-and-drop.py")
3+
files=("getting-started.py" "pmtiles-vector.py" "drag-and-drop.py" "draw-control.py")
44

55
for file in "${files[@]}"; do
66
without_extension="${file%.*}"

marimo/pmtiles-vector.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,27 @@
88

99
@app.cell
1010
def _():
11+
import marimo as mo
1112
import openlayers as ol
13+
return mo, ol
14+
15+
16+
@app.cell
17+
def _():
1218
from openlayers.styles import default_style
13-
return default_style, ol
19+
return (default_style,)
20+
21+
22+
@app.cell(hide_code=True)
23+
def _(mo):
24+
mo.md(
25+
r"""
26+
# PMTiles vector source
27+
28+
See also [pmtiles/openlayers](https://docs.protomaps.com/pmtiles/openlayers)
29+
"""
30+
)
31+
return
1432

1533

1634
@app.cell

0 commit comments

Comments
 (0)