Created
September 12, 2012 19:28
-
-
Save andrewxhill/3709298 to your computer and use it in GitHub Desktop.
CartoDB Backbone for data-driven webpages
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
// Set the CartoDB user account | |
var CartoDB = Backbone.CartoDB({ | |
user: viz2 | |
}); | |
// Create a model, here directly from SQL | |
// You can also do it with simply a table name and list of columns | |
var parksModel = CartoDB.CartoDBCollection.extend({ | |
sql: "SELECT name FROM nyc_parks ORDER BY ST_Area(the_geom) DESC LIMIT 10" | |
}); | |
// Create a new instance of our model and fetch the records | |
var parks = new parksModel(); | |
parks.fetch(); | |
// When records are loaded, do something with them | |
parks.bind('reset', function() { | |
var parks_list = new Array(); | |
parks_list.push(p.get('name')); | |
alert(parks_list); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment