diff --git a/dist/leaflet.nauticscale.js b/dist/leaflet.nauticscale.js index f396925..ccf19ac 100644 --- a/dist/leaflet.nauticscale.js +++ b/dist/leaflet.nauticscale.js @@ -5,16 +5,15 @@ L.Control.ScaleNautic = L.Control.Scale.extend({ _addScales: function(options, className, container) { L.Control.Scale.prototype._addScales.call(this, options, className, container); - - if (options.nautic) { - this._nScale = L.DomUtil.create('div', className + '-line', container); + L.setOptions(options); + if (this.options.nautic) { + this._nScale = L.DomUtil.create('div', className, container); } }, - _updateScales: function (options, maxMeters) { - L.Control.Scale.prototype._updateScales.call(this, options, maxMeters); - - if (options.nautic && maxMeters) { + _updateScales: function (maxMeters) { + L.Control.Scale.prototype._updateScales.call(this, maxMeters); + if (this.options.nautic && maxMeters) { this._updateNautic(maxMeters); } }, @@ -29,9 +28,9 @@ L.Control.ScaleNautic = L.Control.Scale.extend({ nauticalMiles = maxNauticalMiles > 0.1 ? Math.round(maxNauticalMiles * 10) / 10 : Math.round(maxNauticalMiles * 100) / 100; } - scale.style.width = this._getScaleWidth(nauticalMiles / maxNauticalMiles) + 'px'; + scale.style.width = Math.round(this.options.maxWidth * (nauticalMiles / maxNauticalMiles)) - 10 + 'px'; scale.innerHTML = nauticalMiles + ' nm'; - }, + } }); L.control.scalenautic = function (options) { diff --git a/dist/leaflet.nauticscale.min.js b/dist/leaflet.nauticscale.min.js index b92d68a..bd308a6 100644 --- a/dist/leaflet.nauticscale.min.js +++ b/dist/leaflet.nauticscale.min.js @@ -1,2 +1,2 @@ -/*! leaflet.nauticscale 2016-09-13 Copyright by */ -L.Control.ScaleNautic=L.Control.Scale.extend({options:{nautic:!1},_addScales:function(a,b,c){L.Control.Scale.prototype._addScales.call(this,a,b,c),a.nautic&&(this._nScale=L.DomUtil.create("div",b+"-line",c))},_updateScales:function(a,b){L.Control.Scale.prototype._updateScales.call(this,a,b),a.nautic&&b&&this._updateNautic(b)},_updateNautic:function(a){var b,c=this._nScale,d=a/1852;b=a>=1852?L.Control.Scale.prototype._getRoundNum.call(this,d):d>.1?Math.round(10*d)/10:Math.round(100*d)/100,c.style.width=this._getScaleWidth(b/d)+"px",c.innerHTML=b+" nm"}}),L.control.scalenautic=function(a){return new L.Control.ScaleNautic(a)}; \ No newline at end of file +/*! leaflet.nauticscale 2016-11-15 Copyright by */ +L.Control.ScaleNautic=L.Control.Scale.extend({options:{nautic:!1},_addScales:function(a,b,c){L.Control.Scale.prototype._addScales.call(this,a,b,c),L.setOptions(a),this.options.nautic&&(this._nScale=L.DomUtil.create("div",b,c))},_updateScales:function(a){L.Control.Scale.prototype._updateScales.call(this,a),this.options.nautic&&a&&this._updateNautic(a)},_updateNautic:function(a){var b,c=this._nScale,d=a/1852;b=a>=1852?L.Control.Scale.prototype._getRoundNum.call(this,d):d>.1?Math.round(10*d)/10:Math.round(100*d)/100,c.style.width=Math.round(this.options.maxWidth*(b/d))-10+"px",c.innerHTML=b+" nm"}}),L.control.scalenautic=function(a){return new L.Control.ScaleNautic(a)}; \ No newline at end of file diff --git a/package.json b/package.json index 00b71c7..9eb1576 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "leaflet.nauticscale", - "version": "1.0.0", + "version": "1.1.0", "description": "Leaflet Nauticscale", "publishConfig": { "registry": "http://registry.npmjs.org/"