0
我試圖模仿https://rstudio.github.io/leaflet/popups.html上的第一個例子,但使用了html標籤而不是一個向量。R,傳單包,將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)
)
也可以看看[這個答案](http://stackoverflow.com/questions/29173336/how-to-display-advanced-customed-popups-for-leaflet-in-shiny)更精緻的彈出窗口。 –