我目前正在开发一个R package,它允许用户制作他们的航班、公路旅行和他们访问的城市的定制纪念Map。
我正在试图弄清楚如何将自定义标题和框架添加到传单Map的过程中。
□ □ □我目前拥有的
library(leaflet)
library(htmltools)
library(htmlwidgets)
# Custom CSS
tag.map.title <- tags$style(HTML("
.leaflet-control.map-title {
transform: translate(-30%,850%);
position: fixed !important;
left: 50%;
text-align: center;
font-weight: bold;
font-size: 60px;
font-family: 'Brush Script MT'
}
"))
# Adding a title
title <- tags$div(
tag.map.title, HTML("New York, New York!")
)
# Using my custom package
# devtools::install_github("benyamindsmith/mapBliss")
mapBliss::plot_city_view("New York City",
#mapBoxTemplate ="mapbox-template-link",
zoomControl = c(0.15, 0.05, 0.04, -0.003)) %>%
addControl(title, position = "topright", className="map-title")
∮我想要的∮
我想知道什么是CSS的要求,如果我想有这样的框架?理想情况下,他们将保持自己的立场时,调整大小也。
(For现在,忽略MapBox主题)
1条答案
按热度按时间ki0zmccv1#
如果map和title共享一个共同的父容器(例如
<div>
),您可以相对于它们的父容器定位它们。记住在子容器的CSS中设置position:relative
。示例:**编辑:**你可以通过设置一个
class
作为传单Map和标题的父DIV
来设置“图片框架”的样式。或者让用户选择几个CSS类中的一个。或者,你可以从用户输入(颜色,宽度等)中组成一个CSS样式字符串(style="..."
),然后重新设置renderUI
。如果UI呈现的开销很大,您也可以选择set CSS classes/styles client-side。