D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
knownasilya
Full window
Github gist
Simple createLayer https://bl.ocks.org/knownasilya/26336a57eefb63ecbe14266098ac2f10
<!doctype html> <html> <head> <title>createLayer</title> <link href='https://fonts.googleapis.com/css?family=Alike' rel='stylesheet' type='text/css'> <style> html, body, #map { height: 100%; padding: 0; margin: 0; } </style> <link rel="stylesheet" href="https://libs.cartocdn.com/cartodb.js/v3/3.15.9/themes/css/cartodb.css" /> <script src="https://libs.cartocdn.com/cartodb.js/v3/3.15.9/cartodb.js"></script> <script type="text/javascript"> function main() { var layer = L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="https://cartodb.com/attributions">CartoDB</a>' }); var map = L.map('map', { center: [40.7127837, -74.0059413], zoom: 6 }); map.addLayer(layer); var bounds = [[-42, -126],[58, 154]]; map.fitBounds(bounds); cartodb.createLayer(map, 'https://appgeo.cartodb.com/u/clientdemos/api/v2/viz/ab40dbb2-2361-11e6-b6ec-0e31c9be1b51/viz.json') .addTo(map); } window.onload = main; </script> </head> <body> <div id="map"></div> <canvas id="test" style="background-color: black;"></canvas> </body> </html>
https://libs.cartocdn.com/cartodb.js/v3/3.15.9/cartodb.js