Leaflet Map just white when trying to increase height to 100%

1,613 views
Skip to first unread message

Jerad Hoy

unread,
Dec 17, 2014, 11:50:12 PM12/17/14
to shiny-...@googlegroups.com
My application is at jeradhoy.shinyapps.io/choropleth. Please forgive my horribly messy code. I currently have the map set at a height of 600px. The code snippet for creating the map is in ui.R is

ui.R

leafletMap("map", width="100%", height=600,


    initialTileLayer = "//{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png",

    options=list(

      center = c(40, -92.85),

      zoom = 4

))


I want it to be full height like the example at http://shiny.rstudio.com/gallery/superzip-example.html with the 100% map height on screen. Their code for creating the map is in Ui.R is


ui.R


leafletMap("map", width="100%", height="100%",
initialTileLayer = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png",
initialTileLayerAttribution = HTML('Maps by <a href="http://www.mapbox.com/">Mapbox</a>'),

options=list(

center = c(37.45, -93.85),

zoom = 4,

maxBounds = list(list(15.961329,-129.92981), list(52.908902,-56.80481)) # Show US only

))



When I try and change mine to height="100%", the map won't be created and will be just white. It seems as though our code is the exact same. But it's possible it could be a bug.

Huidong TIAN

unread,
Dec 29, 2014, 7:04:06 AM12/29/14
to shiny-...@googlegroups.com
'height' must be a numeric value. 

Jerad Hoy

unread,
Dec 30, 2014, 8:39:24 PM12/30/14
to shiny-...@googlegroups.com
But the height in the example I'm going off of is "100%" and it works

Joe Cheng

unread,
Dec 31, 2014, 7:51:03 PM12/31/14
to Jerad Hoy, shiny-...@googlegroups.com

height=100% is tricky in HTML. It can be made to work but the parent elements all need to be setup for it by having their heights set to 100% as well. If you look closely at the example you're working off of, I'm sure you will find some CSS that either does that or sets an absolute height on one of the parents.

On Dec 30, 2014 6:39 PM, "Jerad Hoy" <jera...@gmail.com> wrote:
But the height in the example I'm going off of is "100%" and it works

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/f760d746-eccf-4cf6-a22a-45274ac9c9b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages