Skip to content

Instantly share code, notes, and snippets.

@maptastik
Created September 5, 2015 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maptastik/d9188e7ca3e7ecbfd01c to your computer and use it in GitHub Desktop.
Save maptastik/d9188e7ca3e7ecbfd01c to your computer and use it in GitHub Desktop.
Commonwealth Stadium - Alternative Configuration, 1973 map w/ slider
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Commonwealth Stadium - Alternative Configuration, 1973</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.2/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.2/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<style>
.title {
position: absolute;
right: 20px;
top: 10px;
font-family: "Proxima Nova", Montserrat, sans-serif;
text-align: right;
max-width: 600px;
z-index: 10001;
}
h1, h2 {
font-weight: 100;
color: #fff; /* offical UK Kentucky blue */
line-height: 5px;
text-shadow: 0 0 0.2em #000;
}
h1 {
font-size: 2em;
}
h2 {
font-size: 1em;
}
.ui-opacity {
background:#FFF;
position:absolute;
left:10px;
top:70px;
height:200px;
width:28px;
border:1px solid rgba(0,0,0,0.4);
border-radius:3px;
z-index:1000;
}
.ui-opacity .handle {
position:absolute;
background:#404040;
left:0;
top:20px;
width:26px;
height:10px;
border-radius:1px;
cursor:pointer;
cursor:ns-resize;
}
.ui-opacity .handle:hover {
background:#303030;
}
</style>
<div class="title">
<h1>Commonwealth Stadium</h1>
<h2> Alternative Configuration, 1973</h2>
</div>
<div id='map'></div>
<div id='control' class='ui-opacity'>
<div id='handle' class='handle'></div>
</div>
<script>
L.mapbox.accessToken = 'pk.eyJ1IjoibWFwdGFzdGlrIiwiYSI6IjNPMkREV1kifQ.2KGPFZD0QaGfvYzXYotTXQ';
var handle = document.getElementById('handle'),
start = false,
startTop;
var map = L.mapbox.map('map', 'maptastik.nc2c5lfc',{
minZoom: 14,
maxZoom: 19
})
.setView([38.021800, -84.509486], 16);
var overlay = L.tileLayer('http://mapwarper.net/maps/tile/10571/{z}/{x}/{y}.png', {
zIndex: 2,
attribution: '<a href="http://www.kyphotoarchive.com/2015/09/04/plans-for-roads-around-commonwealth-stadium-1973/" target="_blank">Kentucky Photo Archive</a>, <a href="http://mapwarper.net/maps/10571" target="_blank">Map Warper</a>'
})
.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;
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment