Class: QgsGoogleMapsGeocoder¶
- class qgis.core.QgsGoogleMapsGeocoder¶
Bases:
QgsGeocoderInterface
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.
QgsGoogleMapsGeocoder(apiKey: str, regionBias: str = ‘’) 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.QgsGoogleMapsGeocoder(
QgsGoogleMapsGeocoder
)Methods
Returns the API key which will be used when accessing the Google Maps API.
- rtype
QgsFields
- rtype
QgsGeocoderInterface.Flags
- param string
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.- rtype
QgsWkbTypes.Type
- apiKey(self) str ¶
Returns the API key which will be used when accessing the Google Maps API.
See also
- Return type
str
- flags(self) QgsGeocoderInterface.Flags ¶
- Return type
- geocodeString(self, string: str, context: QgsGeocoderContext, feedback: QgsFeedback = None) List[QgsGeocoderResult] ¶
- Parameters
string (str) –
context (QgsGeocoderContext) –
feedback (
QgsFeedback
= None) –
- 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
- region(self) str ¶
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, 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
- 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
- Parameters
region (str) –
- wkbType(self) QgsWkbTypes.Type ¶
- Return type