Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move selected_bounds from Layer to Map #676

Merged
merged 1 commit into from
Oct 7, 2024
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
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