一般的にプレイス ID は、(たとえば Places API、または Maps JavaScript API のプレイス ライブラリを利用して)場所を検索し、返されたプレイス ID で場所の詳細を取得するために使用されます。プレイス ID を保存しておき、その ID を使って後で同じ場所の詳細を取得することも可能です。詳しくは、この後のプレイス ID の保存についての説明をご覧ください。
Maps JavaScript API のプレイス ライブラリの使用例
プレイス ID を JavaScript アプリで使用するには、まず ID を取得します。ID は、Place Search や、Place Autocomplete サービスの getPlace() によって返される PlaceResult から取得できます。そのプレイス ID を使って、Place Details で場所の詳細を検索できます。
varmap;functioninitialize(){// Create a map centered in Pyrmont, Sydney (Australia).map=newgoogle.maps.Map(document.getElementById('map'),{center:{lat:-33.8666,lng:151.1958},zoom:15});// Search for Google's office in Australia.varrequest={location:map.getCenter(),radius:'500',query:'Google Sydney'};varservice=newgoogle.maps.places.PlacesService(map);service.textSearch(request,callback);}// Checks that the PlacesServiceStatus is OK, and adds a marker// using the place ID and location from the PlacesService.functioncallback(results,status){if(status==google.maps.places.PlacesServiceStatus.OK){varmarker=newgoogle.maps.Marker({map:map,place:{placeId:results[0].place_id,location:results[0].geometry.location}});}}google.maps.event.addDomListener(window,'load',initialize);
プレイス ID を後で使えるように保存する
プレイス ID は、Google Maps Platform 利用規約のセクション 3.2.3(b)で定められているキャッシュ制限の対象外となります。このため、プレイス ID 値は後で使用するために保存しても問題ありません。
このリクエストは NOT_FOUND ステータス コードを返すこともあります。対策として、それぞれのプレイス ID を返した元のリクエストを保存しておくことをおすすめします。プレイス ID が無効になった場合は、リクエストを再発行して新しい結果を取得することができます。この検索結果に元の場所が含まれているとは限りませんが、このリクエストは課金対象です。
プレイス ID 使用時のエラーコード
INVALID_REQUEST ステータス コードは、指定されたプレイス ID が無効であることを意味します。プレイス ID が不完全、または変更され、正しくない場合は、INVALID_REQUEST が返されることがあります。
NOT_FOUND ステータス コードは、指定されたプレイス ID が古くなっていることを意味します。お店やサービスが閉業した場合や移転した場合、プレイス ID が古くなることがあります。プレイス ID は、Google マップのデータベースの大規模な更新によって変わることもあります。そのような場合、場所には新しいプレイス ID が付与され、古い ID は NOT_FOUND レスポンスを返します。
特に、プレイス ID の種類によっては、NOT_FOUND レスポンスが返される場合があります。また、API によって、レスポンスで別のプレイス ID が返される場合もあります。これに該当するのは次のようなプレイス ID です。
Google マップ上に正確な住所はないものの、住所の範囲から推定される番地。
リクエストで都市や地域区分も指定されている場合の長いルートの区間。
交差点。
subpremise タイプの住所コンポーネントが含まれる場所。
ほとんどの場合、こうした場所の ID は長い文字列になります(プレイス ID の長さに上限はありません)。例は次のとおりです。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-12-22 UTC。"],[[["\u003cp\u003ePlace IDs are unique text identifiers for places in the Google Places database and are used across multiple Google Maps Platform APIs.\u003c/p\u003e\n"],["\u003cp\u003eYou can find a place's ID using the provided Place ID finder or by searching for the place using the Places API or Places library.\u003c/p\u003e\n"],["\u003cp\u003ePlace IDs can be stored for later use and should be refreshed if older than 12 months using a Place Details request.\u003c/p\u003e\n"],["\u003cp\u003eInvalid or obsolete Place IDs result in \u003ccode\u003eINVALID_REQUEST\u003c/code\u003e or \u003ccode\u003eNOT_FOUND\u003c/code\u003e error codes, respectively, and certain Place ID types are more prone to these errors.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/maps/documentation/places/android-sdk/place-id \"View this page for the Android platform docs.\") [iOS](/maps/documentation/places/ios-sdk/place-id \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/place-id \"View this page for the JavaScript platform docs.\") [Web Service](/maps/documentation/places/web-service/place-id \"View this page for the Web Service platform docs.\") \n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nIntroduction\n\nPlace IDs uniquely identify a place in the Google Places database and on Google Maps. Place IDs\nare accepted in requests to the following Maps APIs:\n\n- Retrieving an address for a Place ID in the Geocoding API and Geocoding Service, Maps JavaScript API.\n- Specifying origin, destination and intermediate waypoints in the Routes API and Directions API (Legacy) and Directions Service, Maps JavaScript API (Legacy).\n- Specifying origins and destinations in the Routes API and Distance Matrix API (Legacy) and Distance Matrix Service, Maps JavaScript API (Legacy).\n- Retrieving Place Details in Places API (New), Places SDK for Android (New), Places SDK for iOS (New), and Places Library.\n- Using Place ID parameters in Maps Embed API.\n- Retrieving search queries in Maps URLs.\n- Displaying speed limits in Roads API.\n- Finding and styling boundary polygons in data-driven styling for boundaries.\n\nFind the ID of a particular place\n\nAre you looking for the place ID of a specific place? Use the place ID\nfinder below to search for a place and get its ID:\n\nAlternatively, you can\n[view\nthe place ID finder](/maps/documentation/javascript/examples/places-placeid-finder) with its code in the Maps JavaScript API\ndocumentation.\n\nOverview\n\nA place ID is a textual identifier that uniquely identifies a place. The\nlength of the identifier may vary (there is no maximum length for place IDs).\nExamples:\n\n- `\n ChIJgUbEo8cfqokR5lP9_Wh_DaM\n `\n- `\n GhIJQWDl0CIeQUARxks3icF8U8A\n `\n- `\n EicxMyBNYXJrZXQgU3QsIFdpbG1pbmd0b24sIE5DIDI4NDAxLCBVU0EiGhIYChQKEgnRTo6ixx-qiRHo_bbmkCm7ZRAN\n `\n- `\n EicxMyBNYXJrZXQgU3QsIFdpbG1pbmd0b24sIE5DIDI4NDAxLCBVU0E\n `\n- `\n IhoSGAoUChIJ0U6OoscfqokR6P225pApu2UQDQ\n `\n\nPlace IDs are available for most locations, including businesses, landmarks,\nparks, and intersections. It is possible for the same place or location to\nhave multiple different place IDs. Place IDs may change over time.\n\nYou can use the same place ID across the Places API and a\nnumber of Google Maps Platform APIs. For example, you can use the same place ID to\nreference a place in the\n[Places API](/maps/documentation/places), the\n[Maps JavaScript API](/maps/documentation/javascript/places),\nthe [Geocoding API](/maps/documentation/geocoding),\nthe [Maps Embed API](/maps/documentation/embed)\nand the [Roads API](/maps/documentation/roads/speed-limits).\n\nRetrieve place details using the place ID\n\nA common way of using place IDs is to search for a place\n(using the [Places API](/maps/documentation/places/web-service)\nor the [Places\nlibrary](/maps/documentation/javascript/places#place_searches) in the Maps JavaScript API, for example) then use the\nreturned place ID to retrieve place details. You can store the place ID and\nuse it to retrieve the same place details later. Read about\n[saving place IDs](#save-id) below.\n\nExample using the Places Library in the Maps JavaScript API\n\nTo use a place ID in your JavaScript app, you must first find the ID,\nwhich is available in the `PlaceResult` returned by a\n[Place\nSearch](/maps/documentation/javascript/places#place_search_responses), or by `getPlace()` in the\n[Place Autocomplete (Legacy)](/maps/documentation/javascript/places-autocomplete#get_place_information)\nservice. Then you can use the place ID to look up\n[place\ndetails](/maps/documentation/javascript/places#place_details_requests). \n\n```javascript\nvar map;\n\nfunction initialize() {\n // Create a map centered in Pyrmont, Sydney (Australia).\n map = new google.maps.Map(document.getElementById('map'), {\n center: {lat: -33.8666, lng: 151.1958},\n zoom: 15\n });\n\n // Search for Google's office in Australia.\n var request = {\n location: map.getCenter(),\n radius: '500',\n query: 'Google Sydney'\n };\n\n var service = new google.maps.places.PlacesService(map);\n service.textSearch(request, callback);\n}\n\n// Checks that the PlacesServiceStatus is OK, and adds a marker\n// using the place ID and location from the PlacesService.\nfunction callback(results, status) {\n if (status == google.maps.places.PlacesServiceStatus.OK) {\n var marker = new google.maps.Marker({\n map: map,\n place: {\n placeId: results[0].place_id,\n location: results[0].geometry.location\n }\n });\n }\n}\n\ngoogle.maps.event.addDomListener(window, 'load', initialize);\n```\n\nSave place IDs for later use\n\nPlace IDs are **exempt from** the caching restrictions stated in\n[Section 3.2.3(b)](https://cloud.google.com/maps-platform/terms#3.-license.)\nof the Google Maps Platform Terms of Service. You can therefore store place ID values for later\nuse.\n\nRefresh stored place IDs\n\nBecause Place IDs may change due to updates on the Google Maps database, Google recommends\nrefreshing place IDs if they are more than 12 months old. You can refresh Place IDs **at no\ncharge** by making a\n\n\n[Place Details request](/maps/documentation/javascript/places#place_details_requests),\nspecifying only the `place_id`\n\n\nfield in the `fields` parameter.\n\nThis call triggers the\n\n\n[Places Details - ID Refresh](/maps/billing-and-pricing/sku-details#place-details-id-refresh-ess-sku)\n\n\nSKU.\n\nError codes when using place IDs\n\n`INVALID_REQUEST`\n\nThe `INVALID_REQUEST` status code indicates that the specified\nplace ID is not valid. `INVALID_REQUEST` may be returned when the\nplace ID has been truncated or otherwise modified, and is no longer correct.\n\n`NOT_FOUND`\n\nThe `NOT_FOUND` status code indicates that the specified place ID\nis obsolete. A place ID may become obsolete if a business closes or moves to\na new location. Place IDs may also change due to updates on the Google\nMaps database. In such cases, a place may receive a new place ID, and the old\nID returns a `NOT_FOUND` response.\n| **Note:** Place IDs that are obsolete may continue to be returned in Place Autocomplete (Legacy), Query Autocomplete (Legacy), or Autocomplete (New) responses for a few days after the place ID has been removed from the Google Maps database.\n\nTo refresh results in the event of an obsolete place ID, store the original request that\nreturned each place ID and re-issue the request as needed. Note that the **re-issued request is\nbilled at the appropriate SKU.**\n\nSome types of place IDs may sometimes cause a\n`NOT_FOUND` response, or the API may return a different place ID in\nthe response. These place ID types include:\n\n- Street addresses that don't exist in Google Maps as precise addresses, but are inferred from a range of addresses.\n- Segments of a long route, where the request also specifies a city or locality.\n- Intersections.\n- Places with an address component of type `subpremise`.\n\nThese IDs often take the form of a long string (there is no maximum length\nfor Place IDs). For example: \n\n```\nEpID4LC14LC_4LCo4LCv4LGN4LCo4LCX4LCw4LGNIC0g4LC44LGI4LCm4LGN4LCs4LC-4LCm4LGNIOCwsOCxi-CwoeCxjeCwoeCxgSAmIOCwteCwv-CwqOCwr-CxjSDgsKjgsJfgsLDgsY0g4LCu4LGG4LCv4LC_4LCo4LGNIOCwsOCxi-CwoeCxjeCwoeCxgSwg4LC14LC_4LCo4LCv4LGNIOCwqOCwl-CwsOCxjSDgsJXgsL7gsLLgsKjgsYAsIOCwsuCwleCxjeCwt-CxjeCwruCwv-CwqOCwl-CwsOCxjSDgsJXgsL7gsLLgsKjgsYAsIOCwuOCwsOCxguCwsOCxjSDgsKjgsJfgsLDgsY0g4LC14LGG4LC44LGN4LCf4LGNLCDgsLjgsK_gsYDgsKbgsL7gsKzgsL7gsKbgsY0sIOCwueCxiOCwpuCwsOCwvuCwrOCwvuCwpuCxjSwg4LCk4LGG4LCy4LCC4LCX4LC-4LCjIDUwMDA1OSwg4LCt4LC-4LCw4LCk4LCm4LGH4LC24LCCImYiZAoUChIJ31l5uGWYyzsR9zY2qk9lDiASFAoSCd9ZebhlmMs7Efc2NqpPZQ4gGhQKEglDz61OZpjLOxHgDJCFY-o1qBoUChIJi37TW2-YyzsRr_uv50r7tdEiCg1MwFcKFS_dyy4\n```"]]