Skip to content

Instantly share code, notes, and snippets.

@iriberri
Last active August 29, 2015 14:09
Show Gist options
  • Save iriberri/27bf1de94f41b1c20f34 to your computer and use it in GitHub Desktop.
Save iriberri/27bf1de94f41b1c20f34 to your computer and use it in GitHub Desktop.
Custom legend by CSS - CartoDB
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />
<!--Switch between the different themes changing the stylesheet below - light-theme.css |dark-theme.css -->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
<style>
#map .cartodb-legend-stack { position: absolute; left: 60px; width: 250px; top:10px; background: rgba(58,58,48,0.5); padding: 10px; z-index: 99; bottom: auto;}
</style>
<style>
#logo { position: absolute; left: 20px; bottom: 90px; padding: 0px; z-index: 99; }
</style>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.ie.css" />
<![endif]-->
</head>
<body>
<div class="map" id="map"></div>
<div class="legend" id="legend"></div>
<div class="logo" id="logo"><a href="http://www.CartoDB.com"><img src="http://cartodb.s3.amazonaws.com/tumblr/img/logo2.png"/></a></div>
<!-- include cartodb.js library -->
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.js"></script>
<script>
function main() {
cartodb.createVis('map', 'http://team.cartodb.com/api/v2/viz/7fb47ab0-bdca-11e4-98cf-0e8dde98a187/viz.json', {
})
.done(function(vis, layers) {
})
.error(function(err) {
console.log(err);
});
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment