var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
function addControlGroup(controls) {
- controls.forEach(function (control) {
- control.addTo(map);
- });
+ for (const control of controls) control.addTo(map);
var firstContainer = controls[0].getContainer();
$(firstContainer).find(".control-button").first()
function updateBounds() {
group.clearLayers();
- changesets.forEach(function (changeset) {
+ for (const changeset of changesets) {
var bottomLeft = map.project(L.latLng(changeset.bbox.minlat, changeset.bbox.minlon)),
topRight = map.project(L.latLng(changeset.bbox.maxlat, changeset.bbox.maxlon)),
width = topRight.x - bottomLeft.x,
changeset.bounds = L.latLngBounds(map.unproject(bottomLeft),
map.unproject(topRight));
- });
+ }
changesets.sort(function (a, b) {
return b.bounds.getSize() - a.bounds.getSize();
});
- for (var i = 0; i < changesets.length; ++i) {
- var changeset = changesets[i],
- rect = L.rectangle(changeset.bounds,
- { weight: 2, color: "#FF9500", opacity: 1, fillColor: "#FFFFAF", fillOpacity: 0 });
+ for (const changeset of changesets) {
+ const rect = L.rectangle(changeset.bounds,
+ { weight: 2, color: "#FF9500", opacity: 1, fillColor: "#FFFFAF", fillOpacity: 0 });
rect.id = changeset.id;
rect.addTo(group);
}
function success(json) {
var oldNotes = notes;
notes = {};
- json.features.forEach(updateMarkers);
-
- function updateMarkers(feature) {
+ for (const feature of json.features) {
var marker = oldNotes[feature.properties.id];
delete oldNotes[feature.properties.id];
notes[feature.properties.id] = updateMarker(marker, feature);
var tags = feature.tags,
locales = OSM.preferred_languages;
- for (var i = 0; i < locales.length; i++) {
- if (tags["name:" + locales[i]]) {
- return tags["name:" + locales[i]];
+ for (const locale of locales) {
+ if (tags["name:" + locale]) {
+ return tags["name:" + locale];
}
}
elements = elements.sort(compare);
}
- for (var i = 0; i < elements.length; i++) {
- var element = elements[i];
-
- if (interestingFeature(element)) {
- var $li = $("<li>")
- .addClass("list-group-item list-group-item-action")
- .text(featurePrefix(element) + " ")
- .appendTo($ul);
-
- $("<a>")
- .addClass("stretched-link")
- .attr("href", "/" + element.type + "/" + element.id)
- .data("geometry", featureGeometry(element))
- .text(featureName(element))
- .appendTo($li);
- }
+ for (const element of elements) {
+ if (!interestingFeature(element)) continue;
+
+ var $li = $("<li>")
+ .addClass("list-group-item list-group-item-action")
+ .text(featurePrefix(element) + " ")
+ .appendTo($ul);
+
+ $("<a>")
+ .addClass("stretched-link")
+ .attr("href", "/" + element.type + "/" + element.id)
+ .data("geometry", featureGeometry(element))
+ .text(featureName(element))
+ .appendTo($li);
}
if (results.remark) {
});
input.on("click", function () {
- layers.forEach(function (other) {
+ for (const other of layers) {
if (other !== layer) {
map.removeLayer(other);
}
- });
+ }
map.addLayer(layer);
});
.attr("class", "form-check-input")
.bind("change", toggleFilter))));
- ["minlon", "minlat", "maxlon", "maxlat", "lat", "lon"].forEach(function (name) {
+ const mapnikNames = ["minlon", "minlat", "maxlon", "maxlat", "lat", "lon"];
+
+ for (const name of mapnikNames) {
$("<input>")
.attr("id", "mapnik_" + name)
.attr("name", name)
.attr("type", "hidden")
.appendTo($form);
- });
-
- $("<input>")
- .attr("id", "map_format")
- .attr("name", "format")
- .attr("value", "mapnik")
- .attr("type", "hidden")
- .appendTo($form);
-
- $("<input>")
- .attr("id", "map_zoom")
- .attr("name", "zoom")
- .attr("value", map.getZoom())
- .attr("type", "hidden")
- .appendTo($form);
+ }
- $("<input>")
- .attr("id", "map_width")
- .attr("name", "width")
- .attr("value", 0)
- .attr("type", "hidden")
- .appendTo($form);
+ const hiddenExportDefaults = {
+ format: "mapnik",
+ zoom: map.getZoom(),
+ width: 0,
+ height: 0
+ };
- $("<input>")
- .attr("id", "map_height")
- .attr("name", "height")
- .attr("value", 0)
- .attr("type", "hidden")
- .appendTo($form);
+ for (const name in hiddenExportDefaults) {
+ $("<input>")
+ .attr("id", "map_" + name)
+ .attr("name", name)
+ .attr("value", hiddenExportDefaults[name])
+ .attr("type", "hidden")
+ .appendTo($form);
+ }
var csrf_param = $("meta[name=csrf-param]").attr("content"),
csrf_token = $("meta[name=csrf-token]").attr("content");
return route;
}
- var routes = [];
- for (var r in rts) {
- routes.push(new Route(r, rts[r]));
- }
+ const routes = Object.entries(rts)
+ .map(([r, t]) => new Route(r, t));
routes.recognize = function (path) {
- for (var i = 0; i < this.length; i++) {
- if (this[i].match(path)) return this[i];
+ for (const route of this) {
+ if (route.match(path)) return route;
}
};