LoginSignup
1
2

More than 5 years have passed since last update.

Google GeocodingsのGem作った

Posted at

Google Geocodings APIのラッパーのGemを作りました。

Why

既存のgemはRailsに依存してるものや作られた時代が古くオプションも対応してないものが上位に上がってきており、シンプルに今のAPIに対応してるものがパッと出てこなかったので作ってみました。
後はgem作ってみたいと思っていた中で、事業の延長線上でシンプルでメンテコストがないものだったからです。

gem

使い方は簡単で住所から緯度経度は

client = GoogleGeocodings::Client.new(API_KEY)
client.geocode("1600 Amphitheatre Parkway, Mountain View, CA")

緯度経度から住所は

client = GoogleGeocodings::Client.new(API_KEY)
client.reverse_geocode("37.4230474802915", "-122.0843128697085")

とすれば

types[], formatted_address, address_components[], postcode_localities[], geometry, partial_match, place_id
のアトリビュートを持つGeocodingクラスが返ってきます。

リクエスト、レスポンスともAPIの名称とほぼ同じです。
https://developers.google.com/maps/documentation/geocoding/intro

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2