Skip to content

@tyrasd /index.html forked from tmcw/index.html
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
compares OSM-Carto with the older "Mapnik" style. http://bl.ocks.org/tyrasd/raw/6164696
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v0.6.7/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'>
body {
font:20px/20px 'Helvetica Neue',sans-serif;
background:#f2efe9;
}
#swipe {
background:#222;
position:absolute;
bottom:0;
left:0;
right:0;
z-index:1000;
padding:10px;
height:30px;
}
#swipe #handle {
position:absolute;
height:20px;
padding:5px;
background:#fff;
font-weight:bold;
border:1px solid #333;
color:blue;
cursor:pointer;
-webkit-user-select: none;
}
.map-attribution {
bottom: 50px;
}
#osm1 {
position:absolute;
left:10px;
top:0px;
z-index:99;
}
#osm2 {
position:absolute;
right:10px;
top:0px;
z-index:99;
}
</style>
<div id='swipe'>
<div id='handle'>drag</div>
</div>
<div id='map'></div>
<h1 id='osm1'>osm-carto</h1>
<div id='osm2'>
<h1>old "Mapnik" (via OsmAnd)</h1>
<p style="max-width: 25em;"><i>note that the OsmAnd based rendering diverged a bit from the original Mapnik style. See <a href="http://bl.ocks.org/tyrasd/raw/67a00dbb869456094373">here</a> for a more original rendering (hosted by openstreetmap.nl), which unfortunately is only available for the Netherlands.</i></p>
</div>
<script>
var map = mapbox.map('map'),
layers = document.getElementById('layers');
map.setZoomRange([0,18])
map.addLayer(MM.TemplatedLayer('http://mapnik.osmand.net/{Z}/{X}/{Y}.png'));
map.addLayer(MM.TemplatedLayer('http://tile.openstreetmap.org/{Z}/{X}/{Y}.png'));
map.zoom(6).center({ lat: 48, lon: 9 });
map.ui.hash.add();
map.ui.attribution.add()
.content('<a href="http://opentreetmap.org/copyright">&copy;</a>');
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(400);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.