Description Usage Arguments Value See Also Examples
pluginFactory()
takes in a couple js files (code and dependencies)
and creates a plugin function that applies this plugin to a given map. The new
function also returns the map so it can be piped with the
leaflet functions
1 2 | pluginFactory(name = "JSPlugin", location, jsfilename, dependencies,
stylesheet = NULL)
|
name |
A name for your plugin |
location |
The parent folder of your js file, dependency file, and css stylesheet |
jsfilename |
A .js filename relative to the parent folder at |
dependencies |
A .js filename(s) of all other js libraries the source code depends on |
stylesheet |
A .css stylesheet for adding styles to the entire page |
A function with arguments map, data, and ... to be used as a plugin to leaflet just like the leaflet::addCircles() function
Some code is used from this github gist by Joe Chang
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | df <- data.frame(
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", stylesheet="hexbin.css")
leaflet(df, width = 600, height = 300) %>%
addTiles() %>%
addJS(radius = 20, highEndColor = "yellow")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.