+
+ if (callback) callback(this._objectLayer.getBounds());
+ 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) {
+ 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) {
+ if (object.type === "node") {
+ return true;
+ } else if (object.type === "relation") {
+ return Boolean(relationNodes[node.id]);
+ } else {
+ return false;
+ }
+ };
+
+ map._objectLayer.addData(data);
+ map._objectLayer.addTo(map);
+
+ if (callback) callback(map._objectLayer.getBounds());
+ map.fire("overlayadd", { layer: map._objectLayer });
+ }
+ });
+ }