0

I have a shapefile that I export from QGIS and load using the sf library in R. The shapefile contains an attribute "description" which is a link to a website. I use this shapefile to create an interactive leaflet map. I would like the "description" attribute to show up as a hyperlink that can be selected when using the leaflet map interactively. Any help figuring this out would be greatly appreciated.

Code:

library(shiny)
library(shinydashboard)
library(plotly)
library(sf)
library(maps)
library(tmap)
library(mapview)
library(leaflet)
library(tmaptools)
library(DT)

#Read in Data Files

AZ_Hunt_Units <- sf::st_read("AZHuntDash_v1.0/All_Arizona_SHPv2/All_Arizona_v2.shp", quiet = TRUE)    

output$tmapA = renderLeaflet({
  p =tm_shape(AZ_Hunt_Units)+
  tm_fill("grey",0.1) + tm_borders("purple",lwd=2)+tm_basemap(server ="OpenStreetMap")+tm_text("Name",size=1,col="red",fontface="bold")
  tmap_leaflet(p)
})

enter image description here

Dan
  • 352
  • 3
  • 11
  • Does this answer your question? [Is there a way to make hyperlinks in the pop-up of a tm\_bubbles item?](https://stackoverflow.com/questions/55711438/is-there-a-way-to-make-hyperlinks-in-the-pop-up-of-a-tm-bubbles-item) – Jindra Lacko Nov 24 '19 at 22:28
  • {tmap} sanitizes HTML, you will find it easier to work with {leaflet} directly. See for example https://stackoverflow.com/questions/55711438/is-there-a-way-to-make-hyperlinks-in-the-pop-up-of-a-tm-bubbles-item/55714484#55714484 – Jindra Lacko Nov 24 '19 at 22:31

0 Answers0