I'm currently developing a shiny App, and as I'm trying to use a leaflet plugin that hasn't been translated in a R package at the moment, I'm using a var map in a js script (I use this script in my UI.R), the fact is that I would like in the server part to be able to communicate with this map, with for example a leaflet proxy to add tiles on it, but I didn't manage to make the server part communicate with that Js var.
Maybe if you have a clew of what's the problem you could help me a lot.
Yes you can do it.
tags$script(src="demo.js")
var map = ...
setTimeout(function() {
Shiny.onInputChange("mapInR", map);
}, 10);
Now you can pass the value of map from javascript to R.
In server.R you just need to check for javascript value map as:
server <- function(input, output) {
useMapInR <- reactive({ input$mapInR })
}
Now whenever value of map changes in javascript it will get reflected in useMapInR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With