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