Last active
April 13, 2016 14:54
-
-
Save ramiroaznar/9081bd71f2479b253e0c to your computer and use it in GitHub Desktop.
How to get your Labels to stand out with CartoDB.js
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> | |
<title>How to get your Labels to stand out with 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" /> | |
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" /> | |
<style> | |
html, body, #map { | |
height: 100%; | |
padding: 0; | |
margin: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<!-- include cartodb.js library --> | |
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script> | |
<script> | |
function main() { | |
var map = new L.Map('map', { | |
zoomControl: false, | |
center: [43, 0], | |
zoom: 3 | |
}); | |
cartodb.createLayer(map, { | |
user_name: 'ramirocartodb', | |
type: 'cartodb', | |
sublayers: [ | |
{ | |
type: "http", // add basemap without labels | |
urlTemplate: "http://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}.png", | |
subdomains: [ "a", "b", "c" ] | |
}, | |
{ | |
sql: 'select * from ne_50m_land', // add layer | |
cartocss: '#ne_50m_land{polygon-fill: #FF6600;polygon-opacity: 0.7;line-color: #FFF;line-width: 0.5;line-opacity: 1;}' | |
}, | |
{ | |
type: "http", // add basemap only labels | |
urlTemplate: "http://{s}.basemaps.cartocdn.com/dark_only_labels/{z}/{x}/{y}.png", | |
subdomains: [ "a", "b", "c" ] | |
} | |
], | |
}) | |
.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