Merge pull request #847 from jtreml/custom_unit_in_scale_control_hooks
Provide the hooks needed for writing plugins / extensions to scale control
This commit is contained in:
commit
3b2250cd32
5
dist/leaflet.css
vendored
5
dist/leaflet.css
vendored
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user