-
Notifications
You must be signed in to change notification settings - Fork 509
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
Only show markers selected from other widget when using crosstalk #726
Comments
Reactable developer seemed to think that this was a leaflet issue: glin commented Feb 14, 2021 |
I second this: It would be great to have a way to fine-tune what happens to Leaflet markers when their rows are selected from other widgets using crosstalk. I've done a quick skim of the Leaflet package code, but I'm not familiar with the codebase and it wasn't obvious to me where the behaviour for selected rows is defined. Does anyone have an idea of where the behaviour for crosstalk-selected Leaflet markers is defined? e.g. is it in the R code, the JavaScript code, css, or somewhere else? With a hint, I might be able to help 🙂 |
@chris31415926535 I just came across this same need in my work, and noticed that the markers outside of the filtered selection are being set to an opacity of 0.2. I took a look through the repo and believe I found where that is happening: leaflet/inst/htmlwidgets/leaflet.js Line 1040 in 5bf15ec
As of where to go from here, I am not sure since this is hardcoded in the source code... |
The next step is to make sure that changing the code in the place you've located will work. Download the source code as a zip file. Extract the files from the zip. Edit the line you've discovered. Re-zip. Unzip and then install with R CMD Install. Use some test data to make sure the fix works. After a successful edit, edit the file on the master branch: https://github.com/rstudio/leaflet/blob/master/inst/htmlwidgets/leaflet.js . Then commit the change - and be sure to make them add you as a coauthor. |
@tedmoorman ah yes of course! My statement was, I guess, more rhetorical in the sense that for a particular project/visualization, you're stuck with what you have given the opacity level is hardcoded :) To your point, I can confirm that the block of code I referenced will change the opacity (I set to 0, and they 'disappeared'). Of course if you have marker labels they will still show up, so perhaps creating a solution to just adjust opacity of the markers is not robust enough. It was fun for me to dive in and locate the source code responsible for this. Perhaps I can find the personal time to actually do something with this! |
@michaelbgarcia sounds like you've got it figured out. I noticed a similar section of code in the same file: leaflet/inst/htmlwidgets/leaflet.js Lines 973 to 978 in 5bf15ec
Any idea what's going on there? |
With crosstalk I'm using R's reactable package to display a table to use for filtering. When I select a single row, I see too many markers on the map, even though the opacity of the unselected markers is reduced. I would like for all markers to disappear except the ones I've chosen from the table. You can sort of see what I'm talking about here: [https://glin.github.io/reactable/articles/examples.html#linked-selection-1]. Just imagine many, many more markers.
Maybe there's a quick fix from leaflet. Or maybe the problem has to do with crosstalk or reactable. I'm cross referencing in all issue forums. Please see [https://github.com/rstudio/crosstalk/issues/84].
The text was updated successfully, but these errors were encountered: