+ for (i = 0; i < ((zoom + 8) % 3); ++i) str += "-";
+
+ // Called to interlace the bits in x and y, making a Morton code.
+ function interlace(x, y) {
+ x = (x | (x << 8)) & 0x00ff00ff;
+ x = (x | (x << 4)) & 0x0f0f0f0f;
+ x = (x | (x << 2)) & 0x33333333;
+ x = (x | (x << 1)) & 0x55555555;
+ y = (y | (y << 8)) & 0x00ff00ff;
+ y = (y | (y << 4)) & 0x0f0f0f0f;
+ y = (y | (y << 2)) & 0x33333333;
+ y = (y | (y << 1)) & 0x55555555;
+ return (x << 1) | y;
+ }
+
+ var params = {};
+
+ if (marker && this.hasLayer(marker)) {
+ params.m = '';
+ }
+
+ 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,
+ changeset: {
+ weight: 2,
+ color: '#e90',
+ fillOpacity: 0
+ }
+ }
+ });
+
+ 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);
+
+ var bounds = map._objectLayer.getBounds();
+
+ if (options.zoom && bounds.isValid()) map.fitBounds(bounds);
+ if (options.callback) options.callback(bounds);
+
+ map._objectLayer.addTo(map);
+ }
+ });
+ },
+
+ removeObject: function() {
+ this._object = null;
+ if (this._objectLoader) this._objectLoader.abort();
+ if (this._objectLayer) this.removeLayer(this._objectLayer);
+ }
+});
+
+L.Icon.Default.imagePath = "/images";
+
+L.Icon.Default.imageUrls = {
+ "/images/marker-icon.png": "<%= asset_path("images/marker-icon.png") %>",
+ "/images/marker-icon-2x.png": "<%= asset_path("images/marker-icon-2x.png") %>",
+ "/images/marker-shadow.png": "<%= asset_path("images/marker-shadow.png") %>",
+ "/images/marker-shadow-2x.png": "<%= asset_path("images/marker-shadow-2x.png") %>"
+};
+
+L.extend(L.Icon.Default.prototype, {
+ _oldGetIconUrl: L.Icon.Default.prototype._getIconUrl,
+
+ _getIconUrl: function (name) {
+ var url = this._oldGetIconUrl(name);
+ return L.Icon.Default.imageUrls[url];
+ }