我正在使用R的传单,当我点击光栅图像时,我只想在某个URL上重定向.我目前的代码如下:
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
结果如下:
您可以使用viewExtent
mapview包中的内容:
library(mapview) mapview(poppendorf[[10]]) + viewExtent(poppendorf[[10]], opacity = 0, fillOpacity = 0, popup = 'Search Google')
viewExtent
顾名思义就是在光栅图像(或sp包的任何空间对象)的范围内绘制一个矩形.通过将线条和填充不透明度设置为零并提供自定义弹出窗口,您可以获得非常接近您想要的内容.我不知道有任何方法可以直接将超链接链接到R的传单中的栅格对象.
HTH,蒂姆