Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Forked from sckott/server.r
Last active December 18, 2015 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ramnathv/5717781 to your computer and use it in GitHub Desktop.
Save ramnathv/5717781 to your computer and use it in GitHub Desktop.
require(shiny)
require(rCharts)
shinyServer(function(input, output){
output$chart <- renderMap({
require(rCharts)
map3 <- Leaflet$new()
map3$setView(c(51.505, -0.09), zoom = 13)
map3$tileLayer(provider = input$provider, urlTemplate = NULL)
map3$marker(c(51.5, -0.09), bindPopup = "<p> Hi. I am a popup </p>")
map3$marker(c(51.495, -0.083), bindPopup = "<p> Hi. I am another popup </p>")
map3
})
})
require(shiny)
require(rCharts)
mapOutput = function(outputId){
LIB <- get_lib('leaflet')
suppressMessages(singleton(addResourcePath(LIB$name, LIB$url)))
div(id = outputId, class = paste("shiny-html-output", basename(LIB$name)),
tagList(get_assets_shiny(LIB)))
}
shinyUI(pageWithSidebar(
headerPanel('Leaflet Maps'),
sidebarPanel(
tags$style(".leaflet {height: 400px; width: 800px;}"),
selectInput('provider', 'Provider',
choices = c('Stamen.Toner', 'MapQuestOpen.OSM'),
selected = 'MapQuestOpen.OSM'
)
),
mainPanel(
tabsetPanel(
tabPanel("thing1", mapOutput('chart')),
tabPanel("thing2", uiOutput('chart2'))
))
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment