Class: QgsGoogleMapsGeocoder¶
A geocoder which uses the Google Map geocoding API to retrieve results.
This geocoder utilizes the Google Maps “geocoding” API in order to geocode strings. The Google Maps service is not publicly available, and accordingly an API key must be first obtained from Google and specified when constructing this class.
Warning
The user is responsible for managing their Google Maps API key, and ensuring that the use of this geocoder does not exceed their usage limits! Excessive use of the Google Maps geocoder API can result in charges being applied to the API key holder.
Added in version 3.18.
Class Hierarchy¶
Base classes¶
Interface for geocoders. |
Methods
Returns the API key which will be used when accessing the Google Maps API. |
|
Converts a JSON result returned from the Google Maps service to a geocoder result object. |
|
Returns the optional region bias which will be used to prioritize results in a certain region. |
|
Returns the URL generated for geocoding the specified address. |
|
Sets the API key to use when accessing the Google Maps API. |
|
Sets a specific API endpoint to use for requests. |
|
Sets the optional region bias which will be used to prioritize results in a certain region. |
- class qgis.core.QgsGoogleMapsGeocoder[source]¶
Bases:
QgsGeocoderInterface
- __init__(apiKey: str | None, regionBias: str | None = '')
Constructor for QgsGoogleMapsGeocoder.
The
apiKey
argument must specify a valid Google Maps API key. All use of this geocoder will be associated with the specified key for Google’s billing purposes!Optionally, a
regionBias
can be specified to prioritize results in a certain region. TheregionBias
argument must be set to a two letter country code top-level domain value, e.g. “gb” for Great Britain.- Parameters:
apiKey (Optional[str])
regionBias (Optional[str] = '')
- __init__(a0: QgsGoogleMapsGeocoder)
- Parameters:
- apiKey(self) str [source]¶
Returns the API key which will be used when accessing the Google Maps API.
See also
- Return type:
str
- jsonToResult(self, json: Dict[str, Any]) QgsGeocoderResult [source]¶
Converts a JSON result returned from the Google Maps service to a geocoder result object.
- Parameters:
json (Dict[str, Any])
- Return type:
- region(self) str [source]¶
Returns the optional region bias which will be used to prioritize results in a certain region.
See also
- Return type:
str
- requestUrl(self, address: str | None, bounds: QgsRectangle = QgsRectangle()) QUrl [source]¶
Returns the URL generated for geocoding the specified
address
.- Parameters:
address (Optional[str])
bounds (
QgsRectangle
= QgsRectangle())
- Return type:
QUrl
- setApiKey(self, key: str | None)[source]¶
Sets the API
key
to use when accessing the Google Maps API.All use of this geocoder will be associated with the specified key for Google’s billing purposes!
See also
- Parameters:
key (Optional[str])
- setEndpoint(self, endpoint: str | None)[source]¶
Sets a specific API
endpoint
to use for requests. This is for internal testing purposes only.- Parameters:
endpoint (Optional[str])