Update leaflet-control-geocoder (#296)
Switch BR.Search to ES6 class because L.Control.Geocoder is now an ES6 class and Leaflet L.Class.extend doesn't work anymore (undefined).
This commit is contained in:
parent
cd8ac29aab
commit
fbcfd8cf8e
3 changed files with 33 additions and 34 deletions
|
|
@ -1,29 +1,28 @@
|
||||||
BR.Search = L.Control.Geocoder.extend({
|
BR.Search = class extends L.Control.Geocoder {
|
||||||
options: {
|
constructor(options) {
|
||||||
geocoder: new L.Control.Geocoder.LatLng({
|
super(
|
||||||
next: new L.Control.Geocoder.Nominatim({
|
Object.assign(
|
||||||
serviceUrl: 'https://nominatim.openstreetmap.org/',
|
{
|
||||||
}),
|
geocoder: new L.Control.Geocoder.LatLng({
|
||||||
sizeInMeters: 800,
|
next: new L.Control.Geocoder.Nominatim({
|
||||||
}),
|
serviceUrl: 'https://nominatim.openstreetmap.org/',
|
||||||
position: 'topleft',
|
}),
|
||||||
shortcut: {
|
sizeInMeters: 800,
|
||||||
search: 70, // char code for 'f'
|
}),
|
||||||
},
|
position: 'topleft',
|
||||||
},
|
shortcut: {
|
||||||
|
search: 70, // char code for 'f'
|
||||||
initialize: function (options) {
|
},
|
||||||
L.Control.Geocoder.prototype.initialize.call(this, options);
|
placeholder: i18next.t('map.geocoder-placeholder'),
|
||||||
L.setOptions(this, {
|
},
|
||||||
// i18next.t will only return 'undefined' if it is called in a static context
|
options
|
||||||
// (e.g. when added directly to "options:" above), so we have to call it here
|
)
|
||||||
placeholder: i18next.t('map.geocoder-placeholder'),
|
);
|
||||||
});
|
|
||||||
|
|
||||||
L.DomEvent.addListener(document, 'keydown', this._keydownListener, this);
|
L.DomEvent.addListener(document, 'keydown', this._keydownListener, this);
|
||||||
},
|
}
|
||||||
|
|
||||||
markGeocode: function (result) {
|
markGeocode(result) {
|
||||||
this._map.fitBounds(result.geocode.bbox, {
|
this._map.fitBounds(result.geocode.bbox, {
|
||||||
maxZoom: 17,
|
maxZoom: 17,
|
||||||
});
|
});
|
||||||
|
|
@ -37,18 +36,18 @@ BR.Search = L.Control.Geocoder.extend({
|
||||||
}).addTo(this._map);
|
}).addTo(this._map);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
}
|
||||||
|
|
||||||
clear: function () {
|
clear() {
|
||||||
if (this._geocodeMarker) {
|
if (this._geocodeMarker) {
|
||||||
this._map.removeLayer(this._geocodeMarker);
|
this._map.removeLayer(this._geocodeMarker);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
_keydownListener: function (e) {
|
_keydownListener(e) {
|
||||||
if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.search) {
|
if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.search) {
|
||||||
$('#map .leaflet-control-geocoder')[0].dispatchEvent(new MouseEvent('mousedown'));
|
$('#map .leaflet-control-geocoder')[0].dispatchEvent(new MouseEvent('mousedown'));
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
};
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
"jquery-i18next": "^1.2.1",
|
"jquery-i18next": "^1.2.1",
|
||||||
"jstree": "^3.3.8",
|
"jstree": "^3.3.8",
|
||||||
"leaflet": "~1.6.0",
|
"leaflet": "~1.6.0",
|
||||||
"leaflet-control-geocoder": "^1.13.0",
|
"leaflet-control-geocoder": "^2.2.0",
|
||||||
"leaflet-easybutton": "*",
|
"leaflet-easybutton": "*",
|
||||||
"leaflet-editable": "^1.1.0",
|
"leaflet-editable": "^1.1.0",
|
||||||
"leaflet-filelayer": "^1.2.0",
|
"leaflet-filelayer": "^1.2.0",
|
||||||
|
|
|
||||||
|
|
@ -6554,10 +6554,10 @@ lead@^1.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
flush-write-stream "^1.0.2"
|
flush-write-stream "^1.0.2"
|
||||||
|
|
||||||
leaflet-control-geocoder@^1.13.0:
|
leaflet-control-geocoder@^2.2.0:
|
||||||
version "1.13.0"
|
version "2.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/leaflet-control-geocoder/-/leaflet-control-geocoder-1.13.0.tgz#c84cffd8f64a8f0b1091a59c3b59c03d5dcc583e"
|
resolved "https://registry.yarnpkg.com/leaflet-control-geocoder/-/leaflet-control-geocoder-2.2.0.tgz#c2ebf1913acae683d995769f8652f61b0508122f"
|
||||||
integrity sha512-mgYGx/2WA5CcvhP+IJtw7VvJwSGAe5zxX+TKe6ruYkLj2W5I5V/K/nQiLvsUtqifBojBGoKIPNZ8m0mXJNIudg==
|
integrity sha512-OSnKVIeSZQUXGsErunUBhLbXf2YPRBADaStKipkD3/yrtsZAhLiyFoNHmhjP1nAqD6KO63A98xGfVs4EroFvFA==
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
open-location-code "^1.0.0"
|
open-location-code "^1.0.0"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue