//= require leaflet.sidebar
//= require leaflet.sidebar-pane
//= require leaflet.locatecontrol/src/L.Control.Locate
+//= require leaflet.locate
//= require leaflet.layers
//= require leaflet.key
//= require leaflet.note
}
});
- var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
-
- L.OSM.zoom({ position: position })
+ var sidebar = L.OSM.sidebar("#map-ui")
.addTo(map);
- var 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);
+ var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
- var locateContainer = locate.getContainer();
+ function addControlGroup(controls) {
+ controls.forEach(function (control) {
+ control.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");
+ var firstContainer = controls[0].getContainer();
+ $(firstContainer).find(".control-button").first()
+ .addClass("control-button-first");
- var sidebar = L.OSM.sidebar("#map-ui")
- .addTo(map);
+ var lastContainer = controls[controls.length - 1].getContainer();
+ $(lastContainer).find(".control-button").last()
+ .addClass("control-button-last");
+ }
- 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);
}
}
- var placement = $("html").attr("dir") === "rtl" ? "right" : "left";
- $(".leaflet-control .control-button").tooltip({ placement: placement, container: "body" });
+ $(".leaflet-control .control-button").tooltip({ placement: "left", container: "body" });
var expiry = new Date();
expiry.setYear(expiry.getFullYear() + 10);
});
if (Cookies.get("_osm_welcome") !== "hide") {
- $(".welcome").addClass("visible");
+ $(".welcome").removeAttr("hidden");
}
$(".welcome .btn-close").on("click", function () {
- $(".welcome").removeClass("visible");
+ $(".welcome").hide();
Cookies.set("_osm_welcome", "hide", { secure: true, expires: expiry, path: "/", samesite: "lax" });
});
e.preventDefault();
}
});
+
+ $(document).on("click", "#sidebar_content .btn-close", function () {
+ OSM.router.route("/" + OSM.formatHash(map));
+ });
});