Created
June 5, 2013 21:20
-
-
Save sckott/5717419 to your computer and use it in GitHub Desktop.
trying a rcharts map in a panel - not working for me at least
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(shiny) | |
require(rCharts) | |
renderMap = function(expr, env = parent.frame(), quoted = FALSE){ | |
func <- shiny::exprToFunction(expr, env, quoted) | |
function() { | |
rChart_ <- func() | |
map_div = sprintf('<div id="%s" class="rChart leaflet"></div>', rChart_$params$dom) | |
HTML(paste(c(map_div, rChart_$html()), collapse = '\n')) | |
} | |
} | |
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 | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( | |
selectInput('provider', 'Provider', | |
choices = c('Stamen.Toner', 'MapQuestOpen.OSM'), | |
selected = 'MapQuestOpen.OSM' | |
) | |
), | |
mainPanel( | |
tabsetPanel( | |
tabPanel("thing1", mapOutput('chart')), | |
tabPanel("thing2", mapOutput('chart')) | |
)) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am also trying to create a Shiny app using rMaps, but still running into issues. Were you able to get your code running?