Last active
March 16, 2017 13:01
-
-
Save rochoa/8f3240fd2e2edb5546ae to your computer and use it in GitHub Desktop.
[CARTO] CartoCSS example – background-image
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>CartoDB: CartoCSS example – background-image</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/3.15/themes/css/cartodb.css" /> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script> | |
<script> | |
function main() { | |
var map = L.map('map', { | |
zoomControl: false, | |
center: [43, 0], | |
zoom: 3 | |
}) | |
cartodb.createLayer(map, { | |
user_name: 'examples', | |
type: 'cartodb', | |
sublayers: [{ | |
sql: 'select * from country_boundaries', | |
cartocss: 'Map{ background-image: url(http://cdn.backgroundhost.com/backgrounds/subtlepatterns/batthern.png); background-image-opacity: 0.4} #layer { polygon-fill: #000; polygon-opacity: 0.3; line-color: #000; line-width: 0.5; }' | |
}] | |
}) | |
.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