Create a Compare slider widget
compare.Rd
This function creates a comparison view between two Mapbox GL or Maplibre GL maps, allowing users to swipe between the two maps to compare different styles or data layers.
Usage
compare(
map1,
map2,
width = "100%",
height = NULL,
elementId = NULL,
mousemove = FALSE,
orientation = "vertical"
)
Arguments
- map1
A
mapboxgl
ormaplibre
object representing the first map.- map2
A
mapboxgl
ormaplibre
object representing the second map.- width
Width of the map container.
- height
Height of the map container.
- elementId
An optional string specifying the ID of the container for the comparison. If NULL, a unique ID will be generated.
- mousemove
A logical value indicating whether to enable swiping during cursor movement (rather than only when clicked).
- orientation
A string specifying the orientation of the swiper, either "horizontal" or "vertical".
Examples
if (FALSE) { # \dontrun{
library(mapgl)
library(mapgl)
m1 <- mapboxgl(style = mapbox_style("light"))
m2 <- mapboxgl(style = mapbox_style("dark"))
compare(m1, m2)
} # }