Get a list of cities around a city with a given radius with google places api - ruby-on-rails

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

Related

how to get geojson of mainly cities of all of country of the world

I'm making a map use echarts with geojson mapdata,but i need a geojson resource that contain main cities of all of country of the world,i had looked for everywhere on website ,but the mostly resource is just have border of country not has cities border data. and i also checked the highcharts mapdata resource but the crs option is ESPG type .i need the Longitude latitude coordinates
depends on how many city do you want?
If you want 36430 city with only city name, go here
https://github.com/drei01/geojson-world-cities
If you want 1240 city with lots of details info go here: (choose populated-place)
http://geojson.xyz
if you only need major 120 city with only city name go here: (choose world city)
https://github.com/mapbox/mapping
Go to http://geojson.xyz and look for "populated places" and "populated places simple"
You can also take GeoJSON from website NaturalEarhData.com available at Github e.g ne_10m_populated_places.geojson and ne_10m_populated_places_simple.geojson
In fact, GeoJSON.xyz takes the data from NaturalEarthData.
Here you have geojson of continents, countries, country groupings, regions and states of all the world:
https://github.com/rapomon/geojson-places

Geolocation: How to derive the Country using an address/city/place?

I have a .csv file with Twitter profiles including information such as username, name, description etc. One column is geolocation. In this text the user may have a country (i.e., UK), a city or town (i.e., Cambridge), an actual address (5 Tyrian Place, WR5 TY1), a state (i.e, California, CA) or something silly (i.e., West of Hell).
Is there an API/library/automatic way of taking this information and deriving the country? For example, if the location is Cambridge the output should be UK, if the address is in the UK, the output should be UK, etc.
Google has a reverse geocoding service which you can access through their Maps API:
https://developers.google.com/maps/documentation/geocoding/start
They let you make 2500 free requests per day. One nice feature is it will give you correct latitude, longitude, state, country, etc for things like "Golden Gate Bridge" and "The Big Apple." Twitter users enter all sorts of (sarcastic) phrases for their location -- like "West of Hell," "Mars," etc -- and Google will reverse geocode that as well. Though, that may not be very useful.
As another level of checking, you can compare the user's timezone ("utc_offset"), if it is present, to the place that Google returns. It's a bit involved and requires that you compare the timezone's latitude boundaries to the latitude and longitude in Google's response.

twillio - make a search by city or region

How can I make the search by location.
https://www.twilio.com/user/account/phone-numbers/search
In their example there is a way to search by location e.g. Boston, also it is possible to search by region.
Here is their example:
$numbers = $client->account->available_phone_numbers->getList('US', 'Local', array(
"InRegion" => "AR"
));
How can I make a search by region or by city as well.
Twilio developer evangelist here.
There are a bunch of advanced filters you can use to search for numbers in the US and Canada.
InRegion, as you left as an example, is one of the filters. The rest can be seen here: https://www.twilio.com/docs/api/rest/available-phone-numbers#local-get-advanced-filters
To get a city based search, you could combine a geolocation lookup on the name of the city, to get the latitude and longitude, and the NearLatLong and Distance filters to get something near the city.
Hope that 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

Can i get geocoding information from Google Geocoding API passing only the city?

I just need to fetch some geo data for a given city, i'm not interested (and i don't know) the address. Sending a request like this:
http://maps.googleapis.com/maps/api/geocode/xml?address=fake,%20USA&sensor=false
will match a street with whe word fake in it, somewhere in USA. How can i match only cities and get ZERO_RESULTS response if there is no city with that name?
You can't do this with the Geocoding API unfortunately, from the docs page:
Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739)
The API will always look for a specific address and if it can't find an exact match from the string you provide it will always make a 'best effort' guess as to what you meant to try and find one. Only if it can't make this reasonable guess wil it return ZERO_RESULTS.
I also just explore the API.how about using link like below
http://maps.googleapis.com/maps/api/geocode/xml?components=locality:fake|country:US
locality equal to City and stated the country as US.It will return zero result.But if using this
http://maps.googleapis.com/maps/api/geocode/xml?components=locality:fake|country:Nigeria
This will return the result.

Resources