Skip to content

Commit

Permalink
Move selected_bounds to Map
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Oct 7, 2024
1 parent 25f7e13 commit 59999df
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
11 changes: 0 additions & 11 deletions lonboard/_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,6 @@ def _add_extension_traits(self, extensions: Sequence[BaseExtension]):
- Default: `[0, 0, 128, 128]`
"""

selected_bounds = t.Tuple(
t.Float(), t.Float(), t.Float(), t.Float(), allow_none=True, default_value=None
).tag(sync=True)
"""
Bounds selected by the user, represented as a tuple of floats ordered as
```
(minx, miny, maxx, maxy)
```
"""

selected_index = t.Int(None, allow_none=True).tag(sync=True)
"""
The positional index of the most-recently clicked on row of data.
Expand Down
11 changes: 11 additions & 0 deletions lonboard/_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,17 @@ def __init__(
global `parameters` when that layer is rendered.
"""

selected_bounds = t.Tuple(
t.Float(), t.Float(), t.Float(), t.Float(), allow_none=True, default_value=None
).tag(sync=True)
"""
Bounds selected by the user, represented as a tuple of floats ordered as
```
(minx, miny, maxx, maxy)
```
"""

def add_layer(
self,
layers: BaseLayer | Sequence[BaseLayer] | Map,
Expand Down
12 changes: 8 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,14 @@ function App() {
setSubModelState(newSubModelState);

if (!isDrawingBBoxSelection) {
childModels.forEach((layer) => {
layer.set("selected_bounds", bboxSelectBounds);
layer.save_changes();
});
// Note: selected_bounds is a property of the **Map**. In the future,
// when we use deck.gl to perform picking, we'll have
// `selected_indices` as a property of each individual layer.
model.set("selected_bounds", bboxSelectBounds);
// childModels.forEach((layer) => {
// layer.set("selected_bounds", bboxSelectBounds);
// layer.save_changes();
// });
}
} catch (error) {
console.error("Error loading child models or setting bounds:", error);
Expand Down

0 comments on commit 59999df

Please sign in to comment.