Created
March 28, 2017 15:39
-
-
Save ebrelsford/9a99aa3ffed5016b307a38fc9e2d7dcb to your computer and use it in GitHub Desktop.
Using legends in Carto.js v3
This file contains hidden or 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="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script> | |
<!-- | |
Load Carto's code so we can pull in our Carto maps. | |
--> | |
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" /> | |
<style> | |
html, body { | |
height: 100%; | |
margin: 0; | |
padding: 0; | |
width: 100%; | |
} | |
#map { | |
height: 100%; | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<div class="cartodb-legend color"> | |
<div class="legend-title">Watsan in Kibera</div> | |
<ul class="legend-list"> | |
<li><div class="bullet" style="background-color: #5F4690;"></div> water tap</li> | |
<li><div class="bullet" style="background-color: #EDAD08;"></div> water tank</li> | |
<li><div class="bullet" style="background-color: #187750;"></div> dumping site</li> | |
</ul> | |
</div> | |
<script> | |
$(document).ready(function () { | |
// | |
// Initialize map from CartoDB: create the map and store the data layer for later | |
// | |
cartodb.createVis('map', 'https://thenewschool.carto.com/u/brelsfoeagain/api/v2/viz/5d74528a-f60c-45c8-bfde-92ecd4c386d4/viz.json'); | |
}); | |
</script> | |
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment