Google Geocoding API v3 を用いてジオコーディング
ライセンス条項は各自で気をつけてください。この Web ページは、Google API プログラミングの練習用として載せています.
Google Geocoding API などの Google の API で取得されるコンテンツの使用条件は、Google が定めています.
- 例えば、「東京タワー」の Geocoding を取得して、それを Google 以外の地図と組み合わせて使用するとライセンス違反になる.
- アプリの側で、ストリートビューの画像を保存したり、加工して使うのは行儀がよくありまえん(ライセンス違反のはずです).
- static map は img タグの src 属性、あるいは div タグの background-image 属性で使うことだけが許可されている
各自でよく確認すること.
https://developers.google.com/maps/faq#tos_staticmaps_reuse
http://www.google.com/permissions/geoguidelines.html
【関連する外部ページ】 https://developers.google.com/maps/documentation/geocoding/?hl=ja
Ruby プログラム例
require "open-uri"
require "cgi"
require "nkf"
RequestUrl = "https://maps.googleapis.com/maps/api/geocode"
Key = "AIzaSyDb2yPS66kdmxOKigBES1kbHr8cgC2Y5YU"
def GoogleMapGeocode(address)
@url = "#{RequestUrl}/json?address=#{CGI.escape(NKF.nkf("-w -m0",address))}&sensor=false&language=ja"
json = URI.parse(@url).read
p json
return json
end
json = GoogleMapGeocode("東京都庁")
p json
第2のプログラム例
# -*- coding: euc-jp -*-
require "open-uri"
require "cgi"
require "nkf"
RequestUrl = "https://maps.googleapis.com/maps/api/geocode"
Key = "AIzaSyDb2yPS66kdmxOKigBES1kbHr8cgC2Y5YU"
def GoogleMapStreetView()
@url = 'https://maps.googleapis.com/maps/api/streetview?size=640x480&heading=180&fov=120&location=33.59656025053064,130.21688103675842&sensor=false&key=<APIキー>'
p @url
json = URI.parse(@url).read
p json
return json
end
json = GoogleMapStreetView()
p json