Skip to content

Commit c579168

Browse files
author
Stefan Kuethe
committed
Add ZoomToExtentControl
1 parent 6179f33 commit c579168

File tree

13 files changed

+201
-129
lines changed

13 files changed

+201
-129
lines changed

docs/api/layers.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
11
# Layers
22

3+
::: openlayers.layers.Layer
4+
5+
::: openlayers.layers.VectorLayer
6+
7+
::: openlayers.layers.VectorTileLayer
8+
9+
::: openlayers.layers.TileLayer
10+
11+
::: openlayers.layers.WebGLVectorLayer
12+
13+
::: openlayers.layers.WebGLVectorTileLayer
14+
15+
::: openlayers.layers.WebGLTileLayer
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# See https://openlayers.org/en/latest/examples/image-vector-layer.html
2+
# data: https://openlayers.org/data/vector/ecoregions.json

examples/standalone/polygons.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
m.add_control(ol.controls.InfoBox(
1515
html="PyOL",
1616
css_text="right: .5em; top: .5em; background: white; padding: 5px;"))
17+
m.add_control(ol.controls.ZoomToExtentControl())
1718
m.save()

src/openlayers/__future__/sources.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from ..models.sources import VectorSource
2+
3+
4+
class GeoJSONSource(VectorSource):
5+
@property
6+
def type(self) -> str:
7+
return "VectorSource"

src/openlayers/controls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
ZoomSliderControl,
1212
ZoomControl,
1313
RotateControl,
14+
ZoomToExtentControl,
1415
DrawControl
1516
)
1617

src/openlayers/express.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ def to_map(self, *args, **kwargs) -> Map:
3434
return m
3535

3636

37-
# class VectorLayer(LayerLike): ...
38-
39-
# class GPXLayer(VectorLayer): ...
40-
41-
# class GeoJSONLayer(VectorLayer): ...
42-
43-
# class TopoJSONLayer(VectorLayer): ...
44-
45-
4637
class Vector(LayerLike):
4738
def __init__(
4839
self,

src/openlayers/js/openlayers.anywidget.js

Lines changed: 75 additions & 57 deletions
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: 75 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/openlayers/layers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@
1818
"WebGLTileLayer",
1919
"WebGLVectorLayer",
2020
"BasemapLayer",
21+
"VectorTileLayer",
22+
"WebGLVectorTileLayer"
2123
]

src/openlayers/models/controls.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# -- Base control
1414
class Control(OLBaseModel):
15-
id: str | None = None # = Field(default_factory=lambda x: str(uuid4()))
15+
id: str | None = None
1616

1717
@field_validator("id")
1818
def validate_id(cls, v) -> str:
@@ -52,13 +52,22 @@ class ZoomControl(Control):
5252
class RotateControl(Control): ...
5353

5454

55+
class ZoomToExtentControl(Control):
56+
extent: (
57+
tuple[float | float | float | float]
58+
| list[float | float | float | float]
59+
| None
60+
) = None
61+
62+
5563
# --- Custom controls
5664
class InfoBox(Control):
5765
html: str
5866
css_text: str = Field(
5967
"top: 65px; left: .5em; padding: 5px;", serialization_alias="cssText"
6068
)
6169

70+
6271
class DrawControl(Control): ...
6372

6473

@@ -71,6 +80,7 @@ class DrawControl(Control): ...
7180
OverviewMapControl,
7281
ZoomControl,
7382
RotateControl,
83+
ZoomToExtentControl,
7484
InfoBox,
75-
DrawControl
85+
DrawControl,
7686
]

0 commit comments

Comments
 (0)