knitr::opts_chunk$set(echo = TRUE)

library(rgee)
library(shiny)
library(leaflet)

ee_Initialize()
library(leaflet.minicharts)
library(manipulateWidget)
library(leafsync)

map_sync <- function(m1, m2, type = c("widget", "leafsync"), ...) {
  FUN = switch(type,
    "widget" = manipulateWidget::combineWidgets, 
    "leafsync" = leafsync::sync
  )
  if (type == "widget") {
    m1 = m1 %>% syncWith("one")
    m2 = m2 %>% syncWith("one")
  }
  m <- FUN(m1, m2, ...)
  m
}

m1 <- Map$addLayer(eeObject = ee$Image("CGIAR/SRTM90_V4")) 
m2 <- Map$addLayer(
  eeObject = ee$Image("CGIAR/SRTM90_V4"),
  visParams = list(min=0,max=3000)
)

Figure 1. manipulateWidget map linker

map_sync(m1, m2, "widget", nrow = 1, width = 950, height = 400)

Figure 2. leafsync map linker

map_sync(m1, m2, "leafsync")


rpkgs/rgee2 documentation built on May 31, 2024, 6:58 p.m.