Places¶
Place
¶
Google Places lookup client.
Purpose
Resolves place details and text queries into canonical location records.
Attributes:
| Name | Type | Description |
|---|---|---|
maps |
Optional[Map]
|
Google Maps gateway used for Places requests. |
cache |
Optional[BaseCache]
|
Optional response cache. |
country |
Optional[str]
|
Current search region bias. |
query |
Optional[str]
|
Current place search query. |
hit |
Optional[Dict[str, Any]]
|
Most recent cache hit. |
params |
Optional[Dict[str, str]]
|
Current API query parameters. |
request |
Optional[Dict[str, str]]
|
Last request payload or query. |
search |
Optional[Dict]
|
Most recent search response. |
results |
Optional[List]
|
Most recent candidate locations. |
details |
Optional[Dict]
|
Most recently retrieved place details. |
geometry |
Optional[Dict]
|
Location geometry from a place response. |
key |
Optional[str]
|
Cache key for the current lookup. |
output |
Optional[Dict]
|
Most recent normalized location result. |
prefix |
Optional[str]
|
Current cache-key namespace. |
parts |
Optional[Tuple]
|
Components used to construct the current cache key. |
place_id |
Optional[str]
|
Current Google Places identifier. |
Purpose
Initializes Place objects given a map and optional cache
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maps
|
Maps
|
Maps gateway instance. |
required |
cache
|
Optional[BaseCache]
|
Optional cache for query results. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
Places instance with text search and place-details helpers. |
Source code in mapping.py
Methods:¶
key_for
¶
Purpose
Create a stable cache key from a namespace prefix and one or more string parts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prefix
|
str
|
Cache namespace or operation prefix. |
required |
parts
|
List[str]
|
Values that uniquely identify the request. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Normalized cache key. |
Source code in mapping.py
component_value
¶
component_value(
components: List[Dict[str, Any]],
kind: str,
want_long: bool = False,
) -> Optional[str]
Purpose
Extract a single address component value from a Google Places or Geocoding address_components collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
List[Dict[str, Any]]
|
Google address component dictionaries. |
required |
kind
|
str
|
Component type to extract, such as country or locality. |
required |
want_long
|
bool
|
When True, return long_name instead of short_name. |
False
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional[str]: Component value when present; otherwise None. |
Source code in mapping.py
flatten_place_details
¶
Purpose
Convert a Place Details result into the same flattened output shape used by Geocoder.flatten_geocode(...).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
details
|
Dict[str, Any]
|
Google Place Details result dictionary. |
required |
query
|
str
|
Original query text, when available. |
''
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Canonical location dictionary. |
Source code in mapping.py
place_details
¶
Purpose
Fetch and flatten details for a known Google place_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
place_id
|
str
|
Google Places place identifier. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any] | None
|
Dict[str, Any] | None: Canonical flattened place details. |
Source code in mapping.py
text_to_location
¶
Purpose
Resolve a free-text query into a canonical address and coordinate record via Google Places Text Search and Place Details.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Arbitrary human-entered text such as "Newcastle, NSW, AU". |
required |
country
|
str
|
ISO-2 region bias such as "AU" or "US". |
'US'
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any] | None
|
Dict[str, Any] | None: Canonical location dictionary compatible with Geocoder output. |
Raises:
| Type | Description |
|---|---|
NotFound
|
Raised when no candidate is returned. |
Source code in mapping.py
search_candidates
¶
Purpose
Return multiple Places Text Search candidates for a query. This is intended for future UI candidate-selection workflows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Free-text search query. |
required |
country
|
str
|
ISO-2 region bias. |
'US'
|
lmt
|
int
|
Maximum candidates to return. |
5
|
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Raw candidate dictionaries returned by Text Search. |