mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
This class implements the required logic to bridge a class which implements the QgsGeocoderInterface interface to a QgsLocatorFilter. It allows easy creation of a locator filter from a geocoder. E.g. class GoogleGeocoder(QgsGeocoderInterface): ... class which implements QgsGeocoderInterface... my_google_geocoder = GoogleGeocoder(api_key) my_google_locator_filter = QgsGeocoderLocatorFilter('google', 'Google Maps', 'google', my_google_geocoder, iface.mapCanvas()) iface.registerLocatorFilter(my_google_locator_filter) Note: There's an abstract base class QgsAbstractGeocoderLocatorFilter which lives in core. This base class has the guts of the geocoder to filter adapter logic, but it does NOT implement the part which actually zooms the canvas to the geocode results (because it's in core!) This abstract base class is in place for applications like QField, where the GUI library and QgsMapCanvas is NOT used. Those applications can then implement their own concrete class based on QgsAbstractGeocoderLocatorFilter with the correct logic to zoom their interface to a region. Ultimately, a single QgsGeocoderInterface could be usable across QGIS desktop, QField, with almost all logic shared via the common abstract adapter class.