]> git.openstreetmap.org Git - rails.git/commitdiff
Group map controls
authorAnton Khorev <tony29@yandex.ru>
Mon, 19 Sep 2022 15:20:34 +0000 (18:20 +0300)
committerAnton Khorev <tony29@yandex.ru>
Mon, 19 Sep 2022 15:20:34 +0000 (18:20 +0300)
app/assets/javascripts/index.js
app/assets/stylesheets/common.scss

index 011f3b28258017b507a1f474942550980b69884e..2bda933a975e53f4171ee132b7a21cc854e30f50 100644 (file)
@@ -104,38 +104,50 @@ $(document).ready(function () {
 
   var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
 
-  L.OSM.zoom({ position: position })
-    .addTo(map);
+  function addControlGroup(controls) {
+    controls.forEach(function (control) {
+      control.addTo(map);
+    });
 
-  L.OSM.locate({ position: position })
-    .addTo(map);
+    var lastContainer = controls[controls.length -1].getContainer();
+    $(lastContainer).addClass("leaflet-control-group-end");
+  }
 
-  L.OSM.layers({
-    position: position,
-    layers: map.baseLayers,
-    sidebar: sidebar
-  }).addTo(map);
-
-  L.OSM.key({
-    position: position,
-    sidebar: sidebar
-  }).addTo(map);
-
-  L.OSM.share({
-    "position": position,
-    "sidebar": sidebar,
-    "short": true
-  }).addTo(map);
-
-  L.OSM.note({
-    position: position,
-    sidebar: sidebar
-  }).addTo(map);
-
-  L.OSM.query({
-    position: position,
-    sidebar: sidebar
-  }).addTo(map);
+  addControlGroup([
+    L.OSM.zoom({ position: position }),
+    L.OSM.locate({ position: position })
+  ]);
+
+  addControlGroup([
+    L.OSM.layers({
+      position: position,
+      layers: map.baseLayers,
+      sidebar: sidebar
+    }),
+    L.OSM.key({
+      position: position,
+      sidebar: sidebar
+    }),
+    L.OSM.share({
+      "position": position,
+      "sidebar": sidebar,
+      "short": true
+    })
+  ]);
+
+  addControlGroup([
+    L.OSM.note({
+      position: position,
+      sidebar: sidebar
+    })
+  ]);
+
+  addControlGroup([
+    L.OSM.query({
+      position: position,
+      sidebar: sidebar
+    })
+  ]);
 
   L.control.scale()
     .addTo(map);
index d2ab3d272746755d1ecf6d15660e07e7a734be53..1e638d47d5680888d3066574bf7ef3a2666554e2 100644 (file)
@@ -358,8 +358,6 @@ body.small-nav {
   width: 40px;
   background-color: #333;
   background-color: rgba(0,0,0,.6);
-  border-radius: 4px 0 0 4px;
-  margin-bottom: 10px;
   outline: none;
 
   &:hover,
@@ -383,21 +381,21 @@ body.small-nav {
   }
 }
 
-.leaflet-control .zoomin,
-.control-layers .control-button {
-  margin-bottom: 0px;
-  border-radius: 4px 0 0 0;
+.leaflet-control-group-end + .leaflet-control {
+  padding-top: 10px;
 }
 
-.leaflet-control .zoomout,
-.control-key .control-button {
-  margin-bottom: 0;
-  border-radius: 0;
+.leaflet-control:first-child,
+.leaflet-control-group-end + .leaflet-control {
+  &.control-button, .control-button:first-child {
+    border-start-start-radius: 4px;
+  }
 }
 
-.control-locate .control-button,
-.control-share .control-button {
-  border-radius: 0 0 0 4px;
+.leaflet-control-group-end {
+  &.control-button, .control-button:last-child {
+    border-end-start-radius: 4px;
+  }
 }
 
 /* Rules for the sidebar and main map area */