Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

FilterBinder

Drive a lonboard layer’s filter_range from a RangeSlider (uses the layer’s DataFilterExtension).

Import

from manywidgets.lonboard import FilterBinder

Example

from lonboard import Map, ScatterplotLayer
from lonboard.layer_extension import DataFilterExtension
from manywidgets import RangeSlider, Column
from manywidgets.lonboard import FilterBinder

layer = ScatterplotLayer.from_geopandas(
    gdf,
    extensions=[DataFilterExtension(filter_size=1)],
    get_filter_value=values,           # one float per row
    filter_range=(lo, hi),
)
m = Map(layer, basemap=None)
slider = RangeSlider(min=lo, max=hi, low=lo, high=hi)
binder = FilterBinder(slider, layer)   # slider.low/high -> layer.filter_range

Column(slider, binder, m)

API

TraitTypeDefaultDescription
sourceInstanceThe slider providing low/high values.
layerUnionA single lonboard layer, or a list of layers, to filter.
low_fieldUnicode'low'Source trait for the low bound.
high_fieldUnicode'high'Source trait for the high bound.
filter_fieldUnicode'filter_range'Layer trait to write [low, high] to.
labelUnicode''Optional status label.
widget_idUnicode''Stable unique id used for cross-widget linking (auto-assigned).

For single-ended filtering, pass a Slider and set low_field=high_field="value". Use seconds (not milliseconds) for time filters (see the lonboard guide).