Module: MotionGeocoder::GoogleApi::Place

Extended by:
Place
Included in:
Place
Defined in:
lib/motion-geocoder/google_api/place.rb

Instance Method Summary collapse

Instance Method Details

#auto_complete(input, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/motion-geocoder/google_api/place.rb', line 8

def auto_complete(input, &block)
  url = auto_complete_url input

  AFMotion::JSON.get(url) do |res|
    pres = res.object['predictions'].map do |pre|
      { address: pre['description'], place_id: pre['place_id'] }
    end

    block.call pres
  end
end

#auto_complete_url(input, params = {}) ⇒ Object



20
21
22
# File 'lib/motion-geocoder/google_api/place.rb', line 20

def auto_complete_url(input, params={})
  "#{MotionGeocoder::GoogleApi.root}place/autocomplete/json?key=#{MotionGeocoder::GoogleApi.key}&input=#{input}"
end