Created
December 24, 2012 18:42
-
-
Save wboykinm/4370320 to your computer and use it in GitHub Desktop.
CartoDB layerOptions Use
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
<html> | |
<head> | |
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v2/themes/css/cartodb.css" /> | |
<script src="http://libs.cartocdn.com/cartodb.js/v2/cartodb.js"></script> | |
<!--[if lte IE 8]> | |
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v2/themes/css/cartodb.ie.css" /> | |
<![endif]--> | |
<style> | |
html, body {padding: 0; margin: 0;} | |
#cartodb-map { width: 100%; height:100%; background: black;} | |
</style> | |
<script> | |
var map; | |
function init(){ | |
// initiate leaflet map | |
map = new L.Map('cartodb-map', { | |
center: [0,0], | |
zoom: 2 | |
}) | |
L.tileLayer('https://dnv9my2eseobd.cloudfront.net/v3/cartodb.map-4xtxp73f/{z}/{x}/{y}.png', { | |
attribution: 'Mapbox <a href="http://mapbox.com/about/maps" target="_blank">Terms & Feedback</a>' | |
}).addTo(map); | |
var layerUrl = 'http://examples-beta.cartodb.com/api/v1/viz/936/viz.json'; | |
var layerOptions = { | |
query: "SELECT * FROM {{table_name}} where adm0_a3 = 'USA'", | |
tile_style: "#{{table_name}}{marker-fill: #109DCD; marker-width: 5; marker-line-color: white; marker-line-width: 0;}" | |
} | |
cartodb.createLayer(map, layerUrl, layerOptions) | |
.on('done', function(layer) { | |
map.addLayer(layer); | |
}).on('error', function() { | |
//log the error | |
}); | |
} | |
</script> | |
</head> | |
<body onload="init()"> | |
<div id='cartodb-map'></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment