Skip to content

Instantly share code, notes, and snippets.

@zverok
Created November 30, 2011 12:05
Show Gist options
  • Save zverok/1408834 to your computer and use it in GitHub Desktop.
Save zverok/1408834 to your computer and use it in GitHub Desktop.
class APIProvider
private
def get(url, hash)
page = SimpleHttp::get url, hash
JSON.parse(page)
end
end
class Wikipedia < APIProvider
def request(lat, lng)
response = get "http://api.wikilocation.org/articles", :lat => lat, :lng => lng
end
end
class Foursquare < APIProvider
def request(lat, lng)
end
end
class WikiMapia < APIProvider
def request(lat, lng)
response = get 'http://api.wikimapia.org/', 'function' => 'box', 'format' => 'json', 'key' => '93DAE214-C8C69501-11790454-69F629CD-4346EAE9-6E5CBFAA-B95D49D2-D3F009C',
'lat_min' => lat - 0.05, 'lat_max' => lat + 0.05, 'lon_min' => lng - 0.05, 'lon_max' => lng + 0.05,
'count' => 50
response['folder'].map{|res| {'name' => res['name'], 'location' => res['location']}}
end
end
class GooglePlaces < APIProvider
def request(lat, lng)
response = get 'https://maps.googleapis.com/maps/api/place/search/json',
:key => 'AIzaSyB9AkHP0rNOe1z076WY9dsqeSGUwNDp3yk', :sensor => 'false',
:location => "#{lat},#{lng}", :radius => 500
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment