inst/examples/shiny/bouncemarkers.R

library(shiny)
library(leaflet)
library(leaflet.extras)

greenLeafIcon <- makeIcon(
  iconUrl = "https://leafletjs.com/examples/custom-icons/leaf-green.png",
  iconWidth = 38, iconHeight = 95,
  iconAnchorX = 22, iconAnchorY = 94,
  shadowUrl = "https://leafletjs.com/examples/custom-icons/leaf-shadow.png",
  shadowWidth = 50, shadowHeight = 64,
  shadowAnchorX = 4, shadowAnchorY = 62
)

ui <- fluidPage(
  leafletOutput("map")
)

server <- function(input, output, session) {
  output$map <- renderLeaflet({
    leaflet() %>%
      addTiles() %>%
      addBounceMarkers(data = breweries91, label = ~address,
                       popup = ~brewery,
                       icon = greenLeafIcon)
  })
}
shinyApp(ui, server)
bhaskarvk/leaflet.extras documentation built on Sept. 7, 2024, 10:31 p.m.