Created
December 6, 2012 23:28
-
-
Save tmcw/4229391 to your computer and use it in GitHub Desktop.
Layer Switching and Interaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.6/mapbox.js'></script> | |
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.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%; } | |
select { | |
position:absolute; | |
top:5px; | |
right:5px; | |
z-index:99; | |
} | |
</style> | |
</head> | |
<body> | |
<div id='map'></div> | |
<select> | |
<option value='cornellcalsip.IP-Experiences'>Experiences</option> | |
<option value='cornellcalsip.ip-hhh'>hhh</option> | |
<option value='cornellcalsip.ip-programs'>programs</option> | |
</select> | |
<script> | |
//map | |
var map = mapbox.map('map'); | |
//layers | |
map.zoom(3); | |
map.ui.zoomer.add(); | |
map.interaction.auto(); | |
map.ui.attribution.add() | |
.content('To pan, click on map to drag. To zoom out/in, use mouse wheel or +/- buttons at top left.'); | |
map.addLayer(mapbox.layer()); | |
$("select").change(function(e) { | |
e.preventDefault(); | |
map.getLayerAt(0).id($(this).val(), function() { | |
map.interaction.refresh(); | |
}); | |
}).trigger('change'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment