QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
A geocoder which uses the Google Map geocoding API to retrieve results. More...
#include <qgsgooglemapsgeocoder.h>
Public Member Functions | |
QgsGoogleMapsGeocoder (const QString &apiKey, const QString ®ionBias=QString()) | |
Constructor for QgsGoogleMapsGeocoder. More... | |
QString | apiKey () const |
Returns the API key which will be used when accessing the Google Maps API. More... | |
QgsFields | appendedFields () const override |
Returns a set of newly created fields which will be appended to existing features during the geocode operation. More... | |
Flags | flags () const override |
Returns the geocoder's capability flags. More... | |
QList< QgsGeocoderResult > | geocodeString (const QString &string, const QgsGeocoderContext &context, QgsFeedback *feedback=nullptr) const override |
Geocodes a string. More... | |
QgsGeocoderResult | jsonToResult (const QVariantMap &json) const |
Converts a JSON result returned from the Google Maps service to a geocoder result object. More... | |
QString | region () const |
Returns the optional region bias which will be used to prioritize results in a certain region. More... | |
QUrl | requestUrl (const QString &address, const QgsRectangle &bounds=QgsRectangle()) const |
Returns the URL generated for geocoding the specified address. More... | |
void | setApiKey (const QString &key) |
Sets the API key to use when accessing the Google Maps API. More... | |
void | setEndpoint (const QString &endpoint) |
Sets a specific API endpoint to use for requests. More... | |
void | setRegion (const QString ®ion) |
Sets the optional region bias which will be used to prioritize results in a certain region. More... | |
QgsWkbTypes::Type | wkbType () const override |
Returns the WKB type of geometries returned by the geocoder. More... | |
Public Member Functions inherited from QgsGeocoderInterface | |
virtual | ~QgsGeocoderInterface ()=default |
virtual QList< QgsGeocoderResult > | geocodeFeature (const QgsFeature &feature, const QgsGeocoderContext &context, QgsFeedback *feedback=nullptr) const |
Geocodes a feature. More... | |
Additional Inherited Members | |
Public Types inherited from QgsGeocoderInterface | |
enum class | Flag { GeocodesStrings = 1 << 0 , GeocodesFeatures = 1 << 1 } |
Capability flags for the geocoder. More... | |
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.
Definition at line 40 of file qgsgooglemapsgeocoder.h.
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 34 of file qgsgooglemapsgeocoder.cpp.
QString QgsGoogleMapsGeocoder::apiKey | ( | ) | const |
Returns the API key which will be used when accessing the Google Maps API.
Definition at line 291 of file qgsgooglemapsgeocoder.cpp.
|
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 48 of file qgsgooglemapsgeocoder.cpp.
|
overridevirtual |
Returns the geocoder's capability flags.
Implements QgsGeocoderInterface.
Definition at line 43 of file qgsgooglemapsgeocoder.cpp.
|
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 71 of file qgsgooglemapsgeocoder.cpp.
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 222 of file qgsgooglemapsgeocoder.cpp.
QString QgsGoogleMapsGeocoder::region | ( | ) | const |
Returns the optional region bias which will be used to prioritize results in a certain region.
Definition at line 301 of file qgsgooglemapsgeocoder.cpp.
QUrl QgsGoogleMapsGeocoder::requestUrl | ( | const QString & | address, |
const QgsRectangle & | bounds = QgsRectangle() |
||
) | const |
Returns the URL generated for geocoding the specified address.
Definition at line 158 of file qgsgooglemapsgeocoder.cpp.
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!
Definition at line 296 of file qgsgooglemapsgeocoder.cpp.
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 286 of file qgsgooglemapsgeocoder.cpp.
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.
Definition at line 306 of file qgsgooglemapsgeocoder.cpp.
|
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 66 of file qgsgooglemapsgeocoder.cpp.