- See: Swipe between maps
aObject The first Mapbox GL MapbObject The second Mapbox GL Mapcontainer(string | HTMLElement) An HTML Element, or an element selector string for the compare container. It should be a wrapper around the two map Elements.optionsObjectoptions.orientationstring The orientation of the compare slider.verticalcreates a vertical slider bar to compare one map on the left (map A) with another map on the right (map B).horizontalcreates a horizontal slider bar to compare on mop on the top (map A) and another map on the bottom (map B). (optional, defaultvertical)options.mousemoveboolean Iftruethe compare slider will move with the cursor, otherwise the slider will need to be dragged to move. (optional, defaultfalse)
var compare = new mapboxgl.Compare(beforeMap, afterMap, '#wrapper', {
orientation: 'vertical',
mousemove: true
});Set the position of the slider.
xnumber Slider position in pixels from left/top.
Adds a listener for events of a specified type.
typestring The event type to listen for; one ofslideend.fnlistenerFunction The function to be called when the event is fired.
Returns Compare this
Fire an event of a specified type.
Returns Compare this
Removes an event listener previously added with Compare#on.
typestring The event type previously used to install the listener.fnlistenerFunction The function previously installed as a listener.
Returns Compare this
Removes the control from the DOM and stop synchronizing the two maps.