I am currently exploring the use of a javascript addon for leaflet called the heatmap functionality, which can be found at https://github.com/Leaflet/Leaflet.heat. My goal is to integrate this feature into Shiny, however, it seems that the leaflet package for R does not include this addon by default. Therefore, I would need to manually include this JS script. I came across a post on rCharts that provided some insight on how to achieve this:
server.R.
HeatMap$addAssets(jshead = c("http://leaflet.github.io/Leaflet.heat/dist/leaflet-heat.js"))
HeatMap$setTemplate(afterScript = sprintf("<script>
var addressPoints = %s
var heat = L.heatLayer(addressPoints).addTo(map)
</script>",
rjson::toJSON(dt)))
(source: https://github.com/ramnathv/rCharts/issues/498 )
However, as someone with limited knowledge in JS and new to leaflet, it is still unclear to me how to fully incorporate this feature - starting from obtaining the JS script from github to ultimately creating a heatmap using leaflet with the 'quakes' dataset.
Below is a snippet of my server side code:
library(leaflet)
output$mymap <- renderLeaflet({
leaflet() %>%
addProviderTiles("OpenMapSurfer.Roads",
options = providerTileOptions(noWrap = TRUE))
%>% addMarkers(clusterOptions = markerClusterOptions(), data = quakes))
Instead of using clusterOptions, I aim to add a heatmap indicating the magnitude of the earthquakes (the dataset 'quakes' is readily available in R for reference).