L.mapbox.accessToken = 'pk.eyJ1IjoibWFwdGFzdGlrIiwiYSI6IjNPMkREV1kifQ.2KGPFZD0QaGfvYzXYotTXQ'; var handle = document.getElementById('handle'), start = false, startTop; var map = L.mapbox.map('map', 'maptastik.nc2c5lfc',{ minZoom: 16, maxZoom: 18 }) .setView([38.042966,-84.495238], 17); var overlay = L.tileLayer('http://mapwarper.net/maps/tile/10505/{z}/{x}/{y}.png', { zIndex: 2, attribution: 'University of Kentucky Libraries, Map Warper', opacity: 0.75 }) .addTo(map); document.onmousemove = function(e) { if (!start) return; // Adjust control. handle.style.top = Math.max(-5, Math.min(195, startTop + parseInt(e.clientY, 10) - start)) + 'px'; // Adjust opacity. overlay.setOpacity(1 - (handle.offsetTop / 200)); }; handle.onmousedown = function(e) { // Record initial positions. start = parseInt(e.clientY, 10); startTop = handle.offsetTop - 5; return false; }; document.onmouseup = function(e) { start = null; };