mapbox-gl-geocoder
mapbox-gl-geocoder copied to clipboard
consider unifying country / countries option with rest api and sdk-js
It looks like the official API documentation specifies "country" as an option to restrict search countries, but this library uses "countries". It's a bit confusing, and reading source code isn't an ideal way to find this out.
Is there a reason it differs, or does it make sense to unify the component configuration with the mapbox API?
It's worse than that even the way you specify countries varies between here and mapbox-sdk-js
mapbox-gl-geocoder
options.countries string? a comma separated list of country codes to limit results to specified country or countries.
mapbox-sdk-js
config.countries Array
? Limits results to the specified countries. Each item in the array should be an ISO 3166 alpha 2 country code.
I can't remember but think we just model this option name after the option name in mapbox-sdk-js, and since you can specify more than one country I think countries is best.
I agree that it's confusing that this doesn't match the REST API but my random guess is that originally it only supported a single country and just always left as country.
You shouldn't need to read source code to find this out though, it's all in the API documentation. If anything I think the REST API should change to countries.
Ah that's interesting, and of course, understandable.
Is a good approach to maybe support both, and then deprecate over time?
IMHO:
- support 'country' as a synonym for 'countries'
- allow the value to be provided as either comma-separated string, or array of strings.
I don't think there's much need for the control to be picky.