public
Last active

  • Download Gist
index.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.6/mapbox.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v0.6.6/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<style type='text/css'>
#swipe {
background:#fff;
position:absolute;
bottom:0;
left:0;
right:0;
z-index:1000;
padding:10px;
height:30px;
}
#swipe #handle {
position:absolute;
height:20px;
padding:5px;
background:#aaa;
font-weight:bold;
border:1px solid #333;
cursor:pointer;
-webkit-user-select: none;
}
.map-attribution {
bottom: 50px;
}
</style>
<div id='swipe'>
<div id='handle'>drag</div>
</div>
<div id='map'></div>
<script>
var map = mapbox.map('map'),
layers = document.getElementById('layers');
 
map.addLayer(mapbox.layer().id('examples.map-a1dcgmtr', function() {
map.addLayer(mapbox.layer().id('examples.map-20v6611k', function() {
map.zoom(3);
map.ui.zoomer.add();
map.ui.zoombox.add();
map.ui.legend.add();
map.ui.attribution.add();
map.ui.refresh();
map.interaction.auto();
 
var l_parent = map.getLayerAt(1).parent,
handle = document.getElementById('handle'),
dragging = false;
 
handle.onmousedown = function() { dragging = true; return false;}
document.onmouseup = function() { dragging = false; }
document.onmousemove = function(e) {
if (!dragging) return;
setDivide(MM.getMousePoint(e, map).x);
}
 
function setDivide(x) {
x = Math.max(0, Math.min(x, map.dimensions.x));
handle.style.left = (x - 20) + 'px';
l_parent.style.clip = 'rect(0px ' + x + 'px 9999999px 0px)';
}
 
setDivide(300);
}).composite(false));
}).composite(false));
</script>
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.