Skip to content

Instantly share code, notes, and snippets.

@ramiroaznar
Created July 29, 2016 08:16
Show Gist options
  • Save ramiroaznar/5b0ddb54e20d5a286082dee836e58363 to your computer and use it in GitHub Desktop.
Save ramiroaznar/5b0ddb54e20d5a286082dee836e58363 to your computer and use it in GitHub Desktop.
Set Legend within createVis
<!DOCTYPE html>
<html>
<head>
<title>GIS People | Set Legend within createVis</title>
<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>
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
</head>
<body>
<div id="map"></div>
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script>
<script>
mapUrl='https://gisp.carto.com/u/gispeople/api/v2/viz/60d4cbe2-2925-11e5-9287-0e9d821ea90d/viz.json'
cartodb.createVis('map', mapUrl, {
legends:true // set legends to true
})
.on('done', function(vis,layers) {
console.log(vis);
console.log(layers);
}).on('error', function() {
console.log("some error occurred");
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment