Skip to content

Commit 40e08da

Browse files
author
Stefan Kuethe
committed
Update docstrings
1 parent 91d71c6 commit 40e08da

File tree

3 files changed

+36
-37
lines changed

3 files changed

+36
-37
lines changed

notebooks/modify-interaction.ipynb

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
},
166166
{
167167
"cell_type": "code",
168-
"execution_count": 12,
168+
"execution_count": 4,
169169
"id": "7ad0cc6a-c508-44b6-83d1-8f03eb6a7e72",
170170
"metadata": {},
171171
"outputs": [],
@@ -178,22 +178,22 @@
178178
},
179179
{
180180
"cell_type": "code",
181-
"execution_count": 13,
181+
"execution_count": 5,
182182
"id": "4241d0b7-ab89-4cbd-a60b-988b6896bbd7",
183183
"metadata": {},
184184
"outputs": [
185185
{
186186
"data": {
187187
"application/vnd.jupyter.widget-view+json": {
188-
"model_id": "1b812264d47748e59f07b996e9c18a8f",
188+
"model_id": "76dd6da729614de0864befd370d3034e",
189189
"version_major": 2,
190190
"version_minor": 1
191191
},
192192
"text/plain": [
193193
"MapWidget(calls=[{'method': 'addLayer', 'args': ({'id': 'geopandas', 'source': {'@@geojson': {'type': 'Feature…"
194194
]
195195
},
196-
"execution_count": 13,
196+
"execution_count": 5,
197197
"metadata": {},
198198
"output_type": "execute_result"
199199
}
@@ -204,18 +204,28 @@
204204
},
205205
{
206206
"cell_type": "code",
207-
"execution_count": 15,
207+
"execution_count": 7,
208208
"id": "8ca96e77-dbad-4958-8bac-4b92cbd1acbb",
209209
"metadata": {},
210210
"outputs": [
211211
{
212212
"data": {
213213
"text/plain": [
214-
"{'draw': ['{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-89.9069020159181,-3.410484493977961]},\"properties\":null}',\n",
215-
" '{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-32.14370731485719,-25.10699448813274]},\"properties\":null}']}"
214+
"{'draw': [{'type': 'Feature',\n",
215+
" 'geometry': {'type': 'Point',\n",
216+
" 'coordinates': [-120.47218141829924, -14.347436260705265]},\n",
217+
" 'properties': None},\n",
218+
" {'type': 'Feature',\n",
219+
" 'geometry': {'type': 'Point',\n",
220+
" 'coordinates': [-115.55066021198198, -32.32384479303445]},\n",
221+
" 'properties': None},\n",
222+
" {'type': 'Feature',\n",
223+
" 'geometry': {'type': 'Point',\n",
224+
" 'coordinates': [-91.20204716358482, -21.2491496568545]},\n",
225+
" 'properties': None}]}"
216226
]
217227
},
218-
"execution_count": 15,
228+
"execution_count": 7,
219229
"metadata": {},
220230
"output_type": "execute_result"
221231
}
@@ -226,22 +236,10 @@
226236
},
227237
{
228238
"cell_type": "code",
229-
"execution_count": 18,
239+
"execution_count": null,
230240
"id": "e80b179d-9ce6-410c-b28b-9d232e478685",
231241
"metadata": {},
232-
"outputs": [
233-
{
234-
"ename": "TypeError",
235-
"evalue": "string indices must be integers, not 'str'",
236-
"output_type": "error",
237-
"traceback": [
238-
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
239-
"\u001b[31mTypeError\u001b[39m Traceback (most recent call last)",
240-
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[18]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mm\u001b[49m\u001b[43m.\u001b[49m\u001b[43mfeatures\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mdraw\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[32;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtype\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\n",
241-
"\u001b[31mTypeError\u001b[39m: string indices must be integers, not 'str'"
242-
]
243-
}
244-
],
242+
"outputs": [],
245243
"source": [
246244
"m.features[\"draw\"][0][\"type\"]"
247245
]

src/openlayers/map.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,21 @@ def set_view_from_source(self, layer_id: str) -> None:
7272
self.add_call("setViewFromSource", layer_id)
7373

7474
def set_zoom(self, zoom_level: float | int) -> None:
75-
"""Set the zoom level ot the map view
75+
"""Set the zoom level of the view
7676
7777
Args:
78-
zoom_level (float | int): The zoom level of the view
78+
zoom_level (float | int): The zoom level
7979
"""
8080
self.add_view_call("setZoom", zoom_level)
8181

82-
def set_center(self, lonlat: tuple[float, float]) -> None:
83-
"""Set the center of the map view
82+
def set_center(self, lon: float = 0, lat: float = 0) -> None:
83+
"""Set the center of the view
8484
8585
Args:
86-
lonlat (tuple[float, float]): The centerpoint of the map as `(lon, lat)` pair
86+
lon (float): The center's longitude
87+
lat (float): The center's latitude
8788
"""
88-
self.add_view_call("setCenter", lonlat)
89+
self.add_view_call("setCenter", (lon, lat))
8990

9091
def add_layer(self, layer: LayerT | LayerLike | dict) -> None:
9192
"""Add a layer to the map

src/openlayers/models/view.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from pydantic import Field
44

5-
# from ..abstracts import MyBaseModel
65
from .core import OLBaseModel
76

87

@@ -17,19 +16,20 @@ def from_epsg(code: int) -> str:
1716

1817

1918
class View(OLBaseModel):
20-
"""View object
19+
"""A View object represents a simple 2D view of the map
2120
2221
Note:
2322
See [module-ol_View-View.html](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html) for details.
2423
2524
Attributes:
26-
center (tuple[float, float]): The centerpoint of the map as `(lon, lat)` pair
27-
zoom (float | int): The zoom level of the map
28-
projection (str): ...
29-
rotation (float | int): ...
30-
extent (tuple[float, float, float, float] | list[float, float, float, float]): ...
31-
min_zoom (float | int): The minimum zoom level of the map
32-
max_zoom (float | int): The maximum zoom level of the map
25+
center (tuple[float, float]): The center for the view as (lon, lat) pair
26+
zoom (float | int): The Zoom level used to calculate the resolution for the view
27+
projection (str): The projection
28+
rotation (float | int): The rotation for the view in radians (positive rotation clockwise, 0 means north).
29+
extent (tuple[float, float, float, float] | list[float, float, float, float]): The extent that constrains the view,
30+
in other words, nothing outside of this extent can be visible on the map
31+
min_zoom (float | int): The minimum zoom level used to determine the resolution constraint
32+
max_zoom (float | int): The maximum zoom level used to determine the resolution constraint
3333
"""
3434

3535
center: tuple[float, float] | None = (0, 0)

0 commit comments

Comments
 (0)