Skip to content

Instantly share code, notes, and snippets.

@willwhite
Created September 14, 2012 17:45
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 willwhite/3723470 to your computer and use it in GitHub Desktop.
Save willwhite/3723470 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.5/mapbox.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v0.6.5/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
.counter {
z-index:999;
color:#fff;
position:absolute;
bottom:0;
left:50%;
font-size:52px;
text-align:center;
font-family:sans-serif;
background:black;
opacity:0;
padding:10px;
animation:cloud 1000ms linear;
-moz-animation:cloud 1000ms linear;
-webkit-animation:cloud 1000ms linear;
}
@keyframes {
0% { bottom:0px; }
50% { bottom:100px; opacity:1; }
100% { bottom:200px; }
}
@-moz-keyframes cloud {
0% { bottom:0px; }
50% { bottom:100px; opacity:1; }
100% { bottom:200px; }
}
@-webkit-keyframes cloud {
0% { bottom:0px; }
50% { bottom:100px; opacity:1; }
100% { bottom:200px; }
}
</style>
</head>
<body>
<div id='map'></div>
<script>
mapbox.load('examples.map-8ced9urs', function(o) {
var map = mapbox.map('map');
map.addLayer(o.layer);
map.centerzoom(o.center, o.zoom);
var last;
wax.mm.interaction()
.map(map)
.tilejson(o)
.on({
on: function(interaction) {
if (last == interaction.data.count) return; // Don't keep showing the same number over again.
last = interaction.data.count;
var map = document.getElementById('map');
var div = document.createElement('div');
div.appendChild(document.createTextNode(interaction.data.count));
div.className = 'counter';
map.appendChild(div);
setTimeout(function() {
map.removeChild(div);
}, 5000);
},
off: function(interaction) {
console.log('off');
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment