Google Maps API には GClientGeocoder というジオコーディングをするクラスがあるが、残念ながら日本の住所や施設名には対応していない。
というか最初は対応していたけど、

Update: Removed Japan from the list of countries for which we offer street-level geocoding, as it is not available there. たいへん申し訳ございません。 m(_ _)m

Google Maps API Official Blog: Geocoding at last!

公開直後1日~2日で対応をやめたという経緯がある。どうしてか、詳細はわからないが……

とりあえず代替品は無いのかと探していると、Google AJAX Search API が見つかった。

Google AJAX Search API には GlocalSearch と GlocalResult という JavaScript のクラスが用意されている。
これを使うと、日本語で日本の住所(愛知県名古屋市中区本丸1番1号)
)や施設名(名古屋城)から緯度・経度などの位置情報を取得することが可能。

ということは、GlocalSearch と GlocalResult は ジオコーダとして使える。

Google AJAX Search API Samples には、わかりやすい動作サンプルがたくさん置いてある。
ためしに、サンプルの1つ My Favorite Places の検索窓に日本の住所や施設名を入れると、地図が移動して、位置の候補一覧も表示される。

で、便利なのでこれをこのまま使いたいところだが……

このAPIはもともとUIも含めて AJAX search を提供するというコンセプトで作られたもののようで、二つの点で使いにくいです。
ひとつめがライセンスの部分で、 Terms of Use のところにある
You agree to include and display the “powered by Google” attribution adjacent to the Service search box.
という条項と
For all Search Results available through the Service, Google provides Google AJAX Search API attribution language (such as “clipped from Google - date” or such similar language as may be used from time to time).
という条項。geocoderとして使う時にはそもそもサーチボックスが必要なかったり、検索結果を表示したりしなかったりするのでこの条項は煩わしいです。

ピヨピヨ ZeroMemory( ) >> geocoding with google AJAX search API

という指摘を発見。

Google AJAX Search API Terms of Use の 2.3項には、こんなことが書かれている。

You agree to include and display the "powered by Google" attribution adjacent to the Service search box. If you use the standard search control, or the standard search control form, this attribution will be included automatically. If you use a search form of your own design, or have no search form, you agree to place the attribution conspicuously on the page, in close proximity to the search results, as described in the documentation.

For all Search Results available through the Service, Google provides Google AJAX Search API attribution language (such as "clipped from Google - date" or such similar language as may be used from time to time). You agree to include this attribution, unmodified, adjacent to Search Results on your site. Google will provide this attribution information automatically when you use the default search control, in which case you agree not to modify or obscure this automatically generated attribution. If you do not use the default search control, you must include, adjacent to the Search Result and visible on the same screen, similar attribution that indicates the Search Result came from Google and on what date it was clipped.

Google AJAX Search API Terms of Use

たぶん、

  • 検索窓の近くに「powered by Google」という表示が必要。
  • 検索結果のすべてを利用できるようにしておく必要がある。

といった意味だと思う。
ライセンスは守らねば。

そうなると [F] 日本の地名で簡単にジオコーディングできるライブラリ gmapper.js - F.Ko-Jiの「一秒後は未来」 という便利そうなライブラリも、使うときに注意しなくてはいけないのかも。

Ref. [F] Google Maps APIで日本の住所から緯度・経度を求める方法 - F.Ko-Jiの「一秒後は未来」

追記: 2006-12-14

Google Maps APIでも、日本の住所や駅名によるジオコーディングがご利用いただけるようになりました。Maps APIを利用したサイトでは、Google マップと同様、ユーザーが入力した住所の緯度経度を割り出し、表示される地図の場所させることができようになりました。実装例はこちらをどうぞ。

尚、日本語での利用が主なサイトでは、JavaScript のソースURL のホスト名をmaps.google.co.jp にすることをお勧めします(.co.jp のドメインを使用することで、地図・写真切り替えモードのボタンも日本語で表示されるようになります)。

Google Maps API Official Blog: Japanese Address and Placename Support Added to the Geocoding API

というわけで、Google Maps API の日本語住所ジオコーダーが復活していたので、無理に Google Ajax Search API を使わなくても良さそう。

tags: zlashdot GIS GoogleMapsAPI

Posted by NI-Lab. (@nilab)