Skip to content

Instantly share code, notes, and snippets.

@jsanz
Last active August 29, 2015 14:22
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 jsanz/4ab8cdef2b42c5f651c7 to your computer and use it in GitHub Desktop.
Save jsanz/4ab8cdef2b42c5f651c7 to your computer and use it in GitHub Desktop.
CartoDB.js examples: add layer

Examples on using CartoDB.js.

Adding a VizJSON to a Leaflet Map.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Ejemplos IGN</title>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.14/themes/css/cartodb.css" />
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.14/cartodb.js"></script>
</head>
<body>
<div id="map"></div>
<script>
$( document ).ready(function() {
//Create the leaflet map
var map = L.map('map', {
zoomControl: true,
center: [39.583,2.670],
zoom: 12
});
// PNOA WMS
L.tileLayer.wms("http://www.ign.es/wms-inspire/pnoa-ma", {
layers: 'OI.OrthoimageCoverage',
format: 'image/jpeg',
transparent: false,
attribution: "IGN"
}).addTo(map);
//Add a CartoDB Layer
var viz = 'https://ignspaintest.cartodb.com/api/v2/viz/2d215c0c-08ff-11e5-9e8a-0e018d66dc29/viz.json';
cartodb.createLayer(map, viz).addTo(map);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment