About Chris: Solutions Engineer, Urbanist, Mapmaker, Open Data Junkie
@chris_whong
//Logs current map center and zoom level for use in map init options | |
//Use it to find that perfect intial view without having to use trial and error | |
map.on('dragend',getInit).on('zoomend',getInit); | |
function getInit() { | |
var c = map.getCenter(); | |
console.log('center: [' + c.lat + ',' + c.lng + '],\nzoom: ' + map.getZoom()); | |
} |
//node script for generating complex cartoCSS for torque | |
//as value increases, duration of marker gets longer, | |
//radius gets larger, and color moves up the ramp. | |
var breaks = [0,10,50,100] | |
var colors = ['#eff3ff','#bdd7e7','#6baed6','#2171b5']; | |
var data = { | |
"tableName":"#nepaltrends", | |
"valueCondition":0, |
/* | |
Given a table of census tracts, this query will generate a gaussian distribution of points offset from the tract's centroid. | |
Based on this example by Paul Ramsey: http://boundlessgeo.com/2014/10/postgis-training-creating-overlays/ | |
*/ | |
WITH tracts AS ( | |
SELECT *, random() AS u1, random() AS u2, 25 AS f, generate_series(1,total_pop/100) FROM chriswhong.nytracts | |
) | |
SELECT |
<!DOCTYPE html> | |
<html lang="en"> | |
<head profile="http://www.w3.org/2005/10/profile"> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<link rel="icon" href="./favicon.ico"> |
About Chris: Solutions Engineer, Urbanist, Mapmaker, Open Data Junkie
@chris_whong
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" /> | |
<style> | |
#map, html, body { | |
height:100%; | |
width:100%; |
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --url "http://localhost/~chriswhong/$(basename $PWD)"' |
var layerSource = { | |
type: "torque", | |
options: { | |
auth_token: '{yourAuthToken}', | |
user_name: "{yourCartoDBUsername}", | |
tile_style:"{torqueCartoCSS}", | |
named_map: { | |
name: "{namedmap}" | |
} | |
} |
NYC DOT Live Speed Sensors data: | |
http://207.251.86.229/nyc-links-cams/LinkSpeedQuery.txt | |
h/t https://twitter.com/5h15h/status/684116277586100224 |