I'd like to change the height and width of leaflet
map outputs in html document. Is there a simple way to do this in R markdown without getting into whole CSS business?
```{r}
library(leaflet)
library(dplyr)
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.
I found that changing fig.width
and fig.height
did not change the size of my leaflet maps. However, changing a different parameter/option did.
Try changing the width/height using this in the header for the code chunk:
{r, width = 40, height = 30}
Or alternatively, another thing that has worked for me is to use this (in this case, do not put anything in the chunk header:
m <- leaflet(width = "100%") %>%
This works fine:
SomeData %>%
leaflet(height=2000, width=2000) %>%
addTiles() %>%
addMarkers(clusterOption=markerClusterOptions())
Here SomeData is a dataframe containing columns: Lat and Long.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With