No commit activity in last 3 years
No release in over 3 years
A ruby version of Baidu API Geocoder client.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.7
~> 10.0
 Project Readme

BaiduApi::Geocoding

A ruby version of Baidu API Geocoder client.

Installation

Add this line to your application's Gemfile:

gem 'baidu_api-geocoding'

And then execute:

$ bundle

Or install it yourself as:

$ gem install baidu_api-geocoding

Usage

require 'baidu_api/geocoding'
BaiduApi::Geocoding.setup ak: 'xxxx', sk: 'xxxx'

To geocode an address:

BaiduApi::Geocoding.geocode(address: '百度大厦')
=> {"status"=>0, "result"=>{"location"=>{"lng"=>116.30814954222, "lat"=>40.056885091681}, "precise"=>1, "confidence"=>80, "level"=>"商务大厦"}}

BaiduApi::Geocoding.geocode(location: '40.056885091681,116.30814954222')
=> {"status"=>0,
 "result"=>
  {"location"=>{"lng"=>116.30814954222, "lat"=>40.056885160713},
   "formatted_address"=>"北京市海淀区上地十街10",
   "business"=>"西二旗,龙泽,回龙观",
   "addressComponent"=>{"city"=>"北京市", "direction"=>"附近", "distance"=>"1", "district"=>"海淀区", "province"=>"北京市", "street"=>"上地十街", "street_number"=>"10"},
   "poiRegions"=>[{"direction_desc"=>"内", "name"=>"百度大厦"}],
   "cityCode"=>131}}

More options for parameter of BaiduApi::Geocoding.geocode, please see http://developer.baidu.com/map/index.php?title=webapi/guide/webservice-geocoding

Contributing

  1. Fork it ( https://github.com/[my-github-username]/baidu_api-geocoding/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request