Base Classes¶
lonboard.BaseLayer ¶
Bases: BaseWidget
auto_highlight
class-attribute
instance-attribute
¶
auto_highlight = tag(sync=True)
When true, the current object pointed to by the mouse pointer (when hovered over) is
highlighted with highlightColor
.
Requires pickable
to be True
.
- Type:
bool
- Default:
False
extensions
class-attribute
instance-attribute
¶
extensions = tag(sync=True, **widget_serialization)
A list of layer extension objects to add additional features to a layer.
opacity
class-attribute
instance-attribute
¶
opacity = tag(sync=True)
The opacity of the layer.
- Type:
float
. Must range between 0 and 1. - Default:
1
pickable
class-attribute
instance-attribute
¶
pickable = tag(sync=True)
Whether the layer responds to mouse pointer picking events.
This must be set to True
for tooltips and other interactive elements to be
available. This can also be used to only allow picking on specific layers within a
map instance.
Note that picking has some performance overhead in rendering. To get the absolute
best rendering performance with large data (at the cost of removing interactivity),
set this to False
.
- Type:
bool
- Default:
True
selected_index
class-attribute
instance-attribute
¶
selected_index = tag(sync=True)
The positional index of the most-recently clicked on row of data.
You can use this to access the full row of data from a GeoDataFrame
gdf.iloc[layer.selected_index]
Setting a value here from Python will do nothing. This attribute only exists to be
updated from JavaScript on a map click. Note that pickable
must be True
(the
default) on this layer for the JavaScript onClick
handler to work; if pickable
is set to False
, selected_index
will never update.
Note that you can use observe
to call a function whenever a new value is received
from JavaScript. Refer
here
for an example.
visible
class-attribute
instance-attribute
¶
visible = tag(sync=True)
Whether the layer is visible.
Under most circumstances, using the visible
attribute to control the visibility of
layers is recommended over removing/adding the layer from the Map.layers
list.
In particular, toggling the visible
attribute will persist the layer on the
JavaScript side, while removing/adding the layer from the Map.layers
list will
re-download and re-render from scratch.
- Type:
bool
- Default:
True
lonboard.BaseArrowLayer ¶
Bases: BaseLayer
Any Arrow-based layer should subclass from BaseArrowLayer
auto_highlight
class-attribute
instance-attribute
¶
auto_highlight = tag(sync=True)
When true, the current object pointed to by the mouse pointer (when hovered over) is
highlighted with highlightColor
.
Requires pickable
to be True
.
- Type:
bool
- Default:
False
extensions
class-attribute
instance-attribute
¶
extensions = tag(sync=True, **widget_serialization)
A list of layer extension objects to add additional features to a layer.
opacity
class-attribute
instance-attribute
¶
opacity = tag(sync=True)
The opacity of the layer.
- Type:
float
. Must range between 0 and 1. - Default:
1
pickable
class-attribute
instance-attribute
¶
pickable = tag(sync=True)
Whether the layer responds to mouse pointer picking events.
This must be set to True
for tooltips and other interactive elements to be
available. This can also be used to only allow picking on specific layers within a
map instance.
Note that picking has some performance overhead in rendering. To get the absolute
best rendering performance with large data (at the cost of removing interactivity),
set this to False
.
- Type:
bool
- Default:
True
selected_index
class-attribute
instance-attribute
¶
selected_index = tag(sync=True)
The positional index of the most-recently clicked on row of data.
You can use this to access the full row of data from a GeoDataFrame
gdf.iloc[layer.selected_index]
Setting a value here from Python will do nothing. This attribute only exists to be
updated from JavaScript on a map click. Note that pickable
must be True
(the
default) on this layer for the JavaScript onClick
handler to work; if pickable
is set to False
, selected_index
will never update.
Note that you can use observe
to call a function whenever a new value is received
from JavaScript. Refer
here
for an example.
visible
class-attribute
instance-attribute
¶
visible = tag(sync=True)
Whether the layer is visible.
Under most circumstances, using the visible
attribute to control the visibility of
layers is recommended over removing/adding the layer from the Map.layers
list.
In particular, toggling the visible
attribute will persist the layer on the
JavaScript side, while removing/adding the layer from the Map.layers
list will
re-download and re-render from scratch.
- Type:
bool
- Default:
True
from_geopandas
classmethod
¶
from_geopandas(
gdf: gpd.GeoDataFrame,
*,
auto_downcast: bool = True,
**kwargs: Unpack[BaseLayerKwargs]
) -> Self
Construct a Layer from a geopandas GeoDataFrame.
The GeoDataFrame will be reprojected to EPSG:4326 if it is not already in that coordinate system.
Parameters:
-
gdf
(GeoDataFrame
) –The GeoDataFrame to set on the layer.
Other Parameters:
-
auto_downcast
(bool
) –If
True
, automatically downcast to smaller-size data types if possible without loss of precision. This calls pandas.DataFrame.convert_dtypes and pandas.to_numeric under the hood.
Returns:
-
Self
–A Layer with the initialized data.