if you want to use all the features of cartodb (infowindows, legends, dynamic layers) with mapbox basemaps
http://bl.ocks.org/javisantana/7200781
if you want to use mapbox.js features and show a cartodb layer (without any cartodb feature)
if you want to use all the features of cartodb (infowindows, legends, dynamic layers) with mapbox basemaps
http://bl.ocks.org/javisantana/7200781
if you want to use mapbox.js features and show a cartodb layer (without any cartodb feature)
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Leaflet example | CartoDB.js</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="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" /> | |
<!--[if lte IE 8]> | |
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v2/themes/css/cartodb.ie.css" /> | |
<![endif]--> | |
</head> | |
<body> | |
<div id="map"></div> | |
<!-- include cartodb.js library --> | |
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.uncompressed.js"></script> | |
<Script src='http://api.tiles.mapbox.com/mapbox.js/v1.2.0/mapbox.standalone.js'></Script> | |
<script> | |
function main() { | |
var map = new L.Map('map', { | |
zoomControl: false, | |
center: [43, 0], | |
zoom: 3 | |
}); | |
L.mapbox.tileLayer('examples.map-20v6611k').addTo(map) | |
cartodb.createLayer(map, 'http://documentation.cartodb.com/api/v2/viz/2b13c956-e7c1-11e2-806b-5404a6a683d5/viz.json').addTo(map) | |
} | |
// you could use $(window).load(main); | |
window.onload = main; | |
</script> | |
</body> | |
</html> |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charaset=utf-8 /> | |
<title>mapbox.js + cartodb.js</title> | |
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' /> | |
<script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.js'></script> | |
<link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.css' rel='stylesheet' /> | |
<script src='https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/cartodb.core.js'></script> | |
<style> | |
body { margin:0; padding:0; } | |
#map { position:absolute; top:0; bottom:0; width:100%; } | |
</style> | |
</head> | |
<body> | |
<div id='map'></div> | |
<script> | |
var map = L.mapbox.map('map', 'examples.map-i86nkdio'); | |
// cartodb layers | |
var tiles = new cartodb.Tiles({ | |
user_name: 'examples', | |
sublayers: [{ | |
sql: 'select * from ne_10m_populated_p_2', | |
cartocss: '#ne_10m_populated_p_2{ marker-fill: #F11810; marker-opacity: 0.9; marker-allow-overlap: true; marker-placement: point; marker-type: ellipse; marker-width: 7.5; marker-line-width: 2; marker-line-color: #000; marker-line-opacity: 0.2; }' | |
}] | |
}) | |
// get tilejson with interaction for layer 0 | |
tiles.getTileJSON(0, function(tilejson) { | |
L.mapbox.tileLayer(tilejson).addTo(map) | |
}); | |
</script> | |
</body> | |
</html> |