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

Use event in main view #19

Merged
merged 6 commits into from
Jun 28, 2024
Merged

Use event in main view #19

merged 6 commits into from
Jun 28, 2024

Conversation

brichet
Copy link
Collaborator

@brichet brichet commented Jun 27, 2024

Follow up #17

This PR includes:

  • use of events to update, add or delete the layer and sources
  • use the layers tree to handle the level of each layer in the map
  • start refactoring mainview.tsx to move it then to an base View. It adds functions setSource, removeSource, updateLayers, updateLayer and removeLayer that could be implemented by a plugin (see Map viewers #7 for reference)

Copy link
Contributor

Binder 👈 Launch a Binder on branch brichet/jupytergis/layer_level

@brichet brichet added the enhancement New feature or request label Jun 27, 2024
@martinRenou
Copy link
Member

Thanks!

It adds functions setSource, removeSource, updateLayers, updateLayer and removeLayer

I wonder if the APIs between sources and layers could be symmetrical:

  • addSource/updateSource/removeSource
  • addLayer/updateLayer/removeLayer

@brichet
Copy link
Collaborator Author

brichet commented Jun 28, 2024

I wonder if the APIs between sources and layers could be symmetrical:

I agree.

MapLibre uses a beforeId value to insert the layer at the correct level.
In the addLayer function, we should probably use a index number to be more generic for other frameworks, and compute the beforeId value in the function, in the case of MapLibre.

@davidbrochart
Copy link
Collaborator

index would be the index at which to insert the layer in the list? If so, this is not ideal in RTC since layers could have been removed in the meantime and the index could be out of range.

@brichet
Copy link
Collaborator Author

brichet commented Jun 28, 2024

index would be the index at which to insert the layer in the list? If so, this is not ideal in RTC since layers could have been removed in the meantime and the index could be out of range.

The index is the index of the layer in the map tool (view), not in the list of layer in the shared document.
This index is computed when the layersTree change, accordingly to the position of the layer in possible nested groups.

@davidbrochart
Copy link
Collaborator

Got it, thanks!

@brichet brichet marked this pull request as ready for review June 28, 2024 11:58
Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

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

Thank you!

I just have a small suggestion but I believe we can also resolve it in a separate PR

* @param id - the source id.
* @param source - the source object.
*/
addSource(id: string, source: IJGISSource): void {
Copy link
Member

Choose a reason for hiding this comment

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

Should we start extracting these APIs in their own class implementing an IMapViewer interface?

That way we prepare the ground for future possible implementations/plugins

Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

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

Yeah let's resolve the comment separately, your PR will help Greg and I in our developments (that way we can see the changes we do on the map)

@martinRenou martinRenou merged commit ea74337 into geojupyter:main Jun 28, 2024
10 checks passed
@brichet brichet deleted the layer_level branch June 28, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants