Sha256: 1e52f716f7cee95f13e22df4ba1856e22d5527665af2006f33b3fe45eb9b1f04
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'geocoder/lookups/base' require "geocoder/results/bing" module Geocoder::Lookup class Bing < Base def map_link_url(coordinates) "http://www.bing.com/maps/default.aspx?cp=#{coordinates.join('~')}" end private # --------------------------------------------------------------- def results(query) return [] unless doc = fetch_data(query) if doc['statusDescription'] == "OK" return doc['resourceSets'].first['estimatedTotal'] > 0 ? doc['resourceSets'].first['resources'] : [] else warn "Bing Geocoding API error: #{doc['statusCode']} (#{doc['statusDescription']})." return [] end end def query_url_params(query) super.merge( :key => Geocoder::Configuration.api_key, :query => query.reverse_geocode? ? nil : query.sanitized_text ) end def query_url(query) "#{protocol}://dev.virtualearth.net/REST/v1/Locations" + (query.reverse_geocode? ? "/#{query.sanitized_text}?" : "?") + url_query_string(query) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geocoder-1.1.5 | lib/geocoder/lookups/bing.rb |