Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lonboard/_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ def on_click(self, callback: Callable, *, remove: bool = False) -> None:

basemap: t.Instance[MaplibreBasemap | None] = t.Instance(
MaplibreBasemap,
# If both `args` and `kw` are None, then the default value is None.
# Set empty kw so that the default is MaplibreBasemap() with default params
kw={},
allow_none=True,
).tag(
sync=True,
Expand Down
11 changes: 11 additions & 0 deletions tests/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from traitlets import TraitError

from lonboard import Map, ScatterplotLayer, SolidPolygonLayer
from lonboard.basemap import MaplibreBasemap


def test_map_fails_with_unexpected_argument():
Expand Down Expand Up @@ -38,3 +39,13 @@ def allow_single_layer():
def test_map_basemap_non_url():
with pytest.raises(TraitError, match=r"expected to be a HTTP\(s\) URL"):
_m = Map([], basemap_style="hello world")


def test_map_default_basemap():
m = Map([])
assert isinstance(m.basemap, MaplibreBasemap), (
"Default basemap should be MaplibreBasemap"
)

assert m.basemap.mode == MaplibreBasemap().mode, "Should match default parameters"
assert m.basemap.style == MaplibreBasemap().style, "Should match default parameters"