Geocoder search only by city? - ruby-on-rails

I'm using Geocoder with google places API on my Ruby on Rails api,
I would like to search locations but only if the city params match my query string.
Eg. Searching for 'X' locations return cities called 'X', with no chance of returning a street or country also called 'X'.
Geocoder.search.city('X') #I'm aware that this doesn't work

Related

Google Places Autocomplete API filter type "address" returns places of type "route" via iOS SDK

Google Places API for iOS version: 2.2.30010.0
Code:
let filter = GMSAutocompleteFilter()
filter.type = .address
filter.country = "us"
return filter
When searching for example Montrose with filter of type address & country us, the search results display:
The country filter works, but the type filter displays results of type route. Is this the intended behavior?
The Place Autocomplete docs specify:
address instructs the Place Autocomplete service to return only geocoding results with a precise address. Generally, you use this request when you know the user will be looking for a fully specified address.
Maybe I'm misunderstanding what a precise address is, but it seems like the query should only return results with a building number ex. 22 Montrose Ave.
Is it possible to return only places that have building numbers?
You just need to remove filter.type = .address

Why Foursquare Api not Responding according to Categories filter?

Foursquare Api with Query
As per above link , i am using foursquare and passing categories in query as Strip Club,Adult Boutique, Erotic Museum .. and in response i m getting some irrelevant results like for Bushey Country Club which is under Golf Courses category , i can't figure out why foursquare returning result outside passed categories as query , any1 can help ?
Explore API can't be a good choice for filter venues category.you can use Search API with category id filter. for example, this API return nightlife category venue at Vilnius to you http://api.foursquare.com/v2/venues/search?ll=54.6872,25.2797&categoryId=4d4b7105d754a06376d81259

rails Geocoder gem order by location from me

I have Place model with lat and long fields.
So i need to select all places and order them using my geoposition.
I think that i need to use Geocoder gem.
So user send to me his lat & long
and i need to do smth like
Place.where(status: 1).and order them using my lat long.
How can i do?
Thanks
You would use the near method:
Place.where(status: 1).near( "Party City, Utah", 20 ) # Finds places within 20 miles
This will grab all Place records that are within a specific radius of the given location. In this case, your location is "Party City, Utah". You can add additional arguments to the near method to limit the number of results, and also edit the radius of your query.
More information in the GeoCoder Docs

Find nearest cafe and airports of a given latitude rails

I have latitude and longitude of an address and I want to search all the airports, Railway stations, Bus Stand and cafe etc popular places. I'm using these gems in my application :
gem 'geocoder'
gem 'gmaps4rails'
gem 'geokit-rails
Now Please suggest me how can I solve this problem?
We can pass the search parameters in type (these search strings are suggested by google for places)
lat="30.987674"
lng="-45.098753"
doc = JSON.parse(open("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=#{lat},#{lng}&radius=50&type=['cafe']&name=cruise&key=xxxxxx").read)
cords=[]
doc['results'].each do |r|
tmp={}
tmp = r['geometry']['location']
tmp["name"] = r['name']
cords<< r['geometry']['location']
end
Here cords is the array of hashes with relative information about places i.e. cafes.
See : https://developers.google.com/places/web-service/search
https://developers.google.com/places/supported_types
I would actually use the near function of geocoder, assuming you use ActiveRecord.

Search four fields in YQL geo.places

We are currently using YQL to query geo data for towns and counties in the UK. At the moment, we can use the following query to find all towns named Boston:
select * from geo.places where text="boston" and placeTypeName="Town"
Demo
The issue is, that we would like to specify the county and country to generate more specific results. I have tried the following query, but it returns 0 results:
select * from geo.places where (text="boston" and placeTypeName="Town") and (text="lincolnshire" and placeTypeName="County")
Demo
How can I query 3 field types to return the results I need? Essentially, we would like to query the following fields:
text and placeTypeName="Town"
text and placeTypeName="County"
text and placeTypeName="Country"
This may be an option maybe:
https://developer.yahoo.com/blogs/ydnsevenblog/solving-location-based-services-needs-yahoo-other-technology-7952.html
As it mentions:
Turning text into a location
You can also turn a text (name) into a location using the following code:
yqlgeo.get('paris,fr',function(o){
alert(o.place.name+' ('+
o.place.centroid.latitude+','+
o.place.centroid.longitude+
')');
})
This wrapper call uses our Placemaker Service under the hood and automatically disambiguates for you. This means that Paris is Paris, France, and not Paris Hilton; London is London, England, and not Jack London.

Resources