]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/user.js
Add history changesets layer module
[rails.git] / app / assets / javascripts / user.js
index 9d225a85979c1266c699c76ffe17a303cc503fe3..5f8a931e3956132583e8a9f52734b9621b698a70 100644 (file)
@@ -1,4 +1,4 @@
-//= require leaflet.locatecontrol/dist/L.Control.Locate.umd
+//= require leaflet.locate
 
 (function () {
   $(document).on("change", "#user_all", function () {
@@ -6,7 +6,7 @@
   });
 }());
 
-$(document).ready(function () {
+$(function () {
   const defaultHomeZoom = 12;
   let map, marker, deleted_lat, deleted_lon;
 
@@ -18,30 +18,9 @@ $(document).ready(function () {
 
     const position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
 
-    L.OSM.zoom({ position: position })
-      .addTo(map);
-
-    const locate = L.control.locate({
-      position: position,
-      icon: "icon geolocate",
-      iconLoading: "icon geolocate",
-      strings: {
-        title: I18n.t("javascripts.map.locate.title"),
-        popup: function (options) {
-          return I18n.t("javascripts.map.locate." + options.unit + "Popup", { count: options.distance });
-        }
-      }
-    }).addTo(map);
-
-    const locateContainer = locate.getContainer();
+    L.OSM.zoom({ position }).addTo(map);
 
-    $(locateContainer)
-      .removeClass("leaflet-control-locate leaflet-bar")
-      .addClass("control-locate")
-      .children("a")
-      .attr("href", "#")
-      .removeClass("leaflet-bar-part leaflet-bar-part-single")
-      .addClass("control-button");
+    L.OSM.locate({ position }).addTo(map);
 
     if (OSM.home) {
       map.setView([OSM.home.lat, OSM.home.lon], defaultHomeZoom);
@@ -51,7 +30,7 @@ $(document).ready(function () {
 
     if ($("#map").hasClass("set_location")) {
       marker = L.marker([0, 0], {
-        icon: OSM.getUserIcon(),
+        icon: OSM.getMarker({}),
         keyboard: false,
         interactive: false
       });
@@ -124,7 +103,7 @@ $(document).ready(function () {
       $("[data-user]").each(function () {
         const user = $(this).data("user");
         if (user.lon && user.lat) {
-          L.marker([user.lat, user.lon], { icon: OSM.getUserIcon(user.icon) }).addTo(map)
+          L.marker([user.lat, user.lon], { icon: OSM.getMarker({ icon: user.icon }) }).addTo(map)
             .bindPopup(user.description, { minWidth: 200 });
         }
       });
@@ -210,7 +189,7 @@ $(document).ready(function () {
   });
 
   $("input[name=legale]").change(function () {
-    $("#contributorTerms").html("<div class='spinner-border' role='status'><span class='visually-hidden'>" + I18n.t("browse.start_rjs.loading") + "</span></div>");
+    $("#contributorTerms").html("<div class='spinner-border' role='status'><span class='visually-hidden'>" + OSM.i18n.t("browse.start_rjs.loading") + "</span></div>");
     fetch($(this).data("url"))
       .then(r => r.text())
       .then(html => { $("#contributorTerms").html(html); });