1
Using arbitrary Leaflet JS plugins with Leaflet for Rのサンプルコードを使用してリーフレットサイドバイサイドプラグインを実装しようとしました。シンプルに現れ、これまでのところ成功していない。私は何が間違っているのか分かりませんでした。本当に、あなたの返信を感謝します。 ありがとう、リーフレットサイドバイサイドプラグインをRで使用
library(leaflet)
library(htmltools)
library(htmlwidgets)
LeafletSideBySidePlugin <- htmlDependency("leaflet-side-by-side","2.0.0",
src = c(href="https://github.com/digidem/leaflet-side-by-side"),
script="leaflet-side-by-side.js")
# 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
}
leaflet() %>% addTiles() %>%
setView(lng = 12, lat = 50, zoom = 4) %>%
# Register leaflet-side-by-side plugin on this map instance
registerPlugin(LeafletSideBySidePlugin) %>%
onRender("
function(el, x) {
var mylayer1 = L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
maxZoom: 18
})
var mylayer2 = L.tileLayer(
'//stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png',{
maxZoom: 14
})
L.control.sideBySide(mylayer1, mylayer2).addTo(this);
")
サイドバイサイドが非常にいいです。必ずしも同じではありませんが、 'mapview'はリーフレット同期http://environmentalinformatics-marburg.github.io/mapview/sync/sync.htmlを提供しています。 – timelyportfolio
私はどのように光沢のある 'sync'または 'latticeView'プロットを生成するかを知ることができます。私はplotOutputとleafletOutputを試しましたが、表示されません。 – SatishR
@timelyportfolio私は '同期'と 'latticeView'の両方がとても素敵なことをすることができ、次のような方法で輝いているが成功しなかったことが分かった。あなたのフィードバックを高く評価してください:server.r:output $ plot1 < - renderLeaflet( m1 <-leaflet(EUGegrphclData)%>%addPolygons(...、fillColor = "red") m2 <-leaflet(EUGegrphclData)% >%addPolygons(...、fillColor = "blue") sync(m1、m2) } ' EUGegraphclData - ui.rの空間オブジェクトです ' leafletOutput( 'plot1') – SatishR