我想为整个 map 添加一个标题(与图例标题不同:addLegend(..., title = "", ...):通过“标题”,我的意思是一个覆盖的 map 组件保持原位移动 map 时(与叠加图像不同) 。
这是 RStudio 中的一个选项 leaflet对于 R?
leafletR有一个 title=""参数,但它更新了网页的标题:它不会向 map 添加标题。
最佳答案
@MLavoie 的想法是正确的,但我一直在寻找更具体的东西:
tag.map.title <- tags$style(HTML("
.leaflet-control.map-title {
transform: translate(-50%,20%);
position: fixed !important;
left: 50%;
text-align: center;
padding-left: 10px;
padding-right: 10px;
background: rgba(255,255,255,0.75);
font-weight: bold;
font-size: 28px;
}
"))
title <- tags$div(
tag.map.title, HTML("Map title")
)
map_leaflet <- leaflet() %>%
addTiles() %>%
addControl(title, position = "topleft", className="map-title")
这将使
leaflet-control
居中标题如屏幕截图所示,并将其放在顶部。
关于R:为传单 map 添加标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49072510/