在R/Rmarkdown中同步两个传单地图 [英] Synchronizing two leaflet maps in R / Rmarkdown
问题描述
JS leaflet allows two maps to be synchronized. See an example of synchronized leaflet maps here.
我想在R
中实现同步的传单地图,更具体地说是在Rmarkdown/knitr
中实现.
I would like to implement synchronized leaflet maps in R
and more specifially in Rmarkdown/knitr
.
Preferably, the maps should shown next to each other horizontally (just like in the example).
这是我要同步的两个地图的最小Rmarkdown(.Rmd
)示例.
解决方案不必基于mapview
包.真的欢迎任何解决方案(-:
Here is a minimal Rmarkdown (.Rmd
) example of two maps I would like to sync.
The solution does not have to be based on the the mapview
package. Any solution is welcome really (-:
---
title: "How to sync 2 leaflet maps"
author: "me"
date: "2 April 2016"
output: html_document
---
```{r SETUP, include=FALSE}
library("mapview")
library("sp")
# load example data
data(meuse)
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
```
```{r MAPS}
mapView(meuse, zcol="copper")@map # MAP 1
mapview(meuse, zcol="soil")@map # MAP 2
```
推荐答案
注意,我们已经在包 mapview 中实现了@timelyportfolio提供的答案,因此现在可以使用mapview::sync()
轻松实现.有关说明和示例,请参见?mapview::sync
.
Note, we have implemented the answer provided by @timelyportfolio in package mapview so that this is now easily achievable using mapview::sync()
. See ?mapview::sync
for instructions and examples.
这篇关于在R/Rmarkdown中同步两个传单地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!