Skip to content

Instantly share code, notes, and snippets.

@sckott
Forked from ramnathv/server.r
Last active December 18, 2015 03:39
Show Gist options
  • Save sckott/5719670 to your computer and use it in GitHub Desktop.
Save sckott/5719670 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
})
output$chart2 <- 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)
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