Skip to content

Commit 5e78565

Browse files
authored
feat: Provide default controls for Map (#992)
Default to including `ScaleControl`, `NavigationControl`, and `FullscreenControl` on the `Map` Closes #986
1 parent 1ec97a8 commit 5e78565

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lonboard/_map.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
from lonboard._html_export import map_to_html
1414
from lonboard._viewport import compute_view
1515
from lonboard.basemap import CartoStyle, MaplibreBasemap
16-
from lonboard.controls import BaseControl
16+
from lonboard.controls import (
17+
BaseControl,
18+
FullscreenControl,
19+
NavigationControl,
20+
ScaleControl,
21+
)
1722
from lonboard.layer import BaseLayer
1823
from lonboard.traits import HeightTrait, VariableLengthTuple, ViewStateTrait
1924
from lonboard.traits._map import DEFAULT_INITIAL_VIEW_STATE
@@ -193,7 +198,14 @@ def on_click(self, callback: Callable, *, remove: bool = False) -> None:
193198
"""One or more `Layer` objects to display on this map.
194199
"""
195200

196-
controls = VariableLengthTuple(t.Instance(BaseControl)).tag(
201+
controls = VariableLengthTuple(
202+
t.Instance(BaseControl),
203+
default_value=(
204+
FullscreenControl(),
205+
NavigationControl(),
206+
ScaleControl(),
207+
),
208+
).tag(
197209
sync=True,
198210
**ipywidgets.widget_serialization,
199211
)

lonboard/traits/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class VariableLengthTuple(traitlets.Container):
130130
def __init__(
131131
self,
132132
trait: T | Sentinel = None,
133-
default_value: tuple[T] | Sentinel | None = Undefined,
133+
default_value: tuple[T, ...] | Sentinel | None = Undefined,
134134
minlen: int = 0,
135135
maxlen: int = sys.maxsize,
136136
**kwargs: Any,

0 commit comments

Comments
 (0)