Class: QgsGoogleMapsGeocoder

class qgis.core.QgsGoogleMapsGeocoder(apiKey: str, regionBias: str = '')

Bases: QgsGeocoderInterface

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.

QgsGoogleMapsGeocoder(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.

New in version 3.18.

Parameters
  • apiKey (str) –

  • regionBias

apiKey(self) → str

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

See also

setApiKey()

Return type

str

appendedFields(self)QgsFields
Return type

QgsFields

flags(self)QgsGeocoderInterface.Flags
Return type

QgsGeocoderInterface.Flags

geocodeString(self, string: str, context: QgsGeocoderContext, feedback: QgsFeedback = None) → List[QgsGeocoderResult]
Parameters
Return type

List[QgsGeocoderResult]

jsonToResult(self, json: Dict[str, Any])QgsGeocoderResult

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

Parameters

json (Dict[str) –

Return type

QgsGeocoderResult

region(self) → str

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, bounds: QgsRectangle = QgsRectangle()) → QUrl

Returns the URL generated for geocoding the specified address.

Parameters
  • address (str) –

  • bounds (QgsRectangle = QgsRectangle()) –

Return type

QUrl

setApiKey(self, key: str)

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 (str) –

setEndpoint(self, endpoint: str)

Sets a specific API endpoint to use for requests. This is for internal testing purposes only.

Parameters

endpoint (str) –

setRegion(self, region: str)

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 (str) –

wkbType(self)QgsWkbTypes.Type
Return type

QgsWkbTypes.Type