I saw that MapBox provides a geocoding service. Anyway, it seems that American cities have priority. If I am looking for a city, when I start writing, the first cities shown are American. Is there a way to restrict the search to just one specific Country/State?
3 Answers
A proximity
parameter was recently added to the Mapbox geocoding API that allows you to bias the results toward a given longitude and latitude location. Use it like this:
http://api.tiles.mapbox.com/v4/geocode/{index}/{query}.json?proximity={longitude},{latitude}&access_token={access_token}
For example, to get a top result of London, Canada rather than London, UK:
http://api.tiles.mapbox.com/v4/geocode/mapbox.places/London.json?proximity=-81,42&access_token={access_token}
See the Forward geocoding with proximity section of the API documentation for more info.
It's not possible to restrict the query to a specific country, but you could filter your results to ensure you only display locations from a certain country by looking at the "text"
or "context"
parts of the response.
Regarding your concerns about the default results - American cities do not have priority in the Mapbox geocoding API. However you may see more results from certain countries due to more detailed data currently available for them. The "Coverage" section of the Geocoding API docs provides information about which countries and result types have more detail. (The data and that list are updated regularly.)

- 591
- 3
- 5
Not at this time, but Mapbox's geocoder is under active development and that is likely a feature they're working on.

- 2,421
- 1
- 23
- 38
You can limit a geocoding request to a country, as defined in the Geocoding request format.
country (optional)
Limit results to one or more countries. Options are ISO 3166 alpha 2 country codes separated by commas.
So say you wanted to limit result to Spain, you'd simply add the query parameter as ?country=ES

- 1
- 1

- 713
- 1
- 17
- 26