TC.control=TC.control||{};TC.Consts=TC.Consts||{};TC.Consts.SCREEN_SIZE_KEY="TC.Map.screenSize";TC.Control||TC.syncLoadJS(TC.apiLocation+"TC/Control");TC.control.Scale=function(){TC.Control.apply(this,arguments)};TC.inherit(TC.control.Scale,TC.Control);!function(){var e=TC.control.Scale.prototype;e.CLASS="tc-ctl-scl";e.template=function(){dust.register(e.CLASS,t);function t(e,t){return e.w('<div class="ol-scale-line ol-unselectable"><span>1:').h("math",t,{},{key:n,method:"round"}).w('</span> <input type="button" value="').f(t.get(["screenSize"],!1),t,"h").w("''\" title=\"").h("i18n",t,{},{$key:"estimatedMapSize"}).w('" /></div>')}t.__dustBody=!0;function n(e,t){return e.f(t.get(["scale"],!1),t,"h")}n.__dustBody=!0;return t};e.render=function(e){const t=this;return t._set1stRenderPromise(t.renderData({scale:t.getScale(),screenSize:TC.Cfg.screenSize},function(){const n=t.div.querySelector("span");n.textContent="1:"+t.format(n.textContent.substr(2));t.div.querySelector('input[type="button"]').addEventListener(TC.Consts.event.CLICK,function(){t.setScreenSize()});TC.Util.isFunction(e)&&e()}))};e.register=function(e){const t=this,n=TC.Control.prototype.register.call(t,e);var r=TC.Util.storage.getLocalValue(TC.Consts.SCREEN_SIZE_KEY);r&&(TC.Cfg.screenSize=r);t.render(function(){e.on(TC.Consts.event.ZOOM,function(){delete t.metersPerDegree;t.update()})});return n};e.update=function(){this.render()};e.setScreenSize=function(){var e=this;TC.prompt(e.getLocaleString("selectScreenSize"),TC.Cfg.screenSize,function(t){if(t){TC.Cfg.screenSize=parseFloat(t);TC.Util.storage.setLocalValue(TC.Consts.SCREEN_SIZE_KEY,TC.Cfg.screenSize);e.update()}})};e.getScale=function(e){var t=0,n=!e&&this.map?this.map.wrap.getResolution():e;if(n){t=n*this.getDpi(TC.Cfg.screenSize)/.0254;window.devicePixelRatio&&(t*=window.devicePixelRatio)}if(this.map&&this.map.wrap.isGeo()){if(!this.metersPerDegree){var r=this.map.getExtent();r&&(this.metersPerDegree=TC.Util.getMetersPerDegree(r))}this.metersPerDegree&&(t*=this.metersPerDegree)}return t};e.getDpi=function(e){this.dpi=Math.sqrt(screen.width*screen.width+screen.height*screen.height)/e;return this.dpi};e.format=function(e){for(var t=new Number(e).toFixed(0),n=[];t.length>3;){var r=t.length-3;n.unshift(t.substr(r));t=t.substr(0,r)}t&&n.unshift(t);return n.join(".")}}();
//# sourceMappingURL=../maps/control/Scale.min.js.map