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

Inheritance diagram of qgis.core.QgsGoogleMapsGeocoder

Base classes

QgsGeocoderInterface

Interface for geocoders.

Methods

apiKey

Returns the API key which will be used when accessing the Google Maps API.

jsonToResult

Converts a JSON result returned from the Google Maps service to a geocoder result object.

region

Returns the optional region bias which will be used to prioritize results in a certain region.

requestUrl

Returns the URL generated for geocoding the specified address.

setApiKey

Sets the API key to use when accessing the Google Maps API.

setEndpoint

Sets a specific API endpoint to use for requests.

setRegion

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. The regionBias 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:

a0 (QgsGoogleMapsGeocoder)

apiKey(self) str[source]

Returns the API key which will be used when accessing the Google Maps API.

See also

setApiKey()

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:

QgsGeocoderResult

region(self) str[source]

Returns the optional region bias which will be used to prioritize results in a certain region.

See also

setRegion()

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

apiKey()

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])

setRegion(self, region: str | None)[source]

Sets the optional region bias which will be used to prioritize results in a certain region.

The region argument must be set to a two letter country code top-level domain value, e.g. “gb” for Great Britain.

See also

region()

Parameters:

region (Optional[str])