Get ISO 3166-1 country code as a GMSPlace result - ios

I need to implement a city search dialogue field in my app and use
the ISO 3166-1 country code of the search result.
The country in the result is as a string in the current locale (e.g. "United Kingdom", "Vereinigtes Königreich", ...) instead of just "uk", which is a problem. I could do a string search for all 248 countries in all languages google maps supports but that is very error prone.
Is there a way to include the country code in the search result?
My work around for now is to reverse lookup the reported coordinate afterwards but that's an additional request, resulting in wait time for the user.

Related

Is there a function in Swift to get the ISO 3166-2 codes (provinces, states) for a country?

For an app I need the users to create addresses. It is important that the addresses are valid and include an ISO 3166 ALPHA-2 country code as well as an ISO 3166-2 code for the province, state, etc.
I can use NSLocale to get all country codes and the localized names for a country code but is there a similar way to get the codes and names (they doesn't have to be localized) for the subdivisions of a country or do I have to create that massive dictionary by myself? :D
Thank you in advance

Youtube API - get views by cities?

It is possible?
I read the documentation, there are examples of receiving the number of views by country, but I need the number of views by city.
regionCode string
The regionCode parameter instructs the API to return search results for videos that can be viewed in the specified country. The parameter value is an ISO 3166-1 alpha-2 country code.
The YouTube API only supports searching by region code that being ISO 3166-1 alpha-2 country code
No you cant search by city.

Google Auto suggestion City mismatch when using in different regions

I integrated the GoogleMaps SDK to pick Location of place by AutoSuggestion, I am using GMSAutocompleteViewController to get city suggestions, with this location for city selected I want to search for hotels in our database.
But city is getting different name in different countries. For my App need to be internationally I need to get the same results everywhere across the world. ( using the GMSAutocompleteViewController)
Some cities in India are showing differently in other parts of the world.
Eg.Mangaluru to Mangalore(old)
I tried to put the App Language and Region and to English and UK respectively and also tried to apply some filter like below.
GMSAutocompleteViewController *acController = [[GMSAutocompleteViewController alloc] init];
acController.autocompleteFilter.country #"GB"
After applying filter only that country results coming.
Any suggestions to get same type results everywhere.?
I want to get the same city results getting for the same search everywhere.
You can remove the filter for the country to get results everywhere.
Based on the documentation Place Autocomplete:
**language** — The language code, indicating in which language the results should be returned, if possible. Searches are also biased to the selected language; results in the selected language may be given a higher ranking. See the list of supported languages and their codes. Note that we often update supported languages so this list may not be exhaustive. If language is not supplied, the Place Autocomplete service will attempt to use the native language of the domain from which the request is sent.
For the same city result, unfortunately, currently you can use components to filter by country.
Hope this helps!

How to get only city names from autocomplete using GoogleAPI for iOS

I wish to get only city names from autocomplete api for iOS. For example if i search like Avadi then it should return city name as Chennai. I used google places api. It returns many strings separated by comma from which i couldn't get exact city name if user give any area name of city.
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Avadi&types=(cities)&types=postal_code&key=GOOGLE_API_KEY

Get a list of cities around a city with a given radius with google places api

I'm using google places api for autocomplete on a RoR project.
I want to get a list of cities around the typed city with a given radius.
For instance:
I type "Paris, France" in the input. I want to have a list (JSON or whatever) which contains all the cities around the city with a given radius (maybe 10 miles or more, it'll be a constant in the project).
How can I do that?
Thanks!
-EDIT-
I've end up with this:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=48.534031,2.632121999999981&language=fr&types=locality&sensor=false&rankby=distance&key=YOUR_KEY_HERE
The lat and lng must point to a town near Paris called "Le Mee sur Seine" (https://maps.google.fr/maps?hl=fr&q=48.534031,2.632121999999981).
I want to list the towns surrouding this city ordered by distance but I have "ZERO_RESULTS" as a result...
The type you're tying to filter on, "locality" is specifically listed as not supported. That is, Google will not let you specifically search for locality or a number of other political geo types. See the full list of unsupported types here: https://developers.google.com/places/documentation/supported_types#table2

Resources