+ if (this._object) {
+ params[this._object.type] = this._object.id;
+ }
+
+ var query = querystring.stringify(params);
+ if (query) {
+ str += '?' + query;
+ }
+
+ return str;
+ },
+
+ addObject: function(object, options) {
+ this._object = object;
+
+ if (this._objectLoader) this._objectLoader.abort();
+ if (this._objectLayer) this.removeLayer(this._objectLayer);
+
+ var map = this;
+ this._objectLoader = $.ajax({
+ url: OSM.apiUrl(object),
+ dataType: "xml",
+ success: function (xml) {
+ map._objectLayer = new L.OSM.DataLayer(null, {
+ styles: {
+ node: options.style,
+ way: options.style,
+ area: options.style
+ }
+ });
+
+ map._objectLayer.interestingNode = function (node, ways, relations) {
+ if (object.type === "node") {
+ return true;
+ } else if (object.type === "relation") {
+ for (var i = 0; i < relations.length; i++)
+ if (relations[i].members.indexOf(node) != -1)
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ map._objectLayer.addData(xml);
+
+ if (options.zoom) map.fitBounds(map._objectLayer.getBounds());
+ if (options.callback) options.callback(map._objectLayer.getBounds());
+
+ map._objectLayer.addTo(map);
+ }
+ });
+ },
+
+ removeObject: function() {
+ this._object = null;
+ if (this._objectLoader) this._objectLoader.abort();
+ if (this._objectLayer) this.removeLayer(this._objectLayer);