powered by
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.
compare( map1, map2, width = "100%", height = NULL, elementId = NULL, mousemove = FALSE, orientation = "vertical" )
A comparison widget.
A mapboxgl or maplibre object representing the first map.
mapboxgl
maplibre
A mapboxgl or maplibre object representing the second map.
Width of the map container.
Height of the map container.
An optional string specifying the ID of the container for the comparison. If NULL, a unique ID will be generated.
A logical value indicating whether to enable swiping during cursor movement (rather than only when clicked).
A string specifying the orientation of the swiper, either "horizontal" or "vertical".
if (FALSE) { library(mapgl) library(mapgl) m1 <- mapboxgl(style = mapbox_style("light")) m2 <- mapboxgl(style = mapbox_style("dark")) compare(m1, m2) }
Run the code above in your browser using DataLab