I am building a Leaflet application in R.
I want to use this plugin https://github.com/Turbo87/leaflet-sidebar However, I have no clue where to start.
Guides on implementing Javascript Leaflet plugins in R have not been able to help. Does anyone have any steps/guidance/code I can follow to implement the plugin in my R Leaflet? Any help would be greatly appreciated.
This is where I'm currently at:
sidebarPlugin <- htmlDependency("leaflet-sidebar", "0.2.0",
src = c(href = "https://github.com/Turbo87/leaflet-sidebar.git"),
script = "src/L.Control.Sidebar.js")
registerPlugin <- function(map, plugin) {
map$dependencies <- c(map$dependencies, list(plugin))
map}
testLeaflet <- leaflet() %>%
addTiles %>%
addPolylines(data = dijkjson)%>%
#register plugin on this map instance
registerPlugin(sidebarPlugin)%>%
addControl("Test2", position = "topright")%>%
# Add your custom JS logic here. The `this` keyword
# refers to the Leaflet (JS) map object.
onRender("function(el, x) {
var sidebar = L.control.sidebar('sidebar', {
position: 'left'}).addTo(this);
map.addControl(sidebar).addTo(this);
sidebar.show().addTo(this);
}")