If you want to simply calculate the distance between the two addresses, you can use the gem to complete your work.
Add this line to your application's Gemfile:
gem 'estimate_distance'And then execute:
$ bundle
Or install it yourself as:
$ gem install estimate_distance
Before you get the distance between two points, you must pass the detailed address of two points as a parameter.
For example: EstimateDistance.direct_calculate_distance(former_address,latter_address)
Then,you can get the distance between two points
Version one, the gem is used only 6000 times a day. In order to enhance the number of use。
Version two, the user can go to the Baidu Developer Center to apply for their own ak key, and then use the corresponding gem method to complete your work。
As with version one, you can choose to pass in ak or not.
For example: EstimateDistance.direct_calculate_distance(former_address,latter_address) OR EstimateDistance.direct_calculate_distance(former_address,latter_address,your_ak)
Then,you can get the distance between two points
- Fork it ( https://github.com/[my-github-username]/estimate_distance/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