]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.map.js
Add history changesets layer module
[rails.git] / app / assets / javascripts / leaflet.map.js
index abeb4d3e426d896526b914f665e5a04e506ec6a4..2ea3352ab93b59e897ca63f04fcd384dd7b392ae 100644 (file)
@@ -16,8 +16,6 @@ L.OSM.Map = L.Map.extend({
     this.baseLayers = [];
 
     for (const layerDefinition of OSM.LAYER_DEFINITIONS) {
-      if (layerDefinition.apiKeyId && !OSM[layerDefinition.apiKeyId]) continue;
-
       let layerConstructor = L.OSM.TileLayer;
       const layerOptions = {};
 
@@ -25,9 +23,7 @@ L.OSM.Map = L.Map.extend({
         if (property === "credit") {
           layerOptions.attribution = makeAttribution(value);
         } else if (property === "nameId") {
-          layerOptions.name = I18n.t(`javascripts.map.base.${value}`);
-        } else if (property === "apiKeyId") {
-          layerOptions.apikey = OSM[value];
+          layerOptions.name = OSM.i18n.t(`javascripts.map.base.${value}`);
         } else if (property === "leafletOsmId") {
           layerConstructor = L.OSM[value];
         } else if (property === "leafletOsmDarkId" && OSM.isDarkMap() && L.OSM[value]) {
@@ -47,7 +43,7 @@ L.OSM.Map = L.Map.extend({
     this.noteLayer = new L.FeatureGroup();
     this.noteLayer.options = { code: "N" };
 
-    this.dataLayer = new L.OSM.DataLayer(null, { asynchronous: true });
+    this.dataLayer = new L.OSM.DataLayer(null);
     this.dataLayer.options.code = "D";
 
     this.gpsLayer = new L.OSM.GPS({
@@ -70,10 +66,10 @@ L.OSM.Map = L.Map.extend({
     function makeAttribution(credit) {
       let attribution = "";
 
-      attribution += I18n.t("javascripts.map.copyright_text", {
+      attribution += OSM.i18n.t("javascripts.map.copyright_text", {
         copyright_link: $("<a>", {
           href: "/copyright",
-          text: I18n.t("javascripts.map.openstreetmap_contributors")
+          text: OSM.i18n.t("javascripts.map.openstreetmap_contributors")
         }).prop("outerHTML")
       });
 
@@ -83,7 +79,7 @@ L.OSM.Map = L.Map.extend({
 
       attribution += $("<a>", {
         href: "https://wiki.osmfoundation.org/wiki/Terms_of_Use",
-        text: I18n.t("javascripts.map.website_and_api_terms")
+        text: OSM.i18n.t("javascripts.map.website_and_api_terms")
       }).prop("outerHTML");
 
       return attribution;
@@ -94,7 +90,7 @@ L.OSM.Map = L.Map.extend({
       for (const childId in credit.children) {
         children[childId] = makeCredit(credit.children[childId]);
       }
-      const text = I18n.t(`javascripts.map.${credit.id}`, children);
+      const text = OSM.i18n.t(`javascripts.map.${credit.id}`, children);
       if (credit.href) {
         const link = $("<a>", {
           href: credit.href,
@@ -306,8 +302,7 @@ L.OSM.Map = L.Map.extend({
               way: objectStyle,
               area: objectStyle,
               changeset: changesetStyle
-            },
-            asynchronous: true
+            }
           });
 
           map._objectLayer.interestingNode = function (node, wayNodes, relationNodes) {
@@ -396,13 +391,17 @@ OSM.isDarkMap = function () {
   return window.matchMedia("(prefers-color-scheme: dark)").matches;
 };
 
-OSM.getUserIcon = function (url) {
-  return L.icon({
-    iconUrl: url || OSM.MARKER_RED,
-    iconSize: [25, 41],
-    iconAnchor: [12, 41],
-    popupAnchor: [1, -34],
-    shadowUrl: OSM.MARKER_SHADOW,
-    shadowSize: [41, 41]
-  });
+OSM.getMarker = function ({ icon = "MARKER_RED", shadow = true, height = 41 }) {
+  const options = {
+    iconUrl: OSM[icon.toUpperCase()] || OSM.MARKER_RED,
+    iconSize: [25, height],
+    iconAnchor: [12, height],
+    popupAnchor: [1, -34]
+  };
+  if (shadow) {
+    options.shadowUrl = OSM.MARKER_SHADOW;
+    options.shadowSize = [41, 41];
+    options.shadowAnchor = [12, 41];
+  }
+  return L.icon(options);
 };