diff --git a/dist/leaflet.css b/dist/leaflet.css index cd00cfe1..c76c54a6 100644 --- a/dist/leaflet.css +++ b/dist/leaflet.css @@ -227,12 +227,15 @@ text-shadow: 1px 1px 1px #fff; background-color: rgba(255, 255, 255, 0.5); } -.leaflet-control-scale-line:nth-child(2) { +.leaflet-control-scale-line:not(:first-child) { border-top: 2px solid #777; padding-top: 1px; border-bottom: none; margin-top: -2px; } +.leaflet-control-scale-line:not(:first-child):not(:last-child) { + border-bottom: 2px solid #777; + } .leaflet-touch .leaflet-control-attribution, .leaflet-touch .leaflet-control-layers { box-shadow: none; diff --git a/src/control/Control.Scale.js b/src/control/Control.Scale.js index 1d60e94e..70cff0db 100644 --- a/src/control/Control.Scale.js +++ b/src/control/Control.Scale.js @@ -14,12 +14,7 @@ L.Control.Scale = L.Control.extend({ container = L.DomUtil.create('div', className), options = this.options; - if (options.metric) { - this._mScale = L.DomUtil.create('div', className + '-line', container); - } - if (options.imperial) { - this._iScale = L.DomUtil.create('div', className + '-line', container); - } + this._addScales(options, className, container); map.on(options.updateWhenIdle ? 'moveend' : 'move', this._update, this); this._update(); @@ -31,6 +26,16 @@ L.Control.Scale = L.Control.extend({ map.off(this.options.updateWhenIdle ? 'moveend' : 'move', this._update, this); }, + _addScales: function(options, className, container) { + if (options.metric) { + this._mScale = L.DomUtil.create('div', className + '-line', container); + } + + if (options.imperial) { + this._iScale = L.DomUtil.create('div', className + '-line', container); + } + }, + _update: function () { var bounds = this._map.getBounds(), centerLat = bounds.getCenter().lat, @@ -45,6 +50,10 @@ L.Control.Scale = L.Control.extend({ maxMeters = dist * (options.maxWidth / size.x); } + this._updateScales(options, maxMeters); + }, + + _updateScales: function (options, maxMeters) { if (options.metric && maxMeters) { this._updateMetric(maxMeters); }