BaiduApi::LbsCloud
A Ruby client to call Baidu LBS Cloud API
Installation
Add this line to your application's Gemfile:
gem 'baidu_api-lbs_cloud'
And then execute:
$ bundle
Or install it yourself as:
$ gem install baidu_api-lbs_cloud
Usage
require 'baidu_api/lbs_cloud'
# Call Geodata APIs
# :sk is unnecessary if you are not authenticating with SN
BaiduApi::LbsCloud::V3::Geodata.setup ak: 'xxxx', sk: 'xxxxx'
# Also :ak and :sk can be Proc if you want load them dynamically
BaiduApi::LbsCloud::V3::Geodata.setup ak: ->{ Settings.current.ak } , sk: -> { Settings.current.sk }
# get geodata singleton instance
geodata = BaiduApi::LbsCloud::V3::Geodata.instance
# list existing geotables
geodata.geotable.list()
=> {"status"=>0,
"geotables"=>
[{"name"=>"5656", "geotype"=>1, "is_published"=>1, "create_time"=>1420180426, "modify_time"=>1420180426, "id"=>90286},
{"create_time"=>1419816767, "geotype"=>1, "is_published"=>1, "modify_time"=>1420180449, "name"=>"gogo", "id"=>89998}],
"size"=>2,
"message"=>"成功"}
# create geotable
geodata.geotable.create(name: 'mytest', geotype: 3, is_published: 0)
=> {"status"=>0, "id"=>90288, "message"=>"成功"}
# rails error if status is non-zero
geodata.geotable.create!(name: 'mytest')
BaiduApi::LbsCloud::Exceptions::Failed: geotype:
Contributing
- Fork it ( https://github.com/xiaohui-zhangxh/baidu_api-lbs_cloud/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request