3 L.OSM.TileLayer = L.TileLayer.extend({
 
   5     url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
 
   6     attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors'
 
   9   initialize: function (options) {
 
  10     options = L.Util.setOptions(this, options);
 
  11     L.TileLayer.prototype.initialize.call(this, options.url);
 
  15 L.OSM.Mapnik = L.OSM.TileLayer.extend({
 
  17     url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
 
  22 L.OSM.CyclOSM = L.OSM.TileLayer.extend({
 
  24     url: 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png',
 
  27     attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors. Tiles courtesy of <a href="https://www.openstreetmap.fr" target="_blank">OpenStreetMap France</a>'
 
  31 L.OSM.CycleMap = L.OSM.TileLayer.extend({
 
  33     url: 'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}{r}.png?apikey={apikey}',
 
  35     attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors. Tiles courtesy of <a href="http://www.thunderforest.com/" target="_blank">Andy Allan</a>'
 
  39 L.OSM.TransportMap = L.OSM.TileLayer.extend({
 
  41     url: 'https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}{r}.png?apikey={apikey}',
 
  43     attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors. Tiles courtesy of <a href="http://www.thunderforest.com/" target="_blank">Andy Allan</a>'
 
  47 L.OSM.OPNVKarte = L.OSM.TileLayer.extend({
 
  49     url: 'https://tileserver.memomaps.de/tilegen/{z}/{x}/{y}.png',
 
  51     attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors. Tiles courtesy of <a href="http://memomaps.de/" target="_blank">MeMoMaps</a>'
 
  55 L.OSM.HOT = L.OSM.TileLayer.extend({
 
  57     url: 'https://tile-{s}.openstreetmap.fr/hot/{z}/{x}/{y}.png',
 
  60     attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors. Tiles courtesy of <a href="http://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>'
 
  64 L.OSM.GPS = L.OSM.TileLayer.extend({
 
  66     url: 'https://gps.tile.openstreetmap.org/lines/{z}/{x}/{y}.png',
 
  73 L.OSM.DataLayer = L.FeatureGroup.extend({
 
  75     areaTags: ['area', 'building', 'leisure', 'tourism', 'ruins', 'historic', 'landuse', 'military', 'natural', 'sport'],
 
  76     uninterestingTags: ['source', 'source_ref', 'source:ref', 'history', 'attribution', 'created_by', 'tiger:county', 'tiger:tlid', 'tiger:upload_uuid'],
 
  80   initialize: function (xml, options) {
 
  81     L.Util.setOptions(this, options);
 
  83     L.FeatureGroup.prototype.initialize.call(this);
 
  90   addData: function (features) {
 
  91     if (!(features instanceof Array)) {
 
  92       features = this.buildFeatures(features);
 
  95     for (var i = 0; i < features.length; i++) {
 
  96       var feature = features[i], layer;
 
  98       if (feature.type === "changeset") {
 
  99         layer = L.rectangle(feature.latLngBounds, this.options.styles.changeset);
 
 100       } else if (feature.type === "node") {
 
 101         layer = L.circleMarker(feature.latLng, this.options.styles.node);
 
 103         var latLngs = new Array(feature.nodes.length);
 
 105         for (var j = 0; j < feature.nodes.length; j++) {
 
 106           latLngs[j] = feature.nodes[j].latLng;
 
 109         if (this.isWayArea(feature)) {
 
 110           latLngs.pop(); // Remove last == first.
 
 111           layer = L.polygon(latLngs, this.options.styles.area);
 
 113           layer = L.polyline(latLngs, this.options.styles.way);
 
 118       layer.feature = feature;
 
 122   buildFeatures: function (xml) {
 
 123     var features = L.OSM.getChangesets(xml),
 
 124       nodes = L.OSM.getNodes(xml),
 
 125       ways = L.OSM.getWays(xml, nodes),
 
 126       relations = L.OSM.getRelations(xml, nodes, ways);
 
 128     for (var node_id in nodes) {
 
 129       var node = nodes[node_id];
 
 130       if (this.interestingNode(node, ways, relations)) {
 
 135     for (var i = 0; i < ways.length; i++) {
 
 143   isWayArea: function (way) {
 
 144     if (way.nodes[0] != way.nodes[way.nodes.length - 1]) {
 
 148     for (var key in way.tags) {
 
 149       if (~this.options.areaTags.indexOf(key)) {
 
 157   interestingNode: function (node, ways, relations) {
 
 160     for (var i = 0; i < ways.length; i++) {
 
 161       if (ways[i].nodes.indexOf(node) >= 0) {
 
 171     for (var i = 0; i < relations.length; i++) {
 
 172       if (relations[i].members.indexOf(node) >= 0)
 
 176     for (var key in node.tags) {
 
 177       if (this.options.uninterestingTags.indexOf(key) < 0) {
 
 186 L.Util.extend(L.OSM, {
 
 187   getChangesets: function (xml) {
 
 190     var nodes = xml.getElementsByTagName("changeset");
 
 191     for (var i = 0; i < nodes.length; i++) {
 
 192       var node = nodes[i], id = node.getAttribute("id");
 
 196         latLngBounds: L.latLngBounds(
 
 197           [node.getAttribute("min_lat"), node.getAttribute("min_lon")],
 
 198           [node.getAttribute("max_lat"), node.getAttribute("max_lon")]),
 
 199         tags: this.getTags(node)
 
 206   getNodes: function (xml) {
 
 209     var nodes = xml.getElementsByTagName("node");
 
 210     for (var i = 0; i < nodes.length; i++) {
 
 211       var node = nodes[i], id = node.getAttribute("id");
 
 215         latLng: L.latLng(node.getAttribute("lat"),
 
 216                          node.getAttribute("lon"),
 
 218         tags: this.getTags(node)
 
 225   getWays: function (xml, nodes) {
 
 228     var ways = xml.getElementsByTagName("way");
 
 229     for (var i = 0; i < ways.length; i++) {
 
 230       var way = ways[i], nds = way.getElementsByTagName("nd");
 
 233         id: way.getAttribute("id"),
 
 235         nodes: new Array(nds.length),
 
 236         tags: this.getTags(way)
 
 239       for (var j = 0; j < nds.length; j++) {
 
 240         way_object.nodes[j] = nodes[nds[j].getAttribute("ref")];
 
 243       result.push(way_object);
 
 249   getRelations: function (xml, nodes, ways) {
 
 252     var rels = xml.getElementsByTagName("relation");
 
 253     for (var i = 0; i < rels.length; i++) {
 
 254       var rel = rels[i], members = rel.getElementsByTagName("member");
 
 257         id: rel.getAttribute("id"),
 
 259         members: new Array(members.length),
 
 260         tags: this.getTags(rel)
 
 263       for (var j = 0; j < members.length; j++) {
 
 264         if (members[j].getAttribute("type") === "node")
 
 265           rel_object.members[j] = nodes[members[j].getAttribute("ref")];
 
 266         else // relation-way and relation-relation membership not implemented
 
 267           rel_object.members[j] = null;
 
 270       result.push(rel_object);
 
 276   getTags: function (xml) {
 
 279     var tags = xml.getElementsByTagName("tag");
 
 280     for (var j = 0; j < tags.length; j++) {
 
 281       result[tags[j].getAttribute("k")] = tags[j].getAttribute("v");