Skip to content

Instantly share code, notes, and snippets.

View brightrain's full-sized avatar

David Puckett brightrain

View GitHub Profile
@brightrain
brightrain / typeahead-event.js
Created February 11, 2015 01:24
typeahead event
.on("typeahead:selected", function (obj, datum) {
// what happens when a user selects\clicks a suggestion
// we get the datum that contains the properties we defined when we setup the engine via the filter function
map.graphics.clear();
switch(datum.source) {
case "esri-geocoder":
var url = config.arcgisGeocodingBaseUrl + "find?" +
"magicKey=" + datum.magicKey + "&text=" + datum.name +
"&outFields=Addr_type&f=json";
// https://developers.arcgis.com/rest/geocode/api-reference/geocoding-find.htm
@brightrain
brightrain / typeahead-all.js
Created February 11, 2015 01:03
typeahead setup all
$("#searchInput").typeahead({
// how many characters does the user type before suggestions start firing
minLength: 3,
highlight: true,
hint: false
}, {
name: "camp",
displayKey: "name",
source: campBH.ttAdapter(),
// what the header looks like for this source in the suggestions drop down
@brightrain
brightrain / camp-ahead-setup.js
Last active August 29, 2015 14:15
camp ahead setup
...
, {
name: "camp",
displayKey: "name",
source: campBH.ttAdapter(),
// what the header looks like for this source in the suggestions drop down
templates: {
header: "<h1 class='typeahead-header'><span class='icon icon-camp'></span>&nbsp;Campgrounds</h1>"
}
},
@brightrain
brightrain / setup-typeahead.js
Created February 11, 2015 00:55
setup typeahead
$("#searchInput").typeahead({
minLength: 3,
highlight: true,
hint: false
},
@brightrain
brightrain / geocode-ahead.js
Created February 11, 2015 00:50
esri-geocoder engine
// build the esri geocoder bloodhound engine
var esriBH = new Bloodhound({
name: "esri-geocoder",
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.name);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
//https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm
// use the searchExtent parameter to limit the results to roughly washington state
@brightrain
brightrain / camp-ahead.js
Last active August 29, 2015 14:15
define campground engine
// https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md#options
var campBH = new Bloodhound({
name: "camp",
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.name);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
// feature services currently only support query
@brightrain
brightrain / so-blinky.html
Last active August 29, 2015 13:58
so blinky
<span id='so-blinky' style='text-decoration: blink;'>i m so blinky</span>
@brightrain
brightrain / togglability.js
Last active August 29, 2015 13:58
click event for toggling map layer
//click event for layers
//using dojo for the event and class toggling
//but could just as easily be jQuery or vanilla javascript
on(dojo.byId("trail"), "click", function() {
trailsLayer.visible ? trailsLayer.hide() : trailsLayer.show();
dojo.toggleClass(this, "visible");
dojo.query("#trail .visibility-icon")
.toggleClass("fa-picture-o")
.toggleClass("fa-ban");
});
@brightrain
brightrain / togglable-layers-style.css
Last active August 29, 2015 13:58
togglable layers
.togglable-layer {
margin-top: 0.8em;
width: 100%;
}
.togglable-layer:hover {
background-color: #ccc;
cursor: pointer;
}
.togglable-layer.visible {
background-color: white;
@brightrain
brightrain / mlbparks.geojson
Created March 13, 2014 18:13
MLB Baseball Stadiums
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.