是否有任何好的工具/UI小部件来可视化大型图像/pdf文档。希望该工具的行为类似于谷歌地图的可视化方式,您可以在其中缩放功能并可以拖动到图像的不同部分
对于PDF,我不知道。对于图像,您可以尝试JavaScript库imgViewer2
。
library(shiny)
js <- '$(document).ready(function(){ $("#myimage").imgViewer2(); });'
ui <- fluidPage(
tags$head(
tags$link(
rel = "stylesheet",
href = "https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"),
tags$link(
rel = "stylesheet",
href = "http://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css",
media = "screen"),
tags$script(src = "https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"),
tags$script(src = "http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"),
tags$script(
src = "https://cdn.jsdelivr.net/npm/imgviewer2@1.1.0/src/imgViewer2.min.js"),
tags$script(HTML(js))
),
br(),
tags$img(id = "myimage",
src = "https://images.plot.ly/language-icons/api-home/r-logo.png",
width = "20%")
)
server <- function(input, output, session){}
shinyApp(ui, server)
或者panzoom
库:
library(shiny)
js <- '
$(document).ready(function(){
var img = document.getElementById("myimage");
panzoom(img);
});'
ui <- fluidPage(
tags$head(
tags$script(
src = "https://unpkg.com/panzoom@8.7.3/dist/panzoom.min.js"),
tags$script(HTML(js))
),
br(),
tags$img(id = "myimage",
src = "https://images.plot.ly/language-icons/api-home/r-logo.png",
width = "20%")
)
server <- function(input, output, session){}
shinyApp(ui, server)
或者尝试一下R包svgPanZoom。