[MaaStep]Bing Map でGeocodingして緯度経度を取得

はじめに
前回はReactとLeafletを用いて、Open Street Map(OSM)の地図を表示しました。
その際に、ピンを打つなども行ったのですが、OSMの地図上にピンを打つためには緯度経度が必要です。 そのため、Bing Mapを用いてGeocodingして緯度経度を取得してみます。
必要なもの
- Azureのサブスクリプション(もしくは Microsoft アカウント)
Bing Maps Keyの取得
今回はAzure portalからキーの取得を行います。
Microsoft アカウントからキーの取得を行う場合はこちらを参考にしてください。
1) Azure portalでBing Maps API for Enterpriseを検索し、選択

2) Bing Maps API for Enterpriseを追加

3) 以下のように入力して作成をクリック

Pricing Tierに関しては今回はお試しのため、無料で使える「Public Website Transactions Level 1」を選択します。

4) 作成したリソースを選択し、右下の「すべての設定」をクリックする

5) 設定の中から「Key Management」を選択し、「query key」をコピーする

Geocoding
Bing MapでGeocodingするためには住所が必要です。
「東京タワー」などの建物名などでは検索できません。
今回は東京タワー(東京都港区芝公園4丁目2−8)を検索していきます。
こちらを参考にすると、以下のURLで取得できるようです。
https://dev.virtualearth.net/REST/v1/Locations?countryRegion=JP&adminDistrict=<県名>&locality=<市町村名>&addressLine=<番地>&o=xml&key=<先ほど取得したquerykey>
今回は東京タワーのため、以下のURLとなります。
https://dev.virtualearth.net/REST/v1/Locations?countryRegion=JP&adminDistrict=東京都&locality=港区芝公園&addressLine=4-2−8&o=xml&key=<先ほど取得したquerykey>
ブラウザなどで先ほどのURLを表示させると、以下のようにXML形式で返ってきます。
この中のGeocodePointに緯度経度が入っています。

おわりに
今回はBing Mapを用いてGeocodingして緯度経度を取得を試みました。
今後は建物名を住所に変換するAPIなどを探していきたいと思います。