Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

easyButton

Create an easyButton statestate


Description

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

Usage

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)

Arguments

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 easyButton

...

a list of buttons created with easyButton

Functions

  • easyButtonState: state of an easyButton.

  • addEasyButton: add an EasyButton to the map

  • addEasyButtonBar: add an EasyButton to the map

See Also

Examples

leaf <- leaflet() %>%
  addTiles() %>%
  addEasyButton(easyButton(
     icon = htmltools::span(class = "star", htmltools::HTML("&starf;")),
     onClick = JS("function(btn, map){ map.setZoom(1);}")))
leaf

leaf <- leaflet() %>%
  addTiles() %>%
  addEasyButtonBar(
   easyButton(
     icon = htmltools::span(class = "star", htmltools::HTML("&starf;")),
     onClick = JS("function(btn, map){ alert(\"Button 1\");}")),
   easyButton(
     icon = htmltools::span(class = "star", htmltools::HTML("&target;")),
     onClick = JS("function(btn, map){ alert(\"Button 2\");}")))
leaf

leaflet

Create Interactive Web Maps with the JavaScript 'Leaflet' Library

v2.0.4.1
GPL-3
Authors
Joe Cheng [aut, cre], Bhaskar Karambelkar [aut], Yihui Xie [aut], Hadley Wickham [ctb], Kenton Russell [ctb], Kent Johnson [ctb], Barret Schloerke [ctb], jQuery Foundation and contributors [ctb, cph] (jQuery library), Vladimir Agafonkin [ctb, cph] (Leaflet library), CloudMade [cph] (Leaflet library), Leaflet contributors [ctb] (Leaflet library), Brandon Copeland [ctb, cph] (leaflet-measure plugin), Joerg Dietrich [ctb, cph] (Leaflet.Terminator plugin), Benjamin Becquet [ctb, cph] (Leaflet.MagnifyingGlass plugin), Norkart AS [ctb, cph] (Leaflet.MiniMap plugin), L. Voogdt [ctb, cph] (Leaflet.awesome-markers plugin), Daniel Montague [ctb, cph] (Leaflet.EasyButton plugin), Kartena AB [ctb, cph] (Proj4Leaflet plugin), Robert Kajic [ctb, cph] (leaflet-locationfilter plugin), Mapbox [ctb, cph] (leaflet-omnivore plugin), Michael Bostock [ctb, cph] (topojson), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.