Here is a compiled roster of input handlers specifically tailored for the "shiny leaf

Is there a way to identify the input handlers for a specific package? There are unique input handlers for leaflet, such as input$mymap_shape_mouseover that are not documented in R. My goal is to extract coordinates from a flat png heatmap used in leaflet and convert them into the matrix I have previously plotted.

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")
    })

Answer №1

Exploring Leaflet Input Events

If you're interested in understanding leaflet input events, like input$MAPID_center, a big thank you goes out to @blondclover. They shared a clever trick for displaying all input events:

  1. Set up the output$outputID in your UI using verbatimTextOutput.
  2. Save the results of
    renderPrint({reactiveValuesToList(input)})
    in the output$outputID object on the server side.

Understanding the available leaflet input events becomes essential as your leaflet map becomes more complex, allowing you to customize it effectively.

https://i.sstatic.net/wzHUv.png

# load required libraries
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) {

  # display list of input events
  output$text <-
    renderPrint({reactiveValuesToList(input)})

  # Create base leaflet map
  foundational.map <- reactive({

    leaflet() %>% # create leaflet map widget

      addTiles( urlTemplate = "https://{s}.tile.openstreetmap.se/hydda/base/{z}/{x}/{y}.png" ) # specify provider tile and type

  }) 

  # render base leaflet map
  output$map <- leaflet::renderLeaflet({

    foundational.map()

  }) 

  # save user-created version of the leaflet map for download
  user.created.map <- reactive({

    foundational.map() %>%

      setView( lng = input$map_center$lng
               ,  lat = input$map_center$lat
               , zoom = input$map_zoom
      )

  }) 

  # define file name and how the download button will capture a screenshot 
  output$dl <- downloadHandler(
    filename = paste0( Sys.Date()
                       , "_customLeafletmap"
                       , ".pdf"
    )

    , content = function(file) {
      mapshot( x = user.created.map()
               , file = file
               , cliprect = "viewport" 
               , selfcontained = FALSE 
      )
    } 
  ) 

} 

shinyApp(ui = ui, server = server)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ensure to verify within the ngOnInit function whether the checkbox has been selected

Hi everyone, I'm currently facing a situation where I have a list of checkboxes on one screen. When I select some checkboxes, they move to another screen and remain selected there. However, the issue is that when I try to use a button on the second sc ...

filtering an array based on a specific property will result in the original array remaining

Working on filtering an array of objects based on a certain property using the following code snippet: if (payment == Payment.CREDIT_CARD) { this.currenies.filter((currency: Currency) => currency.isFromEurope === true); console.log(this.currencies) ...

Unable to trigger ActionFunction with Remix and MUI slider

I am trying to implement a MUI slider in order to update a database by using Remix ActionFunction. The issue I am facing is that when the MUI slider is moved, it reloads the default function instead of calling the ActionFunction. How can I make it trigger ...

Substitute Ajax.ActionLink with a different method

Hey there, I have an Ajax Action Link set up that is working perfectly fine. It displays some text from a partial view when the link is clicked. However, I want this text to be shown automatically when the page loads, without the need to click on the actio ...

What could be causing my for loop to not function properly within the ngOnInit lifecycle hook?

I am attempting to create a nested loop structure in order to access an array that is inside an object within an array of objects, and then store this data into a new array. My issue arises as the first loop executes successfully but the second one does no ...

Combining Material UI's Higher Order Components (HOCs) for Maximum Efficiency

Currently in the process of combining multiple Material UI components for rendering. The code I have so far is: export default connect(mapStateToProps, mapDispatchToProps)(withTheme()(withStyles(styles)(ShopStore))); This setup is functioning as expected. ...

Creating a factory in AngularJS to handle RESTful JSON communication with

I have a scenario where I need to call a factory from multiple controllers in order to fetch JSON data. When I tried calling the factory directly from the controller, it worked successfully. However, after adding a factory and checking the console for erro ...

I am encountering difficulty with importing this particular file

I am struggling to get this image to display on my webpage using React. Despite reading through the Facebook documentation, I am still unable to figure it out and feeling quite frustrated. Any help would be greatly appreciated. https://jsfiddle.net/gexcoz1 ...

Calculating the number of distinct values within a dynamic date range using R

After finding a solution for this question using SQL and implementing it in R with sqldf, I have been struggling to achieve the same result using data.table. The challenge is to count the distinct values of one column within a rolling date range. For exam ...

Can one retrieve a catalog of Windows Updates that have been installed by utilizing node.js?

Currently, I am working on a JavaScript/Node.js project where I am seeking to retrieve a comprehensive list of all installed windows updates, similar to how it is done using the C# WUAPI 2.0 Type Library. I have attempted utilizing WMI calls (specifically ...

Is it possible to utilize the aggregate() function in R to determine the maximum value within a set of data points categorized by an identifier, as well as other associated values within each observation?

Thanks for taking the time to read and assist with my query. I have a dataset that contains multiple observations per grouping ID in long form. I've managed to use the aggregate() function to pick out the highest value per ID, enabling me to append t ...

What factors cause variations in script behavior related to the DOM across different browsers?

When looking at the code below, it's evident that its behavior can vary depending on the browser being used. It appears that there are instances where the DOM is not fully loaded despite using $(document).ready or similar checks. In Firefox, the "els ...

Nested loops iterating over an array of objects

I am working with a JSON file that contains my data: { "EIC": { "id": "EIC", "text": "Want to do a quick word game?", "replies": ["Sure", "Later"] }, "YMB": { "id": "YMB", "text": "Okay, tomorrow. Cya!", "replies": ["bye Woeb ...

After the geolocation is retrieved, employing a callback function

I have been developing a web service program that tracks the location of users using geolocation. The program initiates geolocation to locate the user and then proceeds to record the location. However, since geolocation relies on a callback function to ret ...

Having trouble retrieving an element's attribute using jQuery

I am facing an issue with the following HTML code: <img src="http://localhost:82/Clone//images/hosts/Kinx_9843a.jpg" data-name="/images/hosts/K_9843a.jpg" alt=""> I am attempting to achieve the following functionality: $('body').on(&apos ...

Ensuring the accuracy of URLs using JavaScript

I am developing a form with an input field for entering a URL and a submit button. I want to incorporate JavaScript validation to show an alert box when a correct URL is entered. Is it achievable using JavaScript? If so, can you please guide me on how to i ...

Creating dynamic controls in AngularJS relies on the ability to generate different elements

In my application, I am facing an issue where dynamic controls loaded into a block are not updating the data using AngularJS. The static controls work fine with AngularJS, but the dynamic ones do not. Below is the code snippet showing what I have tried: ...

"Exploring the process of retrieving data from a request in Node.js with the help of the Express

I'm encountering some issues with integrating a "login" form into my Node.js script. While I can get it to work using a static HTML page, utilizing a dynamic ".ejs" page is causing trouble as my form fields are showing up as "undefined". var helmet = ...

Node and Express continuing to send requests in a loop even after the response has been completed

After trying numerous solutions without success, my mind has reached its limit. So here I am seeking guidance. How can this seemingly simple code snippet (let's name it app.js): var express = require('express'); var app = express(); app.us ...

Error encountered when uploading mp3 file to S3 node due to size limitation

Currently, I am utilizing Node to transmit mp3 files to Amazon S3. However, after uploading the file, it shows a size of 9.0 Bytes and when attempting to play the audio from the public URL, it does not work as expected. Here is my current code snippet: rou ...