Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created December 18, 2012 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tmcw/4331865 to your computer and use it in GitHub Desktop.
Save tmcw/4331865 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js'></script>
<script src='http://code.jquery.com/jquery-1.8.3.min.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:300px; }
#switch { position:absolute; top:0; bottom:0; left: 300px width:300px; }
</style>
</head>
<body>
<div id='map'></div>
<div id='switch'>
<button data-layer='0'>a</button>
<button data-layer='1'>b</button>
<button data-layer='2'>c</button>
</div>
<script>
mapbox.load(['examples.map-vyofok3q', 'tmcw.map-5vaivzxq', 'tmcw.map-u5tnqr3f'], function(o) {
var map = mapbox.map('map').zoom(3);
map.addLayer(o[0].layer);
$('button').click(function() {
map.setLayerAt(0, o[$(this).data('layer')].layer);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment