2
我正在使用傳單作爲R,我只是想在點擊柵格圖像時重定向到某個URL。我當前的代碼如下:R對於點擊柵格圖像時的傳單重定向
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
結果如下:
如果通過閃亮部署,您可以在一個'()',但在包裝那肯定會適用於整個地圖,我對光柵圖像很懷疑。否則,你可能不得不用JS()來分解JavaScript,而JS()會快速地混亂。 – alistaire