-
-
Save wboykinm/5413917 to your computer and use it in GitHub Desktop.
CartoDB Typeahead
This file contains hidden or 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
<!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