Sha256: fe324eb03b5535ce6b76e7e93580905ef15b046df4aeea9e398afbf31033eb3a

Contents?: true

Size: 634 Bytes

Versions: 23

Compression:

Stored size: 634 Bytes

Contents

class Places
  API_KEY = ""
  #See google places documentation at https://developers.google.com/places/documentation/ to obtain a key

  def self.load(places_list_controller)
    BW::Location.get do |result|
      BW::Location.stop
      BubbleWrap::HTTP.get("https://maps.googleapis.com/maps/api/place/search/json?location=#{result[:to].latitude},#{result[:to].longitude}&radius=500&sensor=false&key=#{API_KEY}") do |response|
        names = BW::JSON.parse(response.body.to_str)["results"].map{|r| r["name"]}
        places_list_controller.places_list = names  
        places_list_controller.reloadData
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
bubble-wrap-1.1.5 samples/location/app/models/places.rb
bubble-wrap-1.1.4 samples/location/app/models/places.rb
bubble-wrap-1.1.3 samples/location/app/models/places.rb