I'm using leaflet for R and I simply would like to be redirected on some URL when I click on the raster image. My current code is the following :
library(htmlwidgets)
library(raster)
library(leaflet)
library(sp)
imgPath = paste(projectPath,"/test.tif", sep = "")
outPath = paste(projectPath, "/leaflethtmlgen.html", sep="")
r <- raster(imgPath)
pal <- colorNumeric(c("#FF0000", "#666666", "#FFFFFF"), values(r),
na.color = "transparent")
m <- leaflet()
m <- addTiles(m)
m <- addRasterImage(m,r, colors=pal, opacity = 0.9, maxBytes = 123123123, group = "Raster1")
m <- addLegend(m,pal = pal, values = values(r), title = "Test")
m <- addLayersControl(
m,
overlayGroups = c("Raster1"),
options = layersControlOptions(collapsed = FALSE)
)
m
The result is the following: