Created
September 13, 2015 08:54
-
-
Save ustroetz/2e680c389913b123abd3 to your computer and use it in GitHub Desktop.
CartoDB.js + Mapbox.js
This file contains hidden or 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> | |
| <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" /> | |
| <link href='https://api.tiles.mapbox.com/mapbox.js/v2.2.1/mapbox.css' rel='stylesheet' /> | |
| </head> | |
| <body> | |
| <div id="map"></div> | |
| <!-- include cartodb.js library --> | |
| <script src='https://api.tiles.mapbox.com/mapbox.js/v2.2.1/mapbox.js'></script> | |
| <script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.uncompressed.js"></script> | |
| <script> | |
| function main() { | |
| L.mapbox.accessToken = 'pk.eyJ1IjoiYWxscnlkZXIiLCJhIjoidWs5cUFfRSJ9.t8kxvO3nIhCaAl07-4lkNw'; | |
| var map = L.mapbox.map('map', 'mapbox.light', { | |
| center: [52.106505,10.986328], | |
| zoom: 2 | |
| }); | |
| cartodb.createLayer(map, 'http://documentation.cartodb.com/api/v2/viz/2b13c956-e7c1-11e2-806b-5404a6a683d5/viz.json').addTo(map) | |
| } | |
| window.onload = main; | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The CartoDB layer is not being shown correctly because there's a conflict with Leaflet. Both CartoDB.js and Mapbox.js include it, so when you add these libraries you will have to use their version without Leaflet in one of them.
The no-leaflet URL for mapbox.js is: https://api.tiles.mapbox.com/mapbox.js/v2.2.1/mapbox.standalone.js
The CartoDB one is: http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb_noleaflet.js
Then, you could use: