link.attr("target", "_blank");
}
return link.prop("outerHTML");
- } else {
- return text;
}
+ return text;
}
},
getShortUrl: function (marker) {
var zoom = this.getZoom(),
latLng = marker && this.hasLayer(marker) ? marker.getLatLng().wrap() : this.getCenter().wrap(),
- str = window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
- window.location.protocol + "//osm.org/go/" :
- window.location.protocol + "//" + window.location.hostname + "/go/",
+ str = window.location.protocol + "//" + window.location.hostname.replace(/^www\.openstreetmap\.org/i, "osm.org") + "/go/",
char_array = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_~",
x = Math.round((latLng.lng + 180.0) * ((1 << 30) / 90.0)),
y = Math.round((latLng.lat + 90.0) * ((1 << 30) / 45.0)),
// JavaScript only has to keep 32 bits of bitwise operators, so this has to be
// done in two parts. each of the parts c1/c2 has 30 bits of the total in it
// and drops the last 4 bits of the full 64 bit Morton code.
- c1 = interlace(x >>> 17, y >>> 17), c2 = interlace((x >>> 2) & 0x7fff, (y >>> 2) & 0x7fff),
+ c1 = interlace(x >>> 17, y >>> 17),
+ c2 = interlace((x >>> 2) & 0x7fff, (y >>> 2) & 0x7fff),
digit,
i;
this.removeObject();
if (object.type === "note" || object.type === "changeset") {
- this._objectLoader = {
- abort: function () {}
- };
+ this._objectLoader = { abort: () => {} };
this._object = object;
this._objectLayer = L.featureGroup().addTo(this);
this.fire("overlayadd", { layer: this._objectLayer });
} else { // element handled by L.OSM.DataLayer
var map = this;
- this._objectLoader = $.ajax({
- url: OSM.apiUrl(object),
- dataType: "json",
- success: function (data) {
+ this._objectLoader = new AbortController();
+ fetch(OSM.apiUrl(object), {
+ headers: { accept: "application/json" },
+ signal: this._objectLoader.signal
+ })
+ .then(response => response.json())
+ .then(function (data) {
map._object = object;
map._objectLayer = new L.OSM.DataLayer(null, {
});
map._objectLayer.interestingNode = function (node, wayNodes, relationNodes) {
- if (object.type === "node") {
- return true;
- } else if (object.type === "relation") {
- return Boolean(relationNodes[node.id]);
- } else {
- return false;
- }
+ return object.type === "node" ||
+ (object.type === "relation" && Boolean(relationNodes[node.id]));
};
map._objectLayer.addData(data);
if (callback) callback(map._objectLayer.getBounds());
map.fire("overlayadd", { layer: map._objectLayer });
- }
- });
+ })
+ .catch(() => {});
}
},