Skip to content

Commit 9dfa34f

Browse files
committed
Rename map_options to options
1 parent 467b2b8 commit 9dfa34f

File tree

8 files changed

+12
-14
lines changed

8 files changed

+12
-14
lines changed

examples/standalone/icons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
m = ol.Map(layers=[BasemapLayer.carto(), icon_layer])
3636
m.add_tooltip()
3737
m.add_control(ol.controls.OverviewMapControl())
38-
print(m.map_options)
38+
print(m.options)
3939
m.save()

src/openlayers/anywidget.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ class MapWidget(Map, AnyWidget):
2424
height = traitlets.Unicode().tag(sync=True)
2525
calls = traitlets.List().tag(sync=True)
2626
created = traitlets.Bool().tag(sync=True)
27-
map_options = traitlets.Dict().tag(sync=True)
28-
# map_clicked = traitlets.Dict().tag(sync=True)
27+
options = traitlets.Dict().tag(sync=True)
28+
# clicked = traitlets.Dict().tag(sync=True)
2929
view_state = traitlets.Dict().tag(sync=True)
3030
metadata = traitlets.Dict().tag(sync=True)
31-
# debug_data = traitlets.Dict().tag(sync=True)
3231

3332
def __init__(
3433
self,

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/map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(
3535
if layers is None:
3636
layers = [TileLayer(id="osm", source=OSM())]
3737

38-
self.map_options = MapOptions(
38+
self.options = MapOptions(
3939
view=view, layers=layers, controls=controls
4040
).model_dump()
4141

@@ -180,7 +180,7 @@ def set_style(self, layer_id: str, style: FlatStyle | dict) -> None:
180180

181181
def to_html(self, **kwargs) -> str:
182182
"""Render map to HTML"""
183-
data = self.map_options | dict(calls=self.calls)
183+
data = self.options | dict(calls=self.calls)
184184
return HTMLTemplate().render(data=data, **kwargs)
185185

186186
def save(self, path: Path | str = None, preview: bool = True, **kwargs) -> str:

srcjs/ipywidget-ts/anywidget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function render({ model, el }: { model: AnyModel; el: HTMLElement }): void {
3030
mapElement.id = "ol-map-widget";
3131
mapElement.style.height = height;
3232
// ...
33-
const mapOptions = model.get("map_options");
33+
const mapOptions = model.get("options");
3434
console.log("mapOptions", mapOptions);
3535
const mapWidget = (window as any).anywidgetMapWidget = new MapWidget(mapElement, mapOptions, model);
3636

@@ -58,7 +58,7 @@ function render({ model, el }: { model: AnyModel; el: HTMLElement }): void {
5858
map.on("click", (e) => {
5959
const info = parseClickEvent(e);
6060
console.log(info);
61-
model.set("map_clicked", info);
61+
model.set("clicked", info);
6262
model.save_changes();
6363
});
6464
*/

srcjs/ipywidget-ts/standalone.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import { MyMapOptions } from ".";
66
const MAP_CONTAINER = "map";
77

88
(window as any).renderOLMapWidget = (mapOptions: MyMapOptions) => {
9-
// mapOptions.viewOptions = mapOptions.viewOptions || { center: [0, 0] };
109
console.log("render OL-MapWidget", mapOptions);
1110
const mapElement = document.getElementById(MAP_CONTAINER) || document.createElement("div");
1211
console.log("el", mapElement);
1312
const mapWidget = (window as any).olMapWidget = new MapWidget(mapElement, mapOptions);
14-
const map = mapWidget.getMap();
13+
// const map = mapWidget.getMap();
1514

1615
console.log("calls", mapOptions.calls);
1716
if (mapOptions.calls) {

tests/test_export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ def test_to_html() -> None:
2020

2121
def _test_save_html() -> None:
2222
m = Map(View())
23-
print(m.map_options)
23+
print(m.options)
2424
path = m.save(preview=True)
2525
print("path", path)

tests/test_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_map() -> None:
1010
m = Map(view)
1111

1212
# Assert
13-
print(m.map_options)
14-
assert m.map_options["view"] == view.model_dump()
13+
print(m.options)
14+
assert m.options["view"] == view.model_dump()
1515

1616
assert m.initial_view.center == (2, 2)

0 commit comments

Comments
 (0)