block by andrewxhill 9095945

Torque using createLayer in CartoDB.js

Full Screen

index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Torque runtime example | 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="//cartodb.com/assets/favicon.ico" />
    <style>
      html, body, #map {
        height: 100%;
        padding: 0;
        margin: 0;
      }
    </style>
    <link rel="stylesheet" href="//libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />
    <!--[if lte IE 8]>
      <link rel="stylesheet" href="//libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.ie.css" />
    <![endif]-->
  </head>
  <body>
    <div id="map"></div>
    
    <!-- include cartodb.js library -->
    <script src="//libs.cartocdn.com/cartodb.js/v3/cartodb.js"></script>

    <script>
      function main() {
        var map = new L.Map('map', {
          zoomControl: false,
          center: [-10, 0],
          zoom: 4
        });

        L.tileLayer('//tile.stamen.com/toner/{z}/{x}/{y}.png', {
          attribution: 'Stamen'
        }).addTo(map);

        cartodb.createLayer(map, {
          type: "torque",
          order: 1,
          options: {
            query: "",
            table_name: "monkey_jump",
            user_name: "andrew",
            tile_style: '/** torque visualization */ Map { -torque-frame-count:19; -torque-animation-duration:2; -torque-time-attribute:"layer"; -torque-aggregation-function:"count(cartodb_id)"; -torque-resolution:4; -torque-data-aggregation:linear; } #monkey_jump{ comp-op: lighter; marker-opacity: 0.9; marker-line-color: #FFF; marker-line-width: 0; marker-line-opacity: 1; marker-type: ellipse; marker-width: 12; marker-fill: #FF2900; }'
            }
        }).done(function(layer) {
          map.addLayer(layer);
        });
      }

      // you could use $(window).load(main);
      window.onload = main;
    </script>
  </body>
</html>