Skip to content

Commit b1e0ba3

Browse files
Merge pull request #12 from eoda-dev/refactor/method-call
Refactor/method call
2 parents 489b41a + c892969 commit b1e0ba3

File tree

15 files changed

+87
-24
lines changed

15 files changed

+87
-24
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* linguist-vendored
2+
*.py linguist-vendored=false

examples/standalone/gpd_multiple_layers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import openlayers as ol
2-
from openlayers.basemaps import BasemapLayer
2+
from openlayers.basemaps import CartoBasemapLayer
33
from openlayers.styles import FlatStyle
44

55
# url = "https://openlayers.org/en/v4.6.5/examples/data/geojson/countries.geojson"
@@ -12,6 +12,6 @@
1212
# countries_layer = gpd.ol.to_layer(style=style, opacity=0.5)
1313
countries_layer = gpd.ol.color_category("name").to_layer(opacity=0.5, webgl=False)
1414

15-
m = ol.Map(layers=[BasemapLayer.carto()])
15+
m = ol.Map(layers=[CartoBasemapLayer()])
1616
m.add_layer(countries_layer)
1717
m.save()

marimo/select-features.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
ol.__version__
14+
return mo, ol
15+
16+
17+
@app.cell
18+
def _():
19+
data = "https://maplibre.org/maplibre-gl-js/docs/assets/us_states.geojson"
20+
return (data,)
21+
22+
23+
@app.cell
24+
def _(data, ol):
25+
vector = ol.VectorLayer(
26+
# background="gray",
27+
source=ol.VectorSource(url=data),
28+
fit_bounds=True
29+
)
30+
return (vector,)
31+
32+
33+
@app.cell
34+
def _(ol, vector):
35+
m = ol.MapWidget(layers=[ol.basemaps.CartoBasemapLayer(), vector])
36+
m.add_tooltip()
37+
m.add_select_interaction()
38+
return (m,)
39+
40+
41+
@app.cell
42+
def _(m, mo):
43+
w = mo.ui.anywidget(m)
44+
return (w,)
45+
46+
47+
@app.cell
48+
def _(w):
49+
w
50+
return
51+
52+
53+
@app.cell
54+
def _(w):
55+
[feat["properties"] for feat in w.value["features"]["selected"] if w.value["features"]]
56+
return
57+
58+
59+
@app.cell
60+
def _():
61+
return
62+
63+
64+
if __name__ == "__main__":
65+
app.run()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "openlayers"
3-
version = "0.1.5"
3+
version = "0.1.6-rc.1"
44
description = "Python Bindings for OpenLayersJS"
55
readme = "README.md"
66
authors = [{ name = "Stefan Kuethe", email = "[email protected]" }]

src/openlayers/anywidget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(
4949
AnyWidget.__init__(self, height=height, **kwargs)
5050

5151
def add_call(self, method_name: str, *args: Any) -> None:
52-
call = dict(method=method_name, args=args)
52+
call = dict(method_name=method_name, args=args)
5353
if self.created:
5454
return self.send(call)
5555

src/openlayers/js/openlayers.anywidget.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/openlayers/js/openlayers.standalone.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/openlayers/map.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ def initial_view_state(self):
4545

4646
# 'apply_call_to_map'
4747
def add_call(self, method_name: str, *args: Any) -> None:
48-
call = dict(method=method_name, args=args)
48+
call = dict(method_name=method_name, args=args)
4949
self.calls.append(call)
5050

5151
# 'apply_call_to_layer'
5252
def add_layer_call(self, layer_id: str, method_name: str, *args: Any):
53-
layer_call = dict(method=method_name, args=args)
53+
layer_call = dict(method_name=method_name, args=args)
5454
self.add_call("applyCallToLayer", layer_id, layer_call)
5555

5656
def add_view_call(self, method_name: str, *args: Any) -> None:
57-
view_call = dict(method=method_name, args=args)
57+
view_call = dict(method_name=method_name, args=args)
5858
self.add_call("applyCallToView", view_call)
5959

6060
def fit_bounds(self, bounds: tuple[float, float, float, float]) -> None:

src/openlayers/models/controls.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Control(OLBaseModel):
1717
id: str | None = None
1818

1919
@field_validator("id")
20+
@classmethod
2021
def validate_id(cls, v) -> str:
2122
if v is None:
2223
return uuid4().hex[0:10]
@@ -83,11 +84,7 @@ class ZoomToExtentControl(Control):
8384
Provides a button that changes the map view to a specific extent when clicked.
8485
"""
8586

86-
extent: (
87-
tuple[float | float | float | float]
88-
| list[float | float | float | float]
89-
| None
90-
) = None
87+
extent: tuple[float, float, float, float] | list[float] | None = None
9188

9289

9390
# --- MapTiler

src/openlayers/models/map_options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class MapOptions(BaseModel):
1818
layers: list[dict | LayerT | LayerLike] | None = None
1919

2020
@field_validator("layers")
21+
@classmethod
2122
def validate_layers(cls, layers) -> list[dict | LayerT]:
2223
layers = [
2324
layer.model if isinstance(layer, LayerLike) else layer for layer in layers

0 commit comments

Comments
 (0)