← Back to Main

Package - Swiper (interactive)

This page is used to showcase loading "Swiper" package with different configuration.

How to use

The swiper draws a draggable divider on the map and clips the selected layers to one side of it, letting you compare layers. Drag the handle (or focus it and use the arrow keys) to move the divider. The swiper follows map resizing automatically.

Console API examples:

const swiper = cgpv.api.getMapViewer('map1').plugins['swiper'];
swiper.activateForLayer('swipe6/lakes', 'right');
swiper.setLayerSide('swipe6/lakes', 'left');
swiper.deActivateForLayer('swipe6/lakes');
swiper.deActivateAll();
swiper.setOrientation('horizontal');

// Bulk layer updates and interactive-mode state use the controller:
const { swiperController } = cgpv.api.getMapViewer('map1').controllers;
swiperController.setLayers([{ layerPath: 'swipe6/lakes', side: 'right' }]);
swiperController.setInteractive(true);

Configuration with supported layers type (WMS, XYZ, WFS, GeoJSON, OGC Feature API and GeoCore)