crosstalk
crosstalk copied to clipboard
Interaction between Polygons in Leaflet and Datatable
My goal is to be able to click on a polygon and the datatable renders automatically and only shows the corresponding values? Similar to what is done here with plotly.
https://blog.cpsievert.me/2018/03/30/visualizing-geo-spatial-data-with-sf-and-plotly/
Is this possible? What I tried so far is the following:
sd <- some_spatial_dataframe %>% SharedData$new()
sd_df <- some_spatial_dataframe %>% data.frame() %>% SharedData$new(group = sd$groupName())
crosstalk::bscols( leaflet(sd) %>% addProviderTiles("CartoDB.Positron") %>% addPolygons(), DT::datatable(data = sd_df) )
Unfortunately, this doesn't work at all. There is no interaction between leaflet and datatable.
the same issue for me
the solution was found in here:
devtools::install_github("dmurdoch/leaflet@crosstalk4")
https://stackoverflow.com/questions/42974140/crosstalk-filter-polylines-in-leaflet
That example is using plotly::plot_mapbox()
, not leaflet.
Is there any chance of reviving https://github.com/rstudio/leaflet/pull/499 @jcheng5? That would be really valuable...
Indeed, I put my comment there: https://github.com/rstudio/leaflet/pull/499#issuecomment-1337584064 It would be awesome to have this feature implemented. Thanks in advance.