Running into issues syncing two leaflet maps on different tabs.
After looking at previous entries (Synchronizing two leaflet maps in R / Rmarkdown), the solution provided by @TimSalabim does not work because the maps are on different tabs.
Here is a MWE RMarkdown example:
---
title: "QuestionforStackOverflow"
output:
flexdashboard::flex_dashboard:
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(leaflet)
```
Tab One
======================================================================
```{r tab1}
output$map1 <-
renderLeaflet(
leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
setView(-93.65, 42.0285, zoom = 4)
)
leafletOutput("map1")
```
Tab Two
======================================================================
```{r tab2}
output$map2 <-
renderLeaflet(
leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
setView(-93.65, 42.0285, zoom = 4)
)
leafletOutput("map2")
```
I want a two way change. Any view changes to map1 -- changes map2 OR any changes to map2 will change map1.
Ideally: if you scroll into St. Louis on map1, map2 will have the same zoom level on St. Louis.
Right now, there is no interactivity between the two maps. Is there a way to make them sync?