Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

addSidebyside

Add Side by Side View


Description

A Leaflet control to add a split screen to compare two map overlays. The plugin works with Panes, see the example.

Usage

addSidebyside(
  map,
  layerId = NULL,
  leftId = NULL,
  rightId = NULL,
  options = list(thumbSize = 42, padding = 0)
)

Arguments

map

a map widget

layerId

the layer id, needed for removeSidebyside

leftId

the layerId of the Tile layer that should be visible on the left side

rightId

the layerId of the Tile layer that should be visible on the right side

options

A list of options. Currently only thumbSize and padding can be changed.

Value

the new map object

Note

It is currently not working correctly if the baseGroups are defined in addLayersControl.

References

See Also

Other Sidebyside Functions: removeSidebyside()

Examples

library(leaflet)
library(leaflet.extras2)

leaflet(quakes) %>%
  addMapPane("left", zIndex = 0) %>%
  addMapPane("right", zIndex = 0) %>%
  addTiles(group = "base", layerId = "baseid",
           options = pathOptions(pane = "right")) %>%
  addProviderTiles(providers$CartoDB.DarkMatter, group="carto", layerId = "cartoid",
                   options = pathOptions(pane = "left")) %>%
  addCircleMarkers(data = breweries91[1:15,], color = "blue", group = "blue",
                   options = pathOptions(pane = "left")) %>%
  addCircleMarkers(data = breweries91[15:20,], color = "yellow", group = "yellow") %>%
  addCircleMarkers(data = breweries91[15:30,], color = "red", group = "red",
                   options = pathOptions(pane = "right")) %>%
  addLayersControl(overlayGroups = c("blue","red", "yellow")) %>%
  addSidebyside(layerId = "sidecontrols",
                rightId = "baseid",
                leftId = "cartoid")

leaflet.extras2

Extra Functionality for 'leaflet' Package

v1.1.0
GPL-3 | file LICENSE
Authors
Gatscha Sebastian [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.