Javascript 列出包的输入处理程序
通常,是否有一个函数来查找包的输入处理程序?传单有几种特殊的输入处理程序,例如,R文档中没有列出的input$mymap\u shape\u mouse。真的,我只想能够抓取一张平面png热图的坐标,我用它来制作传单,然后重新格式化,以抓取我之前绘制的矩阵中的坐标Javascript 列出包的输入处理程序,javascript,r,shiny,leaflet,Javascript,R,Shiny,Leaflet,通常,是否有一个函数来查找包的输入处理程序?传单有几种特殊的输入处理程序,例如,R文档中没有列出的input$mymap\u shape\u mouse。真的,我只想能够抓取一张平面png热图的坐标,我用它来制作传单,然后重新格式化,以抓取我之前绘制的矩阵中的坐标 library(shiny) library(leaflet) library(leaflet.extras) library(mapview) library(foreach) server <- function(input
library(shiny)
library(leaflet)
library(leaflet.extras)
library(mapview)
library(foreach)
server <- function(input, output, session) {
points <- eventReactive(input$recalc, {
cbind(rnorm(40) * 2 + 13, rnorm(40) + 48)
}, ignoreNULL = FALSE)
output$mymap <- renderLeaflet({
bounds <- c(0, 0, 14400, 14400)
leaflet(options = leafletOptions(
crs = leafletCRS(crsClass = "L.CRS.Simple"),
minZoom = -5,
maxZoom = 5)) %>%
fitBounds(bounds[1], bounds[2], bounds[3], bounds[4]) %>%
htmlwidgets::onRender("
function(el, t) {
var myMap = this;
var bounds = myMap.getBounds();
var image = new L.ImageOverlay(
'https://github.com/theaidenlab/juicebox/wiki/images/domains_peaks.png',
bounds);
image.addTo(myMap);
}") %>%
addMeasure() %>%
addMiniMap( toggleDisplay = TRUE,
position = "bottomleft") %>% addDrawToolbar() %>% addFullscreenControl() %>%
addMouseCoordinates(style="basic")
})
库(闪亮)
图书馆(单张)
图书馆(单张、附加资料)
图书馆(地图视图)
图书馆(foreach)
服务器%
addMiniMap(切换显示=TRUE,
position=“bottomleft”)%%>%addDrawToolbar()%%>%addFullscreenControl()%%>%
添加鼠标坐标(style=“basic”)
})
发现传单输入事件
对于那些对传单input
活动感兴趣的人,如input$MAPID_center
,请感谢。他们推荐了一个漂亮的技巧来打印出所有输入
事件:
逐字输出
在UI中创建输出$outputID
;及renderPrint({reactiveValuesToList(input)})
的结果存储在服务器中的output$outputID
对象中#加载必要的包
图书馆(闪亮)
图书馆(单张)
图书馆(地图视图)
ui您是否审阅了来自的官方文档?当然。我知道js中精确函数的确切位置,但在R中找不到类似的处理程序。这就是我感兴趣的。太棒了!有没有办法获取鼠标所在的点(鼠标悬停的坐标以及鼠标点击的位置)?这些类型的事件属于不同的类别,即交互事件(鼠标事件)。有!向@blondclover致敬:他们不久前回答了这个问题:。
# load necessary packages
library( shiny )
library( leaflet )
library( mapview )
ui <- fluidPage(
leafletOutput( outputId = "map"),
downloadButton( outputId = "dl"),
h2("List of Input Events"),
verbatimTextOutput( outputId = "text")
)
server <- function(input, output, session) {
# print list of input events
output$text <-
renderPrint({reactiveValuesToList(input)})
# Create foundational leaflet map
# and store it as a reactive expression
foundational.map <- reactive({
leaflet() %>% # create a leaflet map widget
addTiles( urlTemplate = "https://{s}.tile.openstreetmap.se/hydda/base/{z}/{x}/{y}.png" ) # specify provider tile and type
}) # end of foundational.map()
# render foundational leaflet map
output$map <- leaflet::renderLeaflet({
# call reactive map
foundational.map()
}) # end of render leaflet
# store the current user-created version
# of the Leaflet map for download in
# a reactive expression
user.created.map <- reactive({
# call the foundational Leaflet map
foundational.map() %>%
# store the view based on UI
setView( lng = input$map_center$lng
, lat = input$map_center$lat
, zoom = input$map_zoom
)
}) # end of creating user.created.map()
# create the output file name
# and specify how the download button will take
# a screenshot - using the mapview::mapshot() function
# and save as a PDF
output$dl <- downloadHandler(
filename = paste0( Sys.Date()
, "_customLeafletmap"
, ".pdf"
)
, content = function(file) {
mapshot( x = user.created.map()
, file = file
, cliprect = "viewport" # the clipping rectangle matches the height & width from the viewing port
, selfcontained = FALSE # when this was not specified, the function for produced a PDF of two pages: one of the leaflet map, the other a blank page.
)
} # end of content() function
) # end of downloadHandler() function
} # end of server
# run the Shiny app
shinyApp(ui = ui, server = server)
# end of script #