He estado tratando de crear un mapa de folleto visual en R que sincronice dos mapas (dos mapas se muestran uno al lado del otro y cuando mueves/haces zoom en un mapa, el otro mapa se mueve junto con eso). Esto funciona bien usando el paquete R leafsync , vea esta imagen . Sin embargo, el objetivo final es usar este R Visual en un informe de PowerBI y el paquete leafsync no es compatible con PowerBI. Por lo tanto, me gustaría usar el paquete Javascript Leaflet.Sync en una función OnRender al crear el objeto visual R. A continuación se muestra el código que tengo hasta ahora, donde map1 y map2 son imágenes de mapas de folletos creadas anteriormente en R:
# A function that takes a plugin htmlDependency object and adds # it to the map. This ensures that however or whenever the map # gets rendered, the plugin will be loaded into the browser. registerPlugin <- function(map, plugin) { map$dependencies <- c(map$dependencies, list(plugin)) map } # This tells htmlwidgets about our plugin name, version, and where to find the script syncPlugin <- htmlDependency("Leaflet.Sync", "0.2.4", src = c(href = "https://cdn.jsdelivr.net/gh/jieter/Leaflet.Sync/"), script = list("L.Map.Sync.js")) map2 = map2 %>% # Register Sync Plugin on this map instance registerPlugin(syncPlugin) %>% # Add your custom JS logic here. The `this` keyword refers to the Leaflet (JS) map object. onRender("function(el, x, data) { this.sync(data); data.sync(this); }", data=map1) map2Actualmente, esto no funciona (el resultado que obtengo es la imagen map2 original que no se puede mover ni hacer zoom, la imagen map1 no se ve por ninguna parte), sin embargo, no estoy seguro de por qué y, por lo tanto, tengo un par de preguntas:
¡Muchas gracias de antemano por cualquier ayuda brindada! :)