【发布时间】:2015-08-25 00:53:05
【问题描述】:
我有一个使用传单库的闪亮应用程序。
我现在需要使用get.Bounds() 函数来获取一些坐标。很简单(js file):
var myBounds = map.getBounds();
console.log(myBounds);
然后我需要将坐标发送给闪亮进行进一步处理(也在我的js file:
Shiny.onInputChange("bounds", myBounds);
要查看这是否有效,它在server.R 中这样做了:
observe({
print(input$bounds)
})
但是,当我在 R 控制台中运行应用程序时,会出现 NULL。通过我的.js file 中的console.log,坐标会打印在Firefox 控制台中。
但是,它时不时地起作用。当我运行 Shiny App 十次时,它有时会运行 3 次,有时会运行 4 次,有时甚至不会运行。我得到坐标并将它们打印到 R 控制台中。
我也尝试过reactive,但这并没有成功。这里的行为相同。
#get extensions of map
myBoundsR <- reactive({
input$bounds
})
#print extensions
observe(print(myBoundsR()))
这是为什么?!为什么这种行为不合时宜?!为什么Shiny.onInputChange("bounds", myBounds);这行不把坐标发给server.R?
【问题讨论】:
标签: javascript r shiny leaflet