0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Google Maps Nearby Search API の基本

Posted at

はじめに

Google Maps PlatformのNearby Search API(新バージョン)を活用し、指定したエリア周辺の店舗や施設情報を効率的に取得する方法を解説します

Nearby Search APIとは?

Nearby Search APIは、
指定した緯度・経度と半径を基準に、周辺の店舗や施設(レストラン、カフェなど)を検索できるAPIです。
検索条件として「場所タイプ」や「キーワード」などを指定することができ、用途に応じて柔軟に情報を取得できます

Nearby Search APIの基本的な使い方

リクエスト例

curl -X POST -d '{
  "includedTypes": ["restaurant"],
  "maxResultCount": 2,
  "locationRestriction": {
    "circle": {
      "center": { "latitude": 35.6895, "longitude": 139.6917 },
      "radius": 500.0
    }
  },
  "languageCode": "ja"
}' \
-H 'Content-Type: application/json' \
-H "X-Goog-Api-Key: {API_KEY}" \
-H "X-Goog-FieldMask: places.id,places.displayName,places.location" \
"https://places.googleapis.com/v1/places:searchNearby"
  • includedTypes: 検索したい施設タイプ(例: restaurant, cafe, bank など)
  • locationRestriction: 検索中心座標と半径(最大50,000m)
  • maxResultCount: 最大取得件数
  • X-Goog-FieldMask: レスポンスで取得したい項目(必須
  • languageCode: 言語

レスポンス例

{
  "places": [
    {
      "id": "ChIJ0zbr5v7zGGAR-PzrYw6YsK4",
      "location": {
        "latitude": 35.6910689,
        "longitude": 139.69019219999998
      },
      "displayName": {
        "text": "むさしの森Diner 新宿中央公園店",
        "languageCode": "ja"
      }
    },
    {
      "id": "ChIJBa5ePGfzGGART3FE40yRgr4",
      "location": {
        "latitude": 35.6882759,
        "longitude": 139.6883076
      },
      "displayName": {
        "text": "MORETHAN TAPAS LOUNGE",
        "languageCode": "ja"
      }
    }
  ]
}

よく使うパラメータ

パラメータ 説明
includedTypes 検索したい施設タイプ(複数指定可)
locationRestriction 検索範囲(中心座標+半径)
maxResultCount 最大取得件数
rankPreference 並び順(POPULARITYまたはDISTANCE)
X-Goog-FieldMask レスポンスで取得する項目(必須)
languageCode レスポンスの言語指定

まとめ

Nearby Search APIは、Google Mapsの豊富なデータを活用し、
簡単に周辺施設の情報を取得できる便利なツールです。
基本の使い方を押さえれば、さまざまなジャンルの店舗やスポットを効率よく検索できます。
また、Place Details APIと組み合わせれば、より詳細な情報も取得できます。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?