Skip to content

Instantly share code, notes, and snippets.

@juanignaciosl
Created March 25, 2015 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanignaciosl/574655d396d44803de30 to your computer and use it in GitHub Desktop.
Save juanignaciosl/574655d396d44803de30 to your computer and use it in GitHub Desktop.
table-sql-api.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HTML Table with CartoDB SQL API</title>
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.core.js"></script>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.11/themes/css/cartodb.css" />
</head>
<body>
<table id="mytable"></table>
<script>
var table = document.getElementById('mytable');
var sql = cartodb.SQL({ user: 'documentation' });
sql.execute("select adm0name, name from ne_10m_populated_places_simple_1 limit 10")
.done(function(data) {
data.rows.map(function(r) {
var row = document.createElement('tr');
var nameCell = document.createElement('td');
nameCell.innerText = r.name;
row.appendChild(nameCell);
table.appendChild(row);
});
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment