[gnome-maps] placeEntry: Only use location bias on high zoom



commit 93046509c3937675c29fe3c7b32ea21bb041bd2f
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Jan 25 22:10:48 2022 +0100

    placeEntry: Only use location bias on high zoom
    
    As a stop-gap solution for the location bias
    issue in the Photon search engine
    (https://github.com/komoot/photon/issues/600),
    for now limit the use of location bias to zoom
    level above 17.
    
    Ref #172

 src/placeEntry.js | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/placeEntry.js b/src/placeEntry.js
index c39823cd..5167fd3f 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -118,6 +118,8 @@ var PlaceEntry = GObject.registerClass({
 
         // clear cache when view moves, as result are location-dependent
         this._mapView.view.connect('notify::latitude', () => this._cache = {});
+        // clear cache when zoom level changes, to allow limiting location bias
+        this._mapView.view.connect('notify::zoom-level', () => this._cache =  {});
     }
 
     _onSearchChanged() {
@@ -282,9 +284,18 @@ var PlaceEntry = GObject.registerClass({
             this._cancellable.cancel();
         this._cancellable = new Gio.Cancellable();
         this._previousSearch = this.text;
-        GeocodeFactory.getGeocoder().search(this.text,
-                                            this._mapView.view.latitude,
-                                            this._mapView.view.longitude,
+
+        /* as a stop-gap solution for the location bias tuning issues
+         * in Photon (https://github.com/komoot/photon/issues/600),
+         * for now search "globally" (e.g. without location bias) for
+         * zoom levels above 17, to still allow focused search nearby
+         */
+        let lat = this._mapView.view.zoom_level > 17 ?
+                  this._mapView.view.latitude : null;
+        let lon = this._mapView.view.zoom_level > 17 ?
+                  this._mapView.view.longitude : null;
+
+        GeocodeFactory.getGeocoder().search(this.text, lat, lon,
                                             this._cancellable,
                                             (places, error) => {
             this._cancellable = null;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]