Skip to content

Instantly share code, notes, and snippets.

@michellechandra
Last active January 14, 2016 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michellechandra/2cc89ed3eeea18a6181a to your computer and use it in GitHub Desktop.
Save michellechandra/2cc89ed3eeea18a6181a to your computer and use it in GitHub Desktop.
Basemap Example - CartoDB
<!DOCTYPE html>
<html>
<head>
<title>Basemap Example</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" />
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
function main() {
var map = L.map('map', {
center: [40.742216, -74.20655],
zoom: 11,
zoomControl: true
});
L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png', {
attribution: 'Stamen'
}).addTo(map);
cartodb.createLayer(map, 'https://team.cartodb.com/u/chandra/api/v2/viz/fd5891d6-7db4-11e5-84fe-0e31c9be1b51/viz.json')
.addTo(map)
.on('done', function(layer) {
}).on('error', function() {
console.log("some error occurred");
});
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment