block by wboykinm 4370383

CartoDB Viz JSON w/ Style Params

Full Screen

index.html

<!DOCTYPE html>
<html>
<head>
    <title>CartoDB Runtime</title>
    <style>
      html, body, #cartodb-map {
        height: 100%;
        padding: 0;
        margin: 0;
      }
    </style>
    <link rel="stylesheet" href="//geosprocket.com/assets/leaflet/dist/leaflet.css" />
    <!--[if lte IE 8]><link rel="stylesheet" href="//geosprocket.com/assets/leaflet/dist/leaflet.ie.css" /><![endif]-->

    <script src="//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="//mapbox.com/about/maps" target="_blank">Terms &amp; Feedback</a>'
	  }).addTo(map);
	
	  var layerUrl = '//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>