QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsGoogleMapsGeocoder Class Reference

A geocoder which uses the Google Map geocoding API to retrieve results. More...

#include <qgsgooglemapsgeocoder.h>

Inheritance diagram for QgsGoogleMapsGeocoder:
Inheritance graph
[legend]

Public Member Functions

 QgsGoogleMapsGeocoder (const QString &apiKey, const QString &regionBias=QString())
 Constructor for QgsGoogleMapsGeocoder.
 
QString apiKey () const
 Returns the API key which will be used when accessing the Google Maps API.
 
QgsFields appendedFields () const override
 Returns a set of newly created fields which will be appended to existing features during the geocode operation.
 
Flags flags () const override
 Returns the geocoder's capability flags.
 
QList< QgsGeocoderResultgeocodeString (const QString &string, const QgsGeocoderContext &context, QgsFeedback *feedback=nullptr) const override
 Geocodes a string.
 
QgsGeocoderResult jsonToResult (const QVariantMap &json) const
 Converts a JSON result returned from the Google Maps service to a geocoder result object.
 
QString region () const
 Returns the optional region bias which will be used to prioritize results in a certain region.
 
QUrl requestUrl (const QString &address, const QgsRectangle &bounds=QgsRectangle()) const
 Returns the URL generated for geocoding the specified address.
 
void setApiKey (const QString &key)
 Sets the API key to use when accessing the Google Maps API.
 
void setEndpoint (const QString &endpoint)
 Sets a specific API endpoint to use for requests.
 
void setRegion (const QString &region)
 Sets the optional region bias which will be used to prioritize results in a certain region.
 
Qgis::WkbType wkbType () const override
 Returns the WKB type of geometries returned by the geocoder.
 
- Public Member Functions inherited from QgsGeocoderInterface
virtual ~QgsGeocoderInterface ()=default
 
virtual QList< QgsGeocoderResultgeocodeFeature (const QgsFeature &feature, const QgsGeocoderContext &context, QgsFeedback *feedback=nullptr) const
 Geocodes a feature.
 

Additional Inherited Members

- Public Types inherited from QgsGeocoderInterface
enum class  Flag { GeocodesStrings = 1 << 0 , GeocodesFeatures = 1 << 1 }
 Capability flags for the geocoder. More...
 
typedef QFlags< FlagFlags
 

Detailed Description

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.
Since
QGIS 3.18

Definition at line 40 of file qgsgooglemapsgeocoder.h.

Constructor & Destructor Documentation

◆ QgsGoogleMapsGeocoder()

QgsGoogleMapsGeocoder::QgsGoogleMapsGeocoder ( const QString &  apiKey,
const QString &  regionBias = QString() 
)

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.

Definition at line 36 of file qgsgooglemapsgeocoder.cpp.

Member Function Documentation

◆ apiKey()

QString QgsGoogleMapsGeocoder::apiKey ( ) const

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

See also
setApiKey()

Definition at line 293 of file qgsgooglemapsgeocoder.cpp.

◆ appendedFields()

QgsFields QgsGoogleMapsGeocoder::appendedFields ( ) const
overridevirtual

Returns a set of newly created fields which will be appended to existing features during the geocode operation.

These fields will include any extra content returned by the geocoder, such as fields for accuracy of the match or correct attribute values.

Reimplemented from QgsGeocoderInterface.

Definition at line 50 of file qgsgooglemapsgeocoder.cpp.

◆ flags()

QgsGeocoderInterface::Flags QgsGoogleMapsGeocoder::flags ( ) const
overridevirtual

Returns the geocoder's capability flags.

Implements QgsGeocoderInterface.

Definition at line 45 of file qgsgooglemapsgeocoder.cpp.

◆ geocodeString()

QList< QgsGeocoderResult > QgsGoogleMapsGeocoder::geocodeString ( const QString &  string,
const QgsGeocoderContext context,
QgsFeedback feedback = nullptr 
) const
overridevirtual

Geocodes a string.

If implemented by the geocoder (i.e. flags() returns the QgsGeocoderInterface::Flag::GeocodesStrings flag), a list of matching results will be returned.

The optional feedback argument can be used to provider cancellation support.

Reimplemented from QgsGeocoderInterface.

Definition at line 73 of file qgsgooglemapsgeocoder.cpp.

◆ jsonToResult()

QgsGeocoderResult QgsGoogleMapsGeocoder::jsonToResult ( const QVariantMap &  json) const

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

Definition at line 224 of file qgsgooglemapsgeocoder.cpp.

◆ region()

QString QgsGoogleMapsGeocoder::region ( ) const

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

See also
setRegion()

Definition at line 303 of file qgsgooglemapsgeocoder.cpp.

◆ requestUrl()

QUrl QgsGoogleMapsGeocoder::requestUrl ( const QString &  address,
const QgsRectangle bounds = QgsRectangle() 
) const

Returns the URL generated for geocoding the specified address.

Definition at line 160 of file qgsgooglemapsgeocoder.cpp.

◆ setApiKey()

void QgsGoogleMapsGeocoder::setApiKey ( const QString &  key)

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

Definition at line 298 of file qgsgooglemapsgeocoder.cpp.

◆ setEndpoint()

void QgsGoogleMapsGeocoder::setEndpoint ( const QString &  endpoint)

Sets a specific API endpoint to use for requests.

This is for internal testing purposes only.

Definition at line 288 of file qgsgooglemapsgeocoder.cpp.

◆ setRegion()

void QgsGoogleMapsGeocoder::setRegion ( const QString &  region)

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

Definition at line 308 of file qgsgooglemapsgeocoder.cpp.

◆ wkbType()

Qgis::WkbType QgsGoogleMapsGeocoder::wkbType ( ) const
overridevirtual

Returns the WKB type of geometries returned by the geocoder.

If this is not known in advance then QgsWkbTypes::Unknown should be returned (e.g. in the case that a geocoder may return different geometry types depending on the quality of the match).

Reimplemented from QgsGeocoderInterface.

Definition at line 68 of file qgsgooglemapsgeocoder.cpp.


The documentation for this class was generated from the following files: