Generic Demo

library(leaflethex)
#> Loading required package: leaflet
#> Loading required package: htmltools
#> Loading required package: htmlwidgets
library(leaflethex)
library(tibble)

df = tibble(
  lat = rnorm(100),
  lng = rnorm(100),
  size = runif(100, 5, 20),
  color = sample(colors(), 100)
)
df2 <- tibble(
  lat =  42.9634 + stats::rnorm(100),
  lng = -85.6681 + stats::rnorm(100),
  size = runif(100, 5, 20),
  color = sample(colors(), 100)
)
addJS <- 
  pluginFactory(
    "Some JS Plugin", 
    system.file("js", "", package = "leaflethex"), "hexbin.js", "deps.js")

leaflet(df2, width = 600, height = 300) %>% 
  addTiles() %>% 
  addCircles(color = "red") %>%
  addJS(radius = 20, highEndColor = "yellow")  # radius seems to work, highEnd Color not
#> Assuming "lng" and "lat" are longitude and latitude, respectively
args(addJS)
#> function (map, data = NULL, ...) 
#> NULL
args(add_hexbin)
#> function (map, data = NULL, radius = 8.5, opacity = 0.5, duration = 500, 
#>     lowEndColor = "white", highEndColor = "blue", stroke = TRUE) 
#> NULL