View source: R/plugin-easybutton.R
easyButtonState | R Documentation |
Create an easyButton statestate
Creates an easy button.
Add a EasyButton on the map see https://github.com/CliffCloud/Leaflet.EasyButton
Add a easyButton bar on the map see https://github.com/CliffCloud/Leaflet.EasyButton
easyButtonState(stateName, icon, title, onClick)
easyButton(
icon = NULL,
title = NULL,
onClick = NULL,
position = "topleft",
id = NULL,
states = NULL
)
addEasyButton(map, button)
addEasyButtonBar(map, ..., position = "topleft", id = NULL)
stateName |
a unique name for the state |
icon |
the button icon |
title |
text to show on hover |
onClick |
the action to take |
position |
topleft|topright|bottomleft|bottomright |
id |
id for the button |
states |
the states |
map |
a map widget object |
button |
the button object created with |
... |
a list of buttons created with |
easyButtonState()
: state of an easyButton.
addEasyButton()
: add an EasyButton to the map
addEasyButtonBar()
: add an EasyButton to the map
easyButton
https://github.com/CliffCloud/Leaflet.EasyButton
addEasyButton
leaf <- leaflet() %>%
addTiles() %>%
addEasyButton(easyButton(
icon = htmltools::span(class = "star", htmltools::HTML("★")),
onClick = JS("function(btn, map){ map.setZoom(1);}")))
leaf
leaf <- leaflet() %>%
addTiles() %>%
addEasyButtonBar(
easyButton(
icon = htmltools::span(class = "star", htmltools::HTML("★")),
onClick = JS("function(btn, map){ alert(\"Button 1\");}")),
easyButton(
icon = htmltools::span(class = "star", htmltools::HTML("⌖")),
onClick = JS("function(btn, map){ alert(\"Button 2\");}")))
leaf
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.