另请参阅问题传单插件和 leafletProxy。
我想在 R 的传单中 使用polylineDecorator 插件。
按照如何使用 R 中的传单插件的说明,如果我将该方法与leaflet(). 请参阅第一个示例,它按我想要的方式工作。但如果我尝试使用相同的方法leafletProxy(),它不会做任何事情,我只会得到没有装饰器的线。请参阅第二个示例。
我的问题是如何将传单插件与 R 一起使用leafletProxy()。
示例 1:有效的版本,不使用 lefletProxy。
library(shiny)
library(leaflet)
library(htmltools)
download.file(
'https://raw.githubusercontent.com/bbecquet/Leaflet.PolylineDecorator/master/dist/leaflet.polylineDecorator.js',
'leaflet.polylineDecorator.js')
polylineDecoratorPlugin <- htmlDependency('Leaflet.PolylineDecorator',
'1.6.0',
src = normalizePath('.'),
script = 'leaflet.polylineDecorator.js')
registerPlugin <- function(map, plugin) {
map$dependencies <- c(map$dependencies, list(plugin))
map
}
ui <- bootstrapPage(
tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
leafletOutput("map", width = "100%", height = "100%")
)
server <- function(input, output) {
dat <- …Run Code Online (Sandbox Code Playgroud)