[R] [传单]:点击时的超链接 [英] [R][Leaflet]: hyperlink on click
问题描述
我想在世界地图上添加标记,当用户单击一个标记而不是弹出窗口时,它会将用户定向到另一个网站.
I want to add markers on a world map and when the user clicks in one marker, instead of a popup it would direct the user to another website.
我是这个库的新手(实际上,这是我为解决此问题而尝试的第一个库-带有超链接标记的交互式地图,供用户单击并转到另一个网站),所以我能做的一切原为:
I'm new to this library (actually it's the first one i've tried in order to solve this issue - an interactive map with hyperlinks markers for the user to click and go to another website), so all i could do was:
map <- leaflet() %>%
addTiles()%>%
addMarkers(lng=174.768, lat=-36.852, popup="https://www.r-project.org/")
有什么方法可以处理R中的传单吗?如果没有,您可以建议另一个图书馆吗?
Is there a way to do wha i want with leaflet in R? if not, can you suggest another library?
非常感谢您
推荐答案
在popup
部分使用HTML ...
Use HTML in the popup
portion...
library("leaflet")
map <- leaflet() %>%
addTiles()%>%
addMarkers(lng=174.768, lat=-36.852,
popup='<a href="https://www.r-project.org/">R Project</a>')
此外,如果您不想在一起链接时,shiny
库具有用于此的功能...
Also, if you don't want to paste()
your links together, the shiny
library has functions for this...
shiny::a("something", href="www.something.com")
# <a href="www.something.com">something</a>
这篇关于[R] [传单]:点击时的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!