+
+ if (callback) callback(this._objectLayer.getBounds());
+ this.fire("overlayadd", { layer: this._objectLayer });
+ } else { // element handled by L.OSM.DataLayer
+ var map = this;
+ 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, {
+ styles: {
+ node: objectStyle,
+ way: objectStyle,
+ area: objectStyle,
+ changeset: changesetStyle
+ }
+ });
+
+ map._objectLayer.interestingNode = function (node, wayNodes, relationNodes) {
+ return object.type === "node" ||
+ (object.type === "relation" && Boolean(relationNodes[node.id]));
+ };
+
+ map._objectLayer.addData(data);
+ map._objectLayer.addTo(map);
+
+ if (callback) callback(map._objectLayer.getBounds());
+ map.fire("overlayadd", { layer: map._objectLayer });
+ })
+ .catch(() => {});
+ }