Merge pull request #1690 from umap-project/photon-location-bias

fix: only use location bias in search for close zoom
This commit is contained in:
Yohan Boniface 2024-03-14 14:53:30 +01:00 committed by GitHub
commit 093eb6b56b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -58,7 +58,7 @@
"leaflet.locatecontrol": "^0.79.0", "leaflet.locatecontrol": "^0.79.0",
"leaflet.markercluster": "^1.5.3", "leaflet.markercluster": "^1.5.3",
"leaflet.path.drag": "0.0.6", "leaflet.path.drag": "0.0.6",
"leaflet.photon": "0.9.0", "leaflet.photon": "0.9.1",
"osmtogeojson": "^3.0.0-beta.3", "osmtogeojson": "^3.0.0-beta.3",
"simple-statistics": "^7.8.3", "simple-statistics": "^7.8.3",
"togpx": "^0.5.4", "togpx": "^0.5.4",

View file

@ -1237,6 +1237,7 @@ U.StarControl = L.Control.extend({
U.Search = L.PhotonSearch.extend({ U.Search = L.PhotonSearch.extend({
initialize: function (map, input, options) { initialize: function (map, input, options) {
this.options.placeholder = L._('Type a place name or coordinates') this.options.placeholder = L._('Type a place name or coordinates')
this.options.location_bias_scale = 0.5
L.PhotonSearch.prototype.initialize.call(this, map, input, options) L.PhotonSearch.prototype.initialize.call(this, map, input, options)
this.options.url = map.options.urls.search this.options.url = map.options.urls.search
if (map.options.maxBounds) this.options.bbox = map.options.maxBounds.toBBoxString() if (map.options.maxBounds) this.options.bbox = map.options.maxBounds.toBBoxString()
@ -1276,6 +1277,7 @@ U.Search = L.PhotonSearch.extend({
// Only numbers, abort. // Only numbers, abort.
if (/^[\d .,]*$/.test(this.input.value)) return if (/^[\d .,]*$/.test(this.input.value)) return
// Do normal search // Do normal search
this.options.includePosition = this.map.getZoom() > 10
L.PhotonSearch.prototype.search.call(this) L.PhotonSearch.prototype.search.call(this)
}, },