我想创建一个带有居中的leaflet小部件的HTML文档。
---
title: "Exemple"
author: "Antoine Bichat"
date: "31/08/2018"
output: html_document
---
```{r leaflet, fig.align="center"}
library(leaflet)
leaflet() %>%
addTiles() %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
```
fig.align="center"
的第一种想法不起作用。
我找到了这个问题,并将其适应于我的情况:
<style>
/* resize the widget container */
.leaflet {
width: 80% !important;
}
/* center the widget */
div.leaflet-control-container {
margin: auto !important;
}
</style>
但是,如果我不想让out.width
为100%(我并不想这样做),它就不起作用了。
或者可能是我做错了...
实际上,我更喜欢一个100%的R
/Rmarkdown
解决方案,但我对一切都持开放态度 :)