Ken Ken - 2 months ago 12x
HTML Question

Adjust size of leaflet map in rmarkdown html

I'd like to change the height and width of

map outputs in html document. Is there a simple way to do this in R markdown without getting into whole CSS business?


m <- leaflet() %>% setView(lng = -71.0589, lat = 42.3601, zoom = 12)
m %>% addTiles()

Ideally, I want the width of map to be the same width of code block as shown below.

enter image description here


you can set like a global figure size to the whole document... But I think your code chunks will rescale, the images not.

opts_chunk$set(fig.width=12, fig.height=8)

Actually, I didn't checked it with leaflets. Hope this code is still working.