Last active
December 24, 2015 21:48
-
-
Save DavidSpriggs/6867772 to your computer and use it in GitHub Desktop.
Geocoder suggest filtering.
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
The suggest service does not honor the sourceCountry parameter. This function works to filter results based on a regEx. | |
In post create: | |
this.own(aspect.before(this.geocoder, '_hydrateResults', lang.hitch(this, 'scrubGeocodeAutoComplete'))); | |
member function: | |
scrubGeocodeAutoComplete: function(results) { | |
var re = /United States/i; | |
var scrubedResults = []; | |
array.forEach(results, function(result) { | |
if (result.text && result.text.match(re)) { | |
scrubedResults.push(result); | |
} else if (result.name && result.name.match(re)) { | |
scrubedResults.push(result); | |
} | |
}); | |
return [scrubedResults]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Dave,
Although I couldn't find it documented anywhere, it appears that as of 3.10, the geocoder isn't returning "name" any longer, it instead returns "address". Changing the above to reference result.address instead of result.name corrected our app.
Just thought I'd share in case you still use this function.
Thanks,
Dennis