在 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 轻松实现::同步()
.有关说明和示例,请参阅 ?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屋!