@ bethanyP的答案适用于所有情况。我认为一些额外的细节可能会有所帮助。我在线评论了每一步。
library(leaflet)
# example from https://rstudio.github.io/leaflet/popups.html
content <- paste(sep = "<br/>",
"<b><a href='http://www.samurainoodle.com'>Samurai Noodle</a></b>",
"606 5th Ave. S",
"Seattle, WA 98138"
)
leaflet() %>% addTiles() %>%
addPopups(-122.327298, 47.597131, content,
options = popupOptions(closeButton = FALSE)
)
# according to ?popupOptions can specify min/maxWidth
# set min and max width the to force a width
leaflet() %>% addTiles() %>%
addPopups(
-122.327298, 47.597131,
content,
options = popupOptions(
closeButton = FALSE,
minWidth = 300,
maxWidth = 300
)
# on the other hand, it appears that we only have maxHeight
# so height cannot be controlled in the same way
leaflet() %>% addTiles() %>%
addPopups(
-122.327298, 47.597131,
content,
options = popupOptions(
closeButton = FALSE,
maxHeight = 20
)
)
# let's extend the example to show how we can use
# htmltools to add CSS to control our popups
# could also use the approach suggested in
# the other answer, but I think this is more
# fitting with typical HTML/JS convention
lf <- leaflet() %>% addTiles() %>%
addPopups(
-122.327298, 47.597131,
content,
options = popupOptions(
closeButton = FALSE,
# not necessary but adding a className
# can help in terms of specificity
# especially if you have multiple popups
# with different styling
className = "myspecial-popup"
)
)
library(htmltools)
browsable(
tagList(
tags$head(
# more specific is better
tags$style(
'div.myspecial-popup div.leaflet-popup-content-wrapper {
height: 400px;
opacity: .5;
}'
)
),
lf
)
)
您是否曾经为此找到过解决方案?我试图找出如何增加R中的传单地图的弹出框的宽度,但我还没有运气... – KMcL 2016-03-22 17:15:18