Created
February 11, 2015 00:50
-
-
Save brightrain/2036ceb58860266d5658 to your computer and use it in GitHub Desktop.
esri-geocoder engine
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
// 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 | |
url: config.arcgisGeocodingBaseUrl + | |
"suggest?text=%QUERY&searchExtent=-125,49,-116.9,45.5&f=json", | |
filter: function (data) { | |
return $.map(data.suggestions, function (result) { | |
//typically this is a category or type of business (e.g. coffee shops) | |
if(result.isCollection === false) { | |
return { | |
name: result.text, | |
magicKey: result.magicKey, | |
source: "esri-geocoder" | |
}; | |
} | |
}); | |
}, | |
ajax: { | |
beforeSend: function (jqXhr, settings) { | |
$("#search-loading-icon").addClass("search-loading"); | |
}, | |
complete: function (jqXHR, status) { | |
$("#search-loading-icon").removeClass("search-loading"); | |
} | |
} | |
}, | |
limit: 5 | |
}); | |
esriBH.initialize(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment