Module: Ztil::Baidu

Defined in:
lib/ztil/baidu.rb

Constant Summary collapse

BAIDU_AK =
'A0f00186ba072b824d88d6300c9f7f86'
BAIDU_URL =
'http://api.map.baidu.com'

Class Method Summary collapse

Class Method Details

.coordcoder(location, options = {}) ⇒ Object



18
19
20
21
# File 'lib/ztil/baidu.rb', line 18

def coordcoder(location, options = {})
  r = JSON.parse RestClient.get("#{BAIDU_URL}/geocoder/v2/", { params: {location: location, output: :json, ak: BAIDU_AK, coordtype: options[:coordtype]} })
  JSON.pretty_generate(r)
end

.geocoder(address, options = {}) ⇒ Object



13
14
15
16
# File 'lib/ztil/baidu.rb', line 13

def geocoder(address, options = {})
  r = JSON.parse RestClient.get("#{BAIDU_URL}/geocoder/v2/", { params: {address: address, output: :json, ak: BAIDU_AK, city: options[:city]} })
  JSON.pretty_generate(r)
end