]> git.openstreetmap.org Git - rails.git/blob - app/assets/javascripts/leaflet.locate.js
Localisation updates from https://translatewiki.net.
[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     strings: {
6       title: OSM.i18n.t("javascripts.map.locate.title"),
7       popup: function (options) {
8         return OSM.i18n.t("javascripts.map.locate." + options.unit + "Popup", { count: options.distance });
9       }
10     },
11     ...options
12   });
13
14   control.onAdd = function (map) {
15     const container = Object.getPrototypeOf(this).onAdd.apply(this, [map]);
16     $(container)
17       .removeClass("leaflet-control-locate leaflet-bar")
18       .addClass("control-locate")
19       .children("a")
20       .attr("href", "#")
21       .removeClass("leaflet-bar-part leaflet-bar-part-single")
22       .addClass("control-button")
23       .empty()
24       .append(
25         $(L.SVG.create("svg"))
26           .attr("class", "h-100 w-100")
27           .append(
28             $(L.SVG.create("use"))
29               .attr("href", "#icon-geolocate")));
30     return container;
31   };
32
33   return control;
34 };