Bing Maps REST Services Imagery API は地図画像を取得することができるWeb API 。
似たような競合APIは Google Static Maps API や Yahoo! Open Local Platform スタティックマップAPI あたり。
これらの API と比較した Bing Maps REST Services Imagery API の優位点は、始点と終点を指定するだけで自動的に経路を描画してくれるところ。
(取得した地図画像の情報を XML/JSON で取得できたりとかも優位点だと思うけど今回はパス)
準備: アカウント作成
まず、Windows Live ID を作る。
⇒ Windows Live へようこそ
次に Windows Live ID で Bing Maps Account Center へログインして Bing Maps のアカウントを作成。
⇒ Home - Bing Maps Account Center
Bing Maps Account Center の [Create or view keys] から Bing Maps Key を取得する。
Application Type はよくわからなかったけど Broadcast (Application is used for public or internal-facing television, movies or similar.) にしておいた。
以下、関連するヘルプページ。
Mozilla Firefox で見ると長い URL が切れててスクロールもできないので見れない。なんとかしてほしい。。。
- Creating a Bing Maps Account
- Getting a Bing Maps Key
Bing Maps REST Services Imagery API の仕様とかドキュメントとか
ドキュメントはこのへん。
基本的な画像取得URLのフォーマットはこんな感じ。
http://dev.virtualearth.net/REST/v1/Imagery/Map/imagerySet/centerPoint/zoomLevel?mapSize=mapSize&pushpin=pushpin&mapLayer=mapLayer&format=format&key=BingMapsKey
地図画像の種類は URL の imagerySet の部分で指定できる。次の5種類が使用可能。
- Aerial – Aerial imagery. (航空写真)
- AerialWithLabels –Aerial imagery with a road overlay. (航空写真とテキスト)
- Road – Roads without additional imagery. (道路地図)
- OrdnanceSurvey --Ordnance Survey imagery. (イギリス政府の地図スタイル?)
- CollinsBart – Collins Bart imagery. (スコットランドの地図スタイル?)
OrdnanceSurvey と CollinsBart はつい最近使えるようになったみたい。9/22に Bing Maps Blog でアナウンスされていた。
Ordnance Survey GB Maps and Collins Bartholomew Style
For our friends in the UK we have added support for the Ordnance Survey GB maps and the Collins Bartholomew style to our REST web service API. The Ordnance Survey Maps are available from zoom-level 10 to 15 and the Collins Bartholomew style is available from level 10 to 17.
Bing Updates to Bing Maps: REST API, AJAX Control v7, and Account Center - Bing Maps Blog - Site Blogs - Bing Community
Ordnance Survey についてはこのへん。
Ordnance Survey (Welsh: Arolwg Ordnans), an executive agency and non-ministerial government department of the Government of the United Kingdom,[1] is the national mapping agency for Great Britain,[2] producing maps of Great Britain (and to an extent, the Isle of Man), and one of the world's largest producers of maps.
Ordnance Survey - Wikipedia, the free encyclopedia
Maps of Britain from Ordnance Survey - buy paper maps and GIS data
Collins Bart についてはこのへん。
Collins Bartholomew, formerly John Bartholomew and Son, is a long-established map publishing company originally based in Edinburgh, Scotland. It is currently a subsidiary of HarperCollins.
Collins Bartholomew - Wikipedia, the free encyclopedia
よくわからなかったけど、とりあえずいいや。。。
Bing Maps REST Services Imagery API を使ってみる
試しに、名古屋駅付近の地図をいくつかの縮尺で表示してみる。
key パラメータには Bing Maps Account Center で取得した Bing Maps Key を指定する。
http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/35.170727,136.882603/6?key=BingMapsKey
http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/35.170727,136.882603/8?key=BingMapsKey
http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/35.170727,136.882603/10?key=BingMapsKey
http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/35.170727,136.882603/14?key=BingMapsKey
http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/35.170727,136.882603/15?key=BingMapsKey
http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/35.170727,136.882603/16?key=BingMapsKey
http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/35.170727,136.882603/17?key=BingMapsKey
かっこいいデザインも用意されていたりする。
Ordnance Survey GB Maps
http://dev.virtualearth.net/REST/v1/Imagery/Map/OrdnanceSurvey/51.506666,-0.129436/15?format=jpeg&key=BingMapsKey
残念ながら日本の地図には OrdnanceSurvey は使えないっぽい。
http://dev.virtualearth.net/REST/v1/Imagery/Map/OrdnanceSurvey/35.170727,136.882603/15?format=jpeg&key=BingMapsKey
Collins Bartholomew Style
http://dev.virtualearth.net/REST/v1/Imagery/Map/CollinsBart/51.506666,-0.129436/15?key=BingMapsKey
CollinsBart も日本の地図には使えないみたい。これかっこいいから日本の地図でもできるといいのになぁ。
http://dev.virtualearth.net/REST/v1/Imagery/Map/CollinsBart/35.170727,136.882603/15?key=BingMapsKey
Bing Maps REST Services Imagery API で経路探索した地図を使ってみる
始点と終点を指定すると自動で経路探索して描画してくれる。
フォーマット:
http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?key=BingMapsKey&mapSize=400,400&wp.0=始点の緯度,始点の経度&wp.1=終点の緯度,終点の経度
地名も使えるみたいだけど、今回は緯度経度を指定してみる。
wp.0 にスタート地点の緯度経度を指定
wp.1 にゴール地点の緯度経度を指定
たとえば New York City Hall Park (40.712771,-74.006294) から New York Transit Museum (40.691087,-73.989751) への地図
http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?key=BingMapsKey&mapSize=400,400&wp.0=40.712771,-74.006294&wp.1=40.691087,-73.989751
なかなかいい感じ。
日本もやってみる。名古屋駅から名古屋城への地図 (Road)
http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?key=BingMapsKey&mapSize=400,400&wp.0=35.170663,136.88172099999997&wp.1=35.185589,136.89905899999997
あれ、なんかすごくずれてる。。。
試しに、航空写真 (AerialWithLabels) に変えてみたけど、同じく経路がおかしい。
http://dev.virtualearth.net/REST/v1/Imagery/Map/AerialWithLabels/Routes?key=BingMapsKey&mapSize=400,400&wp.0=35.170663,136.88172099999997&wp.1=35.185589,136.89905899999997
いくつかの場所で試してみたけど、日本だとうまくいかない。もしかしたら、日本の地図上ではまともに経路探索できないのかも。
とりあえず、せっかくなのでこのまえ作った Google Maps API と YOLP 経路地図API のマッシュアップ に Bing Maps API も追加してみてちょっと作り直してみた。
Bing Map API の経路探索がおかしいけど、まぁこれはこれで。
tags: bing_maps_api
Posted by NI-Lab. (@nilab)