Skip to content

Conversation

@kylebarron
Copy link
Member

@kylebarron kylebarron commented Oct 3, 2023

Change list

  • Support for rendering multiple layers on a single map.
  • The serialization on the top-level model only passes string keys to the frontend. Then to access the actual sub-model containing each layer, the frontend calls the async WidgetManager.get_model(). In this PR's implementation, it manages a subModelState object that contains a mapping from layer id to model data. Each model data now has a class (like ScatterplotModel) that wraps each layer model with strong typing and which also manages instantiating event handlers to update the map when the model data changes.

todo:

Follow ups for future prs:

  • Remove support for rendering layers in isolation (outside of a map). Or maybe overwrite the __repr__ to make the repr of a layer pass its data into Map()? Thus making it easy to render just one layer, but directing people to create a Map directly for more control.
  • No longer subclass layers from AnyWidget
  • Update inference of initial_view_state for the top-level Map object
  • Remove .tsx apps for specific layers

Closes #33

This was referenced Oct 3, 2023
@kylebarron kylebarron marked this pull request as ready for review October 30, 2023 21:38
@kylebarron kylebarron changed the title attempt async use effect Support multiple layers on a single map Oct 30, 2023
"react-map-gl": "^7.1.5"
},
"devDependencies": {
"@jupyter-widgets/base": "^6.0.6",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a type-only dependency, so I think it's ok to have it as a dev dependency. And probably better this way, as it won't interact with whatever version jupyterlab is using.

Comment on lines +48 to +50
let [subModelState, setSubModelState] = useState<
Record<string, BaseGeoArrowModel>
>({});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This manually stores the state of all child layers

@kylebarron
Copy link
Member Author

kylebarron commented Oct 30, 2023

This is working now!
Screenshot 2023-10-30 at 5 56 34 PM

Works like a charm in colab too (I published an 0.2.0-alpha.1 to make it easier to test):
image

@kylebarron
Copy link
Member Author

@vgeorge I think this is ready to merge if you'd like to take a look at it! Any feedback is appreciated! It looks like it works, but maybe there's a cleaner way to implement it 🤷‍♂️

@kylebarron
Copy link
Member Author

Merging now to make follow up prs off the main branch, but feedback still welcome

@kylebarron kylebarron merged commit 0f9518a into main Oct 31, 2023
@kylebarron kylebarron deleted the kyle/attempt-async-useffect branch October 31, 2023 16:41
roger120981 pushed a commit to roger120981/lonboard that referenced this pull request Jul 14, 2025
* attempt async use effect

* scratch work

* wip

* simplify js model

* flesh out model

* Clean up model state transfer

* Remove existing callbacks

* Add initial view state to Map

* separate function for sub model state

* remove empty file

* bump version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

React issues

2 participants