-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
Add return values for selected layers in LayersControl #217
Add return values for selected layers in LayersControl #217
Conversation
@@ -111,6 +113,18 @@ function onDraw(e: any) { | |||
return onLayerClick(e) | |||
} | |||
|
|||
function removeLayer(e: any) { | |||
const global_data = window.__GLOBAL_DATA__ | |||
global_data.selected_layers.delete(e.layer["wmsParams"]["layers"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this generically apply to any type of map layer added? Or is this just certain types of layers?
@reyemb this looks like a great addition to me -- there are a couple of formatting issues that github actions caught. Would you mind fixing those? You can fix those manually, or just run |
…st Layer because some provider use the same Layer but different Urls.
Thank you for the feedback! Here are the changes I made in response to the issues raised: Removed the Out-of-Place Comment: I removed the comment that was flagged as out-of-place in the previous review. Added an Example File: I provided an additional example file showcasing how the newly introduced functionality. Support for All Layer Types: In response to the feedback about whether the solution applies to different types of map layers: Yes, the solution I've implemented supports all types of layers added to the map, not just specific ones. Previously, I was only returning the names of the layers, but I found that some providers use layers with identical names while differentiating by URLs. For this reason, the updated implementation now returns a string containing a combination of both the layer's name and URL.
|
That way of separating out layers seems OK, but I think it would be better to just return them as json objects, like [{"name": "foo", "url": "bar"}...] Is there a good reason not to return them like that? Also, can you please fix the linting changes? As I suggested here #217 (comment), you can do this locally with pre-commit. |
Hey I thought I go the easy way by returning a string, but yeah this approach does look better. I also ran pre-commit hopefully it is okay now :) |
All but one passes locally for me @reyemb
|
This reverts commit 0b2a92f.
@reyemb ...my apologies, but can you re-submit this PR? I made a logical error about the order I could merge these PRs, and I cannot re-open this one Should just be hitting the button again from your fork to re-submit |
Description:
I primarily use st_folium in combination with LayerControl in Streamlit applications. However, one challenge I encountered is that there is no straightforward way to determine which layers are currently selected from the LayerControl. This limits functionality when trying to dynamically update components such as legends for each layer.
Here's a basic example of the issue:
To address this issue, I introduced a modification that allows st_folium to return the currently selected layers when interacting with the LayerControl. Now, when users toggle visibility of layers, the Streamlit app can respond accordingly, such as updating a legend for each selected layer. This greatly enhances interactivity.