Leaflet: Setting map height and width from interactive document

Created on 22 Apr 2015  路  3Comments  路  Source: rstudio/leaflet

There doesn't seem to be a way to set the map dimensions when it is created in a Shiny interactive document (.Rmd file with runtime: shiny). In this case the map is rendered using renderLeaflet() and the default parameters to leafletOutput() are used. Is there a way to do this? Thanks!

Most helpful comment

Thanks! It took me a little while to understand your response, partly because there is no explicit output variable in my .Rmd file. Here is what worked:

output$mymap = renderLeaflet({...make a map...})
leafletOutput('mymap', height=600)

All 3 comments

You can explicitly put in a leafletOutput and output$leafletid <- renderLeaflet({...}). Ugly but effective :)

Thanks! It took me a little while to understand your response, partly because there is no explicit output variable in my .Rmd file. Here is what worked:

output$mymap = renderLeaflet({...make a map...})
leafletOutput('mymap', height=600)

That's exactly right. Sorry for not providing an example, I was on my phone.

I know it's a little confusing that the output variable just exists--the same is true for the other common Shiny variables, input and session.

Was this page helpful?
0 / 5 - 0 ratings