}
}
- if (tags.name) {
- return tags.name;
- } else if (tags.ref) {
- return tags.ref;
- } else if (tags["addr:housename"]) {
- return tags["addr:housename"];
- } else if (tags["addr:housenumber"] && tags["addr:street"]) {
+ for (const key of ["name", "ref", "addr:housename"]) {
+ if (tags[key]) {
+ return tags[key];
+ }
+ }
+
+ if (tags["addr:housenumber"] && tags["addr:street"]) {
return tags["addr:housenumber"] + " " + tags["addr:street"];
- } else {
- return "#" + feature.id;
}
+ return "#" + feature.id;
}
function featureGeometry(feature) {
$section.data("ajax").abort();
}
- $section.data("ajax", $.ajax({
- url: url,
+ $section.data("ajax", new AbortController());
+ fetch(url, {
method: "POST",
- data: {
+ body: new URLSearchParams({
data: "[timeout:10][out:json];" + query
- },
- xhrFields: {
- withCredentials: credentials
- },
- success: function (results) {
+ }),
+ credentials: credentials ? "include" : "same-origin",
+ signal: $section.data("ajax").signal
+ })
+ .then(response => response.json())
+ .then(function (results) {
var elements;
$section.find(".loader").hide();
.text(I18n.t("javascripts.query.nothing_found"))
.appendTo($ul);
}
- },
- error: function (xhr, status, error) {
+ })
+ .catch(function (error) {
+ if (error.name === "AbortError") return;
+
$section.find(".loader").hide();
$("<li>")
.addClass("list-group-item")
- .text(I18n.t("javascripts.query." + status, { server: url, error: error }))
+ .text(I18n.t("javascripts.query.error", { server: url, error: error.message }))
.appendTo($ul);
- }
- }));
+ });
}
function compareSize(feature1, feature2) {
.hide();
if (marker) map.removeLayer(marker);
- marker = L.circle(latlng, Object.assign({
+ marker = L.circle(latlng, {
radius: radius,
- className: "query-marker"
- }, featureStyle)).addTo(map);
+ className: "query-marker",
+ ...featureStyle
+ }).addTo(map);
runQuery(latlng, radius, nearby, $("#query-nearby"), false);
runQuery(latlng, radius, isin, $("#query-isin"), true, compareSize);