1L.Control.BetterScale = L.Control.extend({ 2 options: { 3 position: "bottomleft", 4 maxWidth: 150, 5 metric: !1, 6 imperial: !0, 7 updateWhenIdle: !1 8 }, 9 onAdd: function (t) { 10 this._map = t; 11 var e = "leaflet-control-better-scale", 12 i = L.DomUtil.create("div", e), 13 n = this.options, 14 s = L.DomUtil.create("div", e + "-ruler", i); 15 L.DomUtil.create("div", e + "-ruler-block " + e + "-upper-first-piece", s), L.DomUtil.create("div", e + "-ruler-block " + e + "-upper-second-piece", s), L.DomUtil.create("div", e + "-ruler-block " + e + "-lower-first-piece", s), L.DomUtil.create("div", e + "-ruler-block " + e + "-lower-second-piece", s); 16 return this._addScales(n, e, i), this.ScaleContainer = i, t.on(n.updateWhenIdle ? "moveend" : "move", this._update, this), t.whenReady(this._update, this), i 17 }, 18 onRemove: function (t) { 19 t.off(this.options.updateWhenIdle ? "moveend" : "move", this._update, this) 20 }, 21 _addScales: function (t, e, i) { 22 this._iScale = L.DomUtil.create("div", e + "-label-div", i), this._iScaleLabel = L.DomUtil.create("div", e + "-label", this._iScale), this._iScaleFirstNumber = L.DomUtil.create("div", e + "-label " + e + "-first-number", this._iScale), this._iScaleSecondNumber = L.DomUtil.create("div", e + "-label " + e + "-second-number", this._iScale) 23 }, 24 _update: function () { 25 var t = this._map.getBounds(), 26 e = t.getCenter().lat, 27 i = 6378137 * Math.PI * Math.cos(e * Math.PI / 180),
28 n = i * (t.getNorthEast().lng - t.getSouthWest().lng) / 180, 29 o = this._map.getSize(), 30 s = this.options, 31 a = 0; 32 o.x > 0 && (a = n * (s.maxWidth / o.x)), this._updateScales(s, a) 33 }, 34 _updateScales: function (t, e) { 35 t.metric && e && this._updateMetric(e), t.imperial && e && this._updateImperial(e) 36 }, 37 _updateMetric: function (t) { 38 var e, i, n, o, s, a = t, 39 r = this._iScaleFirstNumber, 40 h = this._iScaleSecondNumber, 41 l = this._iScale, 42 u = this._iScaleLabel; 43 u.innerHTML = "0", 44 a >= 1000 ? 45 (e = a / 1000, i = this._getRoundNum(e), o = i / 2, l.style.width = this._getScaleWidth(i / e) + "px", r.innerHTML = o, h.innerHTML = i + " km") 46 : 47 (n = this._getRoundNum(a), s = n / 2, l.style.width = this._getScaleWidth(n / a) + "px", r.innerHTML = s, h.innerHTML = n + " m") 48 }, 49 _updateImperial: function (t) { 50 var e, i, n, o, s, a = 3.2808399 * t, 51 r = this._iScaleFirstNumber, 52 h = this._iScaleSecondNumber, 53 l = this._iScale, 54 u = this._iScaleLabel; 55 u.innerHTML = "0", 56 a > 2640 ? 57 (e = a / 5280, i = this._getRoundNum(e), o = i / 2, l.style.width = this._getScaleWidth(i / e) + "px", r.innerHTML = o, h.innerHTML = i + "mi") 58 : 59 (n = this._getRoundNum(a), s = n / 2, l.style.width = this._getScaleWidth(n / a) + "px", r.innerHTML = s, h.innerHTML = n + "ft") 60 }, 61 _getScaleWidth: function (t) { 62 return Math.round(this.options.maxWidth * t) - 10 63 }, 64 _getRoundNum: function (t) { 65 if (t >= 10) { 66 var e = Math.pow(10, (Math.floor(t) + "").length - 1), 67 i = t / e; 68 return i = i >= 10 ? 10 : i >= 5 ? 5 : i >= 3 ? 3 : i >= 2 ? 2 : 1, e * i 69 } 70 return t = t >= 5 ? 5.0 : t >= 3 ? 3.0 : t >= 2 ? 2.0 : 1.0, t 71 } 72}); 73 74L.control.betterscale = function (options) { 75 return new L.Control.BetterScale(options) 76};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.