[QGIS-Developer] using the QgsGoogleMapsGeocoder class

Johannes Kröger (WhereGroup) johannes.kroeger at wheregroup.com
Thu Aug 7 23:57:04 PDT 2025


Hi,

see 
https://qgis.org/pyqgis/master/core/QgsGeocoderContext.html#qgis.core.QgsGeocoderContext

You can use it to define an area of interest and to specify 
transformation settings.

I guess this should work:

geocoder_context = 
QgsGeocoderContext(QgsProject.instance().transformContext())
geocoder = QgsGoogleMapsGeocoder(apiKey="foo")
for geocoder_result in geocoder.geocodeString("bar", geocoder_context):
     print(geocoder_result)

Cheers, Hannes

On 8/7/25 17:05, Guillermo D'Angelo via QGIS-Developer wrote:
> Hi there!
> Does somebody have an example or snippet on how to use the 
> "QgsGoogleMapsGeocoder" class from PyQGIS?
>
> I want to geocode a string using the method "//geocodeString" but I 
> don't undestand what is the qgis.core.QgsGeocoderContext class and how 
> to use it.
>
> Thanks a lot.
>
> ------------------------------------------------------------------------
> 	Guillermo D'Angelo
> Encargado del Departamento de Geografía
> División de Trabajo de Campo
> Dirección Nacional Transferencias Monetarias y Análisis de Datos
> Av. 18 de julio 1453 | Piso 1
> Tel.: (+598) 2400 0302, int. 1262
> gdangelo at mides.gub.uy <mailto:>
> www.mides.gub.uy <http://www.mides.gub.uy>
>
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info:https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-developer

Johannes Kröger

GIS-Entwickler/-Berater




WhereGroup GmbH
Lange Reihe 29
20099 Hamburg
Germany

Tel: +49 (0)228 / 90 90 38 - 36

johannes.kroeger at wheregroup.com
www.wheregroup.com

Geschäftsführer:
Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRB 9885
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20250808/7643a922/attachment.htm>


More information about the QGIS-Developer mailing list