Skip to content

lonboard.controls

lonboard.controls

Controls to extend a Map's interactivity.

BaseControl

Bases: BaseWidget

A deck.gl or Maplibre Control.

position class-attribute instance-attribute

position = Union(
    [
        Unicode("top-left"),
        Unicode("top-right"),
        Unicode("bottom-left"),
        Unicode("bottom-right"),
    ],
    allow_none=True,
    default_value=None,
)

Position of the control in the map.

One of "top-left", "top-right", "bottom-left", or "bottom-right".

FullscreenControl

Bases: BaseControl

A deck.gl FullscreenControl.

Passing this to Map.controls will add a button to the map that allows for toggling fullscreen mode.

GeocoderControl

Bases: BaseControl

A deck.gl GeocoderControl.

Passing this to Map.controls will add a geocoder search box to the map.

__init__

__init__(*, client: GeocoderHandler, **kwargs: Any) -> None

Create a new GeocoderControl.

Other Parameters:

  • client (GeocoderHandler) –

    An async callable that takes a geocoder query string and returns a Feature or FeatureCollection representing the geocoder results. Use the GeocoderHandler protocol for type checking.

  • kwargs (Any) –

    Other keyword arguments passed to the BaseControl.

from_geopy classmethod

from_geopy(geocoder: Geocoder, **kwargs: Any) -> GeocoderControl

Create a GeocoderControl from a geopy geocoder instance.

The geocoder must be created in async mode using an async adapter (e.g. AioHTTPAdapter).

Example:

from lonboard.controls import GeocoderControl
from lonboard import Map
from geopy.adapters import AioHTTPAdapter
from geopy.geocoders import Nominatim

geocoder = Nominatim(user_agent="lonboard", adapter_factory=AioHTTPAdapter)
geocoder_control = GeocoderControl.from_geopy(geocoder)

m = Map(layer, controls=[geocoder_control])

GeocoderFeature

Bases: TypedDict

The expected response from a geocoder query.

This must be a GeoJSON Point feature, extended with some additional properties.

bbox instance-attribute

Bounding box of the form [minx,miny,maxx,maxy].

center instance-attribute

The center of the feature [lng, lat].

geometry instance-attribute

geometry: GeoJsonPoint

A GeoJSON Point geometry representing the location of the geocoder result.

language instance-attribute

language: NotRequired[str]

The language code of the text returned in text.

place_name instance-attribute

place_name: str

Human-readable text representing the full result hierarchy.

For example, "Austin, Texas, United States".

place_type instance-attribute

place_type: Sequence[str]

An array of index types that this feature may be returned as.

Most features have only one type matching its id.

text instance-attribute

text: str

Text representing the feature (e.g. "Austin").

GeocoderFeatureCollection

Bases: TypedDict

A collection of geocoder features.

features instance-attribute

The geocoder features returned from the query.

GeocoderHandler

Bases: Protocol

A protocol for handling geocoder queries from the frontend.

__call__ async

__call__(query: str) -> GeocoderFeatureCollection | GeocoderFeature | None

Handle a geocoder query.

Parameters:

  • query (str) –

    The geocoder query string from the frontend.

Returns:

MultiRangeSlider

Bases: VBox

A widget for multiple ranged sliders.

This is designed to be used with the DataFilterExtension when you want to filter on 2 to 4 columns on the same time.

If you have only a single filter, use an ipywidgets FloatRangeSlider directly.

Example:

from ipywidgets import FloatRangeSlider

slider1 = FloatRangeSlider(
    value=(2, 5),
    min=0,
    max=10,
    step=0.1,
    description="First slider: "
)
slider2 = FloatRangeSlider(
    value=(30, 40),
    min=0,
    max=50,
    step=1,
    description="Second slider: "
)
multi_slider = MultiRangeSlider([slider1, slider2])
multi_slider

Then to propagate updates to a rendered layer, call jsdlink to connect the two widgets.

from ipywidgets import jsdlink

jsdlink(
    (multi_slider, "value"),
    (layer, "filter_range")
)

As you change the slider, the filter_range value on the layer class should be updated.

__init__

__init__(children: Sequence[FloatRangeSlider], **kwargs: Any) -> None

Create a new MultiRangeSlider.

NavigationControl

Bases: BaseControl

A deck.gl NavigationControl.

Passing this to Map.controls will add zoom and compass buttons to the map.

show_compass class-attribute instance-attribute

show_compass = Bool(allow_none=True, default_value=None)

Whether to show the compass button.

Default True.

show_zoom class-attribute instance-attribute

show_zoom = Bool(allow_none=True, default_value=None)

Whether to show the zoom buttons.

Default True.

visualize_pitch class-attribute instance-attribute

visualize_pitch = Bool(allow_none=True, default_value=None)

Whether to enable pitch visualization.

This only has effect for Maplibre-driven maps (i.e. where MaplibreBasemap.mode is "overlaid" or "interleaved").

Default True.

visualize_roll class-attribute instance-attribute

visualize_roll = Bool(allow_none=True, default_value=None)

Whether to enable roll visualization.

This only has effect for Maplibre-driven maps (i.e. where MaplibreBasemap.mode is "overlaid" or "interleaved").

Default False.

ScaleControl

Bases: BaseControl

A deck.gl ScaleControl.

Passing this to Map.controls will add a scale bar to the map.

max_width class-attribute instance-attribute

max_width = Int(allow_none=True, default_value=None)

The maximum width of the scale control in pixels.

This only has effect for Maplibre-driven maps (i.e. where MaplibreBasemap.mode is "overlaid" or "interleaved").

Default 100.

unit class-attribute instance-attribute

unit = Unicode(allow_none=True, default_value=None)

The unit of the scale.

This only has effect for Maplibre-driven maps (i.e. where MaplibreBasemap.mode is "overlaid" or "interleaved").

One of 'metric', 'imperial', or 'nautical'. Default is 'metric'.