How would I receive data, created in a .js
file in the server.R
in shiny?
I am using the leaflat library and I need the extend the LatLngBounds of the current map view has. I need this variable in the server.R
for furhter processing.
So i have
mycode.js
//get bounds of extend of view
$(document).ready(function() {
var myBounds = map.getBounds();
Shiny.onInputChange("bounds", myBounds);
});
which I include in the ui.R
like
tags$body(tags$script(src="mycode.js"))
Thats how my Server.R
looks like:
myBoundsR <- reactive(
as.numeric(input$bounds)
print(input$bounds)
)
However, how would I receive the data in the server.R
file, coming from my mycode.js
?
It feels like Shiny.addCustomMessageHandler
is only to receive data in .js
(or .R
) while session$sendCustomMessage
can only be used in the .R
files? What would I use to send something from a .js
file to the server.R
file?!
Or can I simply use the variable bound
as if I created it in the server.R
file?!