I want to make a map with points and a responsive heatmap using crosstalk in R. Like this:
library(crosstalk)
library(leaflet)
library(DT)
# Wrap data frame in SharedData
sd <- SharedData$new(quakes[sample(nrow(quakes), 10),])
bscols(
# Create a filter input
filter_slider("mag", "Magnitude", sd, column=~mag, step=0.1, width=250),
leaflet(sd) %>% addTiles() %>% addMarkers() %>% addHeatmap())
)
But, as can be observed after running the code, this way doesn't get the responsive effect on the heatmap when filtering
How can I achieve the effect?
This could be easily done with Shiny. However, if you really wan't to use crosstalk, then you would have to add some javascript to redraw the heat map every time the markers are changed as crosstalk for some reason can't seem to do this.
A working example can be found here: https://rpubs.com/Jumble/r_crosstalk_leaflet_heatmap_update
Below is the code which produced this: