Last active
October 1, 2017 14:41
-
-
Save javisantana/f485d193884983820cd3 to your computer and use it in GitHub Desktop.
mapbox.js + cartodb.core.js - useful when you want to show cartodb tiles on top of mapbox layers
This file contains 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> | |
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment