Example of a Layer swipe map.
<!DOCTYPE html> <html> <head> <title>Layer Swipe example</title> <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.6.0/ol.css" type="text/css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.6.0/ol.js"></script> </head> <body> <div class="container-fluid"> <div class="row-fluid"> <div class="span12"> <div id="map" class="map"></div> <input id="swipe" type="range" style="width: 100%"> </div> </div> </div> <script> var osm = new ol.layer.Tile({ source: new ol.source.OSM() }); var bing = new ol.layer.Tile({ source: new ol.source.BingMaps({ key: 'Ak-dzM4wZjSqTlzveKz5u0d4IQ4bRzVI309GxmkgSVr1ewS6iPSrOvOKhA-CJlm3', imagerySet: 'Aerial' }) }); var map = new ol.Map({ layers: [osm, bing], target: 'map', controls: ol.control.defaults({ attributionOptions: /** @type {olx.control.AttributionOptions} */ ({ collapsible: false }) }), view: new ol.View({ center: [0, 0], zoom: 2 }) }); var swipe = document.getElementById('swipe'); bing.on('precompose', function(event) { var ctx = event.context; var width = ctx.canvas.width * (swipe.value / 100); ctx.save(); ctx.beginPath(); ctx.rect(width, 0, ctx.canvas.width - width, ctx.canvas.height); ctx.clip(); }); bing.on('postcompose', function(event) { var ctx = event.context; ctx.restore(); }); swipe.addEventListener('input', function() { map.render(); }, false); </script> </body> </html>