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.TracestrackTopo = L.OSM.TileLayer.extend({
 
  66     url: 'https://tile.tracestrack.com/topo__/{z}/{x}/{y}.png?key={apikey}',
 
  68     attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors. Tiles courtesy of <a href="https://www.tracestrack.com/" target="_blank">Tracestrack Maps</a>'
 
  72 L.OSM.GPS = L.OSM.TileLayer.extend({
 
  74     url: 'https://gps.tile.openstreetmap.org/lines/{z}/{x}/{y}.png',
 
  81 L.OSM.DataLayer = L.FeatureGroup.extend({
 
  83     areaTags: ['area', 'building', 'leisure', 'tourism', 'ruins', 'historic', 'landuse', 'military', 'natural', 'sport'],
 
  84     uninterestingTags: ['source', 'source_ref', 'source:ref', 'history', 'attribution', 'created_by', 'tiger:county', 'tiger:tlid', 'tiger:upload_uuid'],
 
  88   initialize: function (xml, options) {
 
  89     L.Util.setOptions(this, options);
 
  91     L.FeatureGroup.prototype.initialize.call(this);
 
  98   addData: function (features) {
 
  99     if (!(features instanceof Array)) {
 
 100       features = this.buildFeatures(features);
 
 103     for (var i = 0; i < features.length; i++) {
 
 104       var feature = features[i], layer;
 
 106       if (feature.type === "changeset") {
 
 107         layer = L.rectangle(feature.latLngBounds, this.options.styles.changeset);
 
 108       } else if (feature.type === "node") {
 
 109         layer = L.circleMarker(feature.latLng, this.options.styles.node);
 
 111         var latLngs = new Array(feature.nodes.length);
 
 113         for (var j = 0; j < feature.nodes.length; j++) {
 
 114           latLngs[j] = feature.nodes[j].latLng;
 
 117         if (this.isWayArea(feature)) {
 
 118           latLngs.pop(); // Remove last == first.
 
 119           layer = L.polygon(latLngs, this.options.styles.area);
 
 121           layer = L.polyline(latLngs, this.options.styles.way);
 
 126       layer.feature = feature;
 
 130   buildFeatures: function (xml) {
 
 131     var features = L.OSM.getChangesets(xml),
 
 132       nodes = L.OSM.getNodes(xml),
 
 133       ways = L.OSM.getWays(xml, nodes),
 
 134       relations = L.OSM.getRelations(xml, nodes, ways);
 
 136     for (var node_id in nodes) {
 
 137       var node = nodes[node_id];
 
 138       if (this.interestingNode(node, ways, relations)) {
 
 143     for (var i = 0; i < ways.length; i++) {
 
 151   isWayArea: function (way) {
 
 152     if (way.nodes[0] != way.nodes[way.nodes.length - 1]) {
 
 156     for (var key in way.tags) {
 
 157       if (~this.options.areaTags.indexOf(key)) {
 
 165   interestingNode: function (node, ways, relations) {
 
 168     for (var i = 0; i < ways.length; i++) {
 
 169       if (ways[i].nodes.indexOf(node) >= 0) {
 
 179     for (var i = 0; i < relations.length; i++) {
 
 180       if (relations[i].members.indexOf(node) >= 0)
 
 184     for (var key in node.tags) {
 
 185       if (this.options.uninterestingTags.indexOf(key) < 0) {
 
 194 L.Util.extend(L.OSM, {
 
 195   getChangesets: function (xml) {
 
 198     var nodes = xml.getElementsByTagName("changeset");
 
 199     for (var i = 0; i < nodes.length; i++) {
 
 200       var node = nodes[i], id = node.getAttribute("id");
 
 204         latLngBounds: L.latLngBounds(
 
 205           [node.getAttribute("min_lat"), node.getAttribute("min_lon")],
 
 206           [node.getAttribute("max_lat"), node.getAttribute("max_lon")]),
 
 207         tags: this.getTags(node)
 
 214   getNodes: function (xml) {
 
 217     var nodes = xml.getElementsByTagName("node");
 
 218     for (var i = 0; i < nodes.length; i++) {
 
 219       var node = nodes[i], id = node.getAttribute("id");
 
 223         latLng: L.latLng(node.getAttribute("lat"),
 
 224                          node.getAttribute("lon"),
 
 226         tags: this.getTags(node)
 
 233   getWays: function (xml, nodes) {
 
 236     var ways = xml.getElementsByTagName("way");
 
 237     for (var i = 0; i < ways.length; i++) {
 
 238       var way = ways[i], nds = way.getElementsByTagName("nd");
 
 241         id: way.getAttribute("id"),
 
 243         nodes: new Array(nds.length),
 
 244         tags: this.getTags(way)
 
 247       for (var j = 0; j < nds.length; j++) {
 
 248         way_object.nodes[j] = nodes[nds[j].getAttribute("ref")];
 
 251       result.push(way_object);
 
 257   getRelations: function (xml, nodes, ways) {
 
 260     var rels = xml.getElementsByTagName("relation");
 
 261     for (var i = 0; i < rels.length; i++) {
 
 262       var rel = rels[i], members = rel.getElementsByTagName("member");
 
 265         id: rel.getAttribute("id"),
 
 267         members: new Array(members.length),
 
 268         tags: this.getTags(rel)
 
 271       for (var j = 0; j < members.length; j++) {
 
 272         if (members[j].getAttribute("type") === "node")
 
 273           rel_object.members[j] = nodes[members[j].getAttribute("ref")];
 
 274         else // relation-way and relation-relation membership not implemented
 
 275           rel_object.members[j] = null;
 
 278       result.push(rel_object);
 
 284   getTags: function (xml) {
 
 287     var tags = xml.getElementsByTagName("tag");
 
 288     for (var j = 0; j < tags.length; j++) {
 
 289       result[tags[j].getAttribute("k")] = tags[j].getAttribute("v");