Skip to content

Commit

Permalink
placeEntry: Only use location bias on high zoom
Browse files Browse the repository at this point in the history
As a stop-gap solution for the location bias
issue in the Photon search engine
(komoot/photon#600),
for now limit the use of location bias to zoom
level above 17.

Ref #172
  • Loading branch information
Marcus Lundblad committed Jan 25, 2022
1 parent 3b7e2b4 commit 9304650
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/placeEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9304650

Please sign in to comment.