2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Amazon Location Serviceのジオコーディングのオプションを試してみる

Last updated at Posted at 2021-11-30

概要

Amazon Location Serviceのジオコーディングでは、以下のオプションが用意されています

  • 近くの場所のジオコーディング
  • 境界ボックス内のジオコーディング
  • 国内のジオコーディング

これらのオプションを、デモサイトに実装しましたので、紹介したいと思います

スクリーンショット 2021-11-17 2.06.31.png

近くの場所のジオコーディング

位置の近くの場所のジオコーディングを行います
デモサイトでは、表示されている箇所の中心位置に近い場所に対して行っています

// 中心から近い箇所の検索設定
// 中心位置オプションのチェックボックスが入っていた場合
if (this.search.selectedBiasCenterSearch === true) {
    // 中心座標の取得
    const center = this.mapObject.getCenter();
    // ポストパラメーターの設定
    params.BiasPosition = [center.lng, center.lat];
}

BiasPositionというオプションに、位置を設定すると、その位置から近い場所のデータが優先されて返ってきます

境界ボックス内のジオコーディング

指定した範囲の場所のジオコーディングを行います
デモサイトでは、表示されている範囲の場所に対して行っています

// 範囲の検索設定
// 範囲位置オプションのチェックボックスが入っていた場合
if (this.search.selectedBboxSearch === true) {
  //現在表示されている範囲のBBOXを取得
  const bounds = this.mapObject.getBounds();
  // ポストパラメーターの設定
  params.FilterBBox = [
    bounds._sw.lng,
    bounds._sw.lat,
    bounds._ne.lng,
    bounds._ne.lat,
  ];
}

FilterBBoxというオプションに、バウンディングボックスを設定すると、その範囲でジオコーディングしてくれます

国内のジオコーディング

FilterCountriesというオプションに ISO3166 の3桁の国コードを指定すると、指定した国の中だけでジオコーディング可能となります

デモサイトでは日本を指定してジオコーディングしています
パラメーターの値は配列で、複数の国を指定可能です

FilterCountries: ['JPN'],

以上、Amazon Location Serviceのジオコーディングのオプションの紹介でした
これらを実装したデモサイトはこちらになります

2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?