【发布时间】:2016-10-17 10:22:40
【问题描述】:
我正在尝试模拟https://rstudio.github.io/leaflet/popups.html 上的第一个示例,但使用的是 html 标签向量而不是一个。
https://rstudio.github.io/leaflet/popups.html 上的示例:
内容
[1] "<b><a href='http://www.samurainoodle.com'>Samurai Noodle</a></b><br/>606 5th Ave. S<br/>Seattle, WA 98138"
我的:
鸟$html[1]
[1] "<a href=‘https://www.allaboutbirds.org/guide/Gadwall/id’>more info</a>"
但是,当我将代码传递给传单弹出窗口时,更多信息超链接会显示并链接到未找到的页面而不是 url。我是否必须在 HTML 标签中添加任何特殊字符(例如斜杠或引号)?有什么想法吗?
leaflet () %>%
addTiles(urlTemplate = base_map, attribution = mb_attribution)%>%
addMarkers(bird$lon, bird$lat,
popup=paste(sep="","<b>", bird$Common.Name,"</b>",
"<br/>","<font size=2 color=#045FB4>","Scientific Name: ","</font>" ,bird$Scientific.Name,
"<br/>","<font size=2 color=#045FB4>","Number Observed: ","</font>", bird$Count,
"<br/>","<font size=2 color=#045FB4>","Location: ","</font>", bird$Location,
"<br/>","<font size=2 color=#045FB4>","Region: ","</font>", bird$Area,
"<br/>","<font size=2 color=#045FB4>", "Date: ", "</font>", bird$Date,
"<br/>", bird$html),
clusterOptions = markerClusterOptions()) %>%
addPopups(bird$lon, bird$lat, bird$html, options = popupOptions(closeButton = FALSE)
)
【问题讨论】:
-
也可以查看this answer 以获得更详细的弹出窗口。