Skip to content

Instantly share code, notes, and snippets.

@wboykinm
Forked from andrewxhill/index.html
Last active December 16, 2015 09:38
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 wboykinm/5413917 to your computer and use it in GitHub Desktop.
Save wboykinm/5413917 to your computer and use it in GitHub Desktop.
CartoDB Typeahead
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Typeahead + CartoDB</title>
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="well">
<input type="text" class="span6" id="filter" data-provide="typeahead" data-items="6" />
</div>
<script src="http://libs.cartocdn.com/cartodb.js/v2/cartodb.js"></script>
<script src="http://gist.github.com/johanneswuerbach/2712048/raw/be3b8cff86b4d66d3281d29e234dbaf894a0f604/bootstrap-typeahead-2.0.3.js"></script>
<script>
var sql = new cartodb.SQL({ user: 'geosprocket', format: 'json'});
sql.execute("SELECT distinct newstr FROM btv_prints_041513f ORDER BY newstr").done(function(data){
var subjects = [];
for (var i = 0; i < data.rows.length; i++){
subjects.push(data.rows[i].newstr)
};
$('#filter').typeahead({source: subjects})
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment