crosstalk icon indicating copy to clipboard operation
crosstalk copied to clipboard

Interaction between Polygons in Leaflet and Datatable

Open pabuta opened this issue 6 years ago • 5 comments

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.

pabuta avatar Apr 23 '18 11:04 pabuta

the same issue for me

harryprince avatar May 13 '18 00:05 harryprince

the solution was found in here:

devtools::install_github("dmurdoch/leaflet@crosstalk4")

https://stackoverflow.com/questions/42974140/crosstalk-filter-polylines-in-leaflet

harryprince avatar Dec 10 '18 08:12 harryprince

That example is using plotly::plot_mapbox(), not leaflet.

cpsievert avatar Dec 10 '18 15:12 cpsievert

Is there any chance of reviving https://github.com/rstudio/leaflet/pull/499 @jcheng5? That would be really valuable...

petrbouchal avatar Sep 16 '20 18:09 petrbouchal

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.

damianooldoni avatar Dec 05 '22 15:12 damianooldoni