lib/gogo_maps.rb in gogo_maps-0.2.71800000 vs lib/gogo_maps.rb in gogo_maps-0.2.71820000
- old
+ new
@@ -3,22 +3,28 @@
require 'json'
module GogoMaps
class << self
# @param Hash opts - to support below Ruby1.9x.
- def get(opts={})
- fail 'Should provide either address or latlng' unless opts[:address] || opts[:latlng]
+ def get_latlng(address, opts={})
+ GoogleMapClient.call(
+ { address: address, language: :ja, sensor: false }.merge(opts),
+ :to_latlng
+ )
+ end
+ # @param Hash opts - to support below Ruby1.9x.
+ def get_address(latlng, opts={})
GoogleMapClient.call(
- { language: :ja, sensor: false }.merge(opts),
- opts[:address] ? :to_latlng : :to_address
+ { latlng: latlng, language: :ja, sensor: false }.merge(opts),
+ :to_address
)
end
def random(opts={})
lat = ((-180..180).to_a.sample + rand).round(8)
lng = ((-180..180).to_a.sample + rand).round(8)
- get({latlng:[lat, lng].join(',')}.merge(opts))
+ get_address([lat, lng].join(','), opts)
rescue
random #FIXIT:
end
end