QGIS API Documentation 3.41.0-Master (cea29feecf2)
|
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. | |
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< QgsGeocoderResult > | geocodeString (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 ®ion) |
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< QgsGeocoderResult > | geocodeFeature (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< Flag > | Flags |
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 36 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 293 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 50 of file qgsgooglemapsgeocoder.cpp.
|
overridevirtual |
Returns the geocoder's capability flags.
Implements QgsGeocoderInterface.
Definition at line 45 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 73 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 224 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 303 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 160 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 298 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 288 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 308 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 68 of file qgsgooglemapsgeocoder.cpp.