我试图模仿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>"
但是,当我将代码传递给leaflet popup时,会显示更多的info超链接,并链接到未找到的页面而不是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)
)
答案 0 :(得分:2)
我认为您使用的是错误的引号字符串。 ’
代替'
。如果我将引号字符串反转为:
'<a href="https://www.allaboutbirds.org/guide/Gadwall/id">more info</a>'
双引号以转义网址。