Skip to content

Instantly share code, notes, and snippets.

@tiernanmartin
Created March 8, 2016 06:44
Show Gist options
  • Save tiernanmartin/076503e31b4cbea93b72 to your computer and use it in GitHub Desktop.
Save tiernanmartin/076503e31b4cbea93b72 to your computer and use it in GitHub Desktop.
An example illustrating a possible bug in the Leaflet package
library(shiny)
library(shinydashboard)
library(leaflet)
header <- dashboardHeader(
title = "Example",
titleWidth = "600px"
)
sidebar <- dashboardSidebar(width = "600px")
body <- dashboardBody(
bootstrapPage(
leafletOutput("map",height = "800px")
)
)
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
output$map <- renderLeaflet({
pal <- colorNumeric("Set2", quakes$mag)
leaflet(quakes) %>%
addTiles() %>%
fitBounds(~min(long), ~min(lat), ~max(long), ~max(lat)) %>%
addCircles(radius = ~10^mag/10, weight = 1, color = "#777777",
fillColor = ~pal(mag), fillOpacity = 0.7, popup = ~paste(mag)
)
})
}
shinyApp(ui,server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment