@location_manager = CLLocationManager.alloc.init @location_manager.desiredAccuracy = KCLLocationAccuracyNearestTenMeters @location_manager.startUpdatingLocation url = "http://restro.nalwaya.com/restaurants/find_restaurent_distance.json?latitude=#{@location_manager.location.latitude}&longitude=#{@location_manager.location.longitude}" @location_manager.stopUpdatingLocation # query = 'Chicago' # url = "http://restro.nalwaya.com/restaurants/search.json?city=#{query}" @restaurants.clear json = nil begin json = JSONParser.parse_from_url(url) rescue RuntimeError => e presentError e.message end
現在地の緯度と軽度を取得し、緯度軽度でレストランの一覧を取得するAPIを適当に叩いております。
url = "http://restro.nalwaya.com/restaurants/find_restaurent_distance.json?latitude=#{@location_manager.location.latitude}&longitude=#{@location_manager.location.longitude}"
緯度と経度の取り方はこちらを参照。
現在地の緯度と軽度を取得する - by shigemk2