Created
December 24, 2012 19:00
-
-
Save wboykinm/4370383 to your computer and use it in GitHub Desktop.
CartoDB Viz JSON w/ Style Params
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 Runtime</title> | |
<style> | |
html, body, #cartodb-map { | |
height: 100%; | |
padding: 0; | |
margin: 0; | |
} | |
</style> | |
<link rel="stylesheet" href="http://geosprocket.com/assets/leaflet/dist/leaflet.css" /> | |
<!--[if lte IE 8]><link rel="stylesheet" href="http://geosprocket.com/assets/leaflet/dist/leaflet.ie.css" /><![endif]--> | |
<script src="http://libs.cartocdn.com/cartodb.js/v2/cartodb.js"></script> | |
<script> | |
var map; | |
function init(){ | |
// initiate leaflet map | |
map = new L.Map('cartodb-map', { | |
center: [0,0], | |
zoom: 2 | |
}) | |
L.tileLayer('https://landplanner.mapbox.com/v3/map-a0wbwf43/{z}/{x}/{y}.png', { | |
attribution: 'Mapbox <a href="http://mapbox.com/about/maps" target="_blank">Terms & Feedback</a>' | |
}).addTo(map); | |
var layerUrl = 'http://dai.cartodb.com/api/v1/viz/11371/viz.json'; | |
var layerOptions = { | |
query: "SELECT * FROM ag_2011_commune3 where mean_jache > 0", | |
tile_style: "#ag_2011_commune3{ | |
line-color: #FFF; | |
line-opacity: 1; | |
line-width: 1; | |
polygon-opacity: 0.8; | |
} | |
#ag_2011_commune3 [ mean_jache <= 2.26312] {polygon-fill: #B10026;} | |
#ag_2011_commune3 [ mean_jache <= 1.19784363636] {polygon-fill: #E31A1C;} | |
#ag_2011_commune3 [ mean_jache <= 0.778073210526] {polygon-fill: #FC4E2A;} | |
#ag_2011_commune3 [ mean_jache <= 0.4677762] {polygon-fill: #FD8D3C;} | |
#ag_2011_commune3 [ mean_jache <= 0.29674792] {polygon-fill: #FEB24C;} | |
#ag_2011_commune3 [ mean_jache <= 0.164760217391] {polygon-fill: #FED976;} | |
#ag_2011_commune3 [ mean_jache <= 0.0] {polygon-fill: #FFFFB2;}" | |
} | |
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