]> git.openstreetmap.org Git - rails.git/blob - app/assets/javascripts/leaflet.locate.js
Merge remote-tracking branch 'upstream/pull/5923'
[rails.git] / app / assets / javascripts / leaflet.locate.js
1 //= require leaflet.locatecontrol/dist/L.Control.Locate.umd
2
3 L.OSM.locate = function (options) {
4   const control = L.control.locate({
5     icon: "icon geolocate",
6     iconLoading: "icon geolocate",
7     strings: {
8       title: OSM.i18n.t("javascripts.map.locate.title"),
9       popup: function (options) {
10         return OSM.i18n.t("javascripts.map.locate." + options.unit + "Popup", { count: options.distance });
11       }
12     },
13     ...options
14   });
15
16   control.onAdd = function (map) {
17     const container = Object.getPrototypeOf(this).onAdd.apply(this, [map]);
18     $(container)
19       .removeClass("leaflet-control-locate leaflet-bar")
20       .addClass("control-locate")
21       .children("a")
22       .attr("href", "#")
23       .removeClass("leaflet-bar-part leaflet-bar-part-single")
24       .addClass("control-button");
25     return container;
26   };
27
28   return control;
29 };