在 R/Rmarkdown 中同步两个传单地图 [英] Synchronizing two leaflet maps in R / Rmarkdown

查看:14
本文介绍了在 R/Rmarkdown 中同步两个传单地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JS 传单允许两个地图同步.查看同步传单地图的示例这里.

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
```

推荐答案

注意,我们已经在 ma​​pview 包中实现了@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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆