我已将传单TextPath插件添加到一个闪亮的应用程序中,类似于此示例.这非常有效:
output$fullscreen_map <- renderLeaflet({
points <- points_reactive()
points %>%
leaflet() %>%
addTiles() %>%
fitBounds(~min(lon), ~min(lat), ~max(lon), ~max(lat)) %>%
registerPlugin(textPathPlugin) %>%
onRender("function(el, x, data) {
data = HTMLWidgets.dataframeToD3(data);
data = data.map(function(val) { return [val.lat, val.lon]; });
var layer = L.polyline(data);
layer.on('mouseover', function () {
this.setText(' ? ', {repeat: true, attributes: {fill: 'blue'}});
});
layer.on('mouseout', function () {
this.setText(null);
});
layer.addTo(this);
}", data = points)
})
Run Code Online (Sandbox Code Playgroud)
根据我现在要使用的文档,leafletProxy()以便在响应数据源发生更改时不会重绘整个映射.唉,使用以下代码片段
leafletProxy("fullscreen_map", data = points) %>%
onRender("function(el, x, …Run Code Online (Sandbox Code Playgroud) 我有一个闪亮的应用程序,它涉及在地图上绘制大量线条。我想使用微调器向用户显示渲染正在进行中。大多数闪亮的方法都不起作用,因为它们只在数据发送到传单时显示微调器,而不是在传单渲染时显示。Leaflet.Spin 插件看起来很有前途,但我一直在努力让它工作。我一直在遵循的例子是
https://gist.github.com/jcheng5/c084a59717f18e947a17955007dc5f92
以 polylineDecorator 为例的传单插件和传单代理
当线条(本例中的圆圈)渲染时,如何让 js 事件正确触发并显示 Leaflet.Spin?谢谢!
library(shiny)
library(leaflet)
library(htmltools) # for htmlDependency
library(htmlwidgets) # for onRender
# https://gist.github.com/jcheng5/c084a59717f18e947a17955007dc5f92
# https://stackoverflow.com/questions/52846472/leaflet-plugin-and-leafletproxy-with-polylinedecorator-as-example
spinPlugin <- htmlDependency(
"spin.js",
"2.3.2",
src = c(href = "https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2"),
script = "spin.min.js") # there's no spin.css
leafletspinPlugin <- htmlDependency(
"Leaflet.Spin",
"1.1.2",
src = c(href = "https://cdnjs.cloudflare.com/ajax/libs/Leaflet.Spin/1.1.2"),
script = "leaflet.spin.min.js")
registerPlugin <- function(map, plugin) {
map$dependencies <- c(map$dependencies, list(plugin))
map
}
# Note: Ctrl-Shift-J opens the javascript console in the browser
spin_event <- "function(el, x) …Run Code Online (Sandbox Code Playgroud)