I would like to make a map of point locations using a tmap leaflet that when you click on a location it brings up a popup that includes a clickable link. Is there a way to do this?
Here is some sample code of what I would like to do:
library(sf)
library(tmap)
cities = data.frame(name=c("Pucón, Chile","Quito, Ecuador"),
altitude=c(227, 2850),
lon=c(-71.974444, -78.509722),
lat=c(-39.276667, -0.218611),
link1=c("https://fr.wikipedia.org/wiki/Puc%C3%B3n",
"https://fr.wikipedia.org/wiki/Quito"
),
link2=c("https://www.lonelyplanet.com/chile/the-lakes-district/pucon",
"https://www.quito.gob.ec/"
)
)
cities = st_as_sf(cities,coords=c("lon","lat"),crs=4326)
lf = tmap_leaflet(tm_shape(cities)+tm_symbols(popup.vars = c("link1","link2")))
print(lf)
The leaflet will include the URLs in the popup, but they are not clickable. I have tried placing the URLs inside an html link (<a>
), but that doesn't work.
Is there a solution to this problem?