You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取完整address_component值列表及小众地址元素可选值?

How to Get the Full List of address_component Values for Google Places API

Great question—this is a common pain point since the official Places Details docs only show examples of the address_component array instead of a complete list of possible values. Here’s how you can track down all possible types, including niche elements like pre-directions and post-directions:

1. Use the Shared Type System with Geocoding API

The Google Places API shares the exact same address_component type framework as the Geocoding API, which has a more comprehensive documented list of types. This includes under-documented options like:

  • subpremise: For apartment numbers, unit IDs, or suite numbers
  • neighborhood: Localized community or neighborhood names
  • postal_code_suffix: The secondary part of a postal code (e.g., the "1234" in "90210-1234")
  • administrative_area_level_4/administrative_area_level_5: Hyper-local administrative divisions used in some countries

2. Test Diverse Addresses to Capture Niche Types

The most reliable way to uncover rare or region-specific types is to send Places Details requests for addresses that include the elements you care about. For example:

  • Pre/post-directions: Test addresses like "123 North Main Street" or "456 Oak Avenue West"—you’ll find direction prefixes/suffixes either embedded in the route component’s name, or in some regions, as a standalone component tied to street orientation.
  • Special address formats: Test PO boxes ("PO Box 789"), military addresses, or European-style addresses with plazas to capture types like premise or intersection.
  • International addresses: Check addresses from countries with unique structures (e.g., Japan’s chōme-block system, India’s village-level divisions) to find region-exclusive types.

3. Tap Into Community-Curated Lists

Many developers have shared compiled lists of address_component types on platforms like Stack Overflow. These often include niche types that don’t make it into official docs, such as:

  • postal_town: Used in the UK to denote the main town linked to a postal code
  • sublocality_level_3/sublocality_level_4: Ultra-local neighborhood divisions
  • street_number_prefix: Rarely used, but appears in some regions for numbered street prefixes

4. Parse for Directional Elements

For pre-direction and post-direction specifically, since they’re often not standalone components, you can:

  • Split the route component’s long_name or short_name to extract directional terms (e.g., "North", "W", "West") using regex or string matching tailored to regional address conventions.
  • Check for components where the types array includes route and the name is a directional term—this occurs in some regions where directions are treated as separate address elements.

Remember, address structures vary wildly by country, so always build fallback logic to handle cases where a niche element isn’t returned.

内容的提问来源于stack exchange,提问作者Dave Graham

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 10:02:04