@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 5.92 kB
JavaScript
module.exports=function(t){function e(n){if(i[n])return i[n].exports;var o=i[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}({0:function(t,e,i){t.exports=i(901)},3:function(t,e){t.exports=function(){throw Error("define cannot be used indirect")}},891:function(t,e){t.exports=require("../location")},897:function(t,e){t.exports=require("./base")},901:function(t,e,i){var n,o,s;!function(r,define){o=[i(897),i(891)],n=r,s="function"==typeof n?n.apply(e,o):n,!(void 0!==s&&(t.exports=s))}(function(){!function(t,e){function i(t){return new p(x(t.x),x(t.y))}var n=Math,o=t.proxy,s=window.kendo,r=s.Class,l=s.template,h=s.dataviz,a=s.deepExtend,u=s.geometry,p=u.Point,c=h.map.layers.Layer,d=s.util,f=d.renderSize,m=s.drawing.util,x=m.round,_=m.limitValue,v=c.extend({init:function(t,e){c.fn.init.call(this,t,e),"string"==typeof this.options.subdomains&&(this.options.subdomains=this.options.subdomains.split(""));var i=this._viewType();this._view=new i(this.element,this.options)},destroy:function(){c.fn.destroy.call(this),this._view.destroy(),this._view=null},_beforeReset:function(){var t=this.map,e=t.locationToLayer(t.extent().nw).round();this._view.viewOrigin(e)},_reset:function(){c.fn._reset.call(this),this._updateView(),this._view.reset()},_viewType:function(){return y},_activate:function(){c.fn._activate.call(this),s.support.mobileOS||(this._pan||(this._pan=s.throttle(o(this._render,this),100)),this.map.bind("pan",this._pan))},_deactivate:function(){c.fn._deactivate.call(this),this._pan&&this.map.unbind("pan",this._pan)},_updateView:function(){var t=this._view,e=this.map,i=e.extent(),n={nw:e.locationToLayer(i.nw).round(),se:e.locationToLayer(i.se).round()};t.center(e.locationToLayer(e.center())),t.extent(n),t.zoom(e.zoom())},_resize:function(){this._render()},_panEnd:function(t){c.fn._panEnd.call(this,t),this._render()},_render:function(){this._updateView(),this._view.render()}}),y=r.extend({init:function(t,e){this.element=t,this._initOptions(e),this.pool=new b},options:{tileSize:256,subdomains:["a","b","c"],urlTemplate:""},center:function(t){this._center=t},extent:function(t){this._extent=t},viewOrigin:function(t){this._viewOrigin=t},zoom:function(t){this._zoom=t},pointToTileIndex:function(t){return new p(n.floor(t.x/this.options.tileSize),n.floor(t.y/this.options.tileSize))},tileCount:function(){var t=this.size(),e=this.pointToTileIndex(this._extent.nw),i=this._extent.nw,o=this.indexToPoint(e).translate(-i.x,-i.y);return{x:n.ceil((n.abs(o.x)+t.width)/this.options.tileSize),y:n.ceil((n.abs(o.y)+t.height)/this.options.tileSize)}},size:function(){var t=this._extent.nw,e=this._extent.se,i=e.clone().translate(-t.x,-t.y);return{width:i.x,height:i.y}},indexToPoint:function(t){var e=t.x,i=t.y;return new p(e*this.options.tileSize,i*this.options.tileSize)},subdomainText:function(){var t=this.options.subdomains;return t[this.subdomainIndex++%t.length]},destroy:function(){this.element.empty(),this.pool.empty()},reset:function(){this.pool.reset(),this.subdomainIndex=0,this.render()},render:function(){var t,e,i,n=this.tileCount(),o=this.pointToTileIndex(this._extent.nw);for(e=0;e<n.x;e++)for(i=0;i<n.y;i++)t=this.createTile({x:o.x+e,y:o.y+i}),t.visible||t.show()},createTile:function(t){var e=this.tileOptions(t),i=this.pool.get(this._center,e);return 0===i.element.parent().length&&this.element.append(i.element),i},tileOptions:function(t){var e=this.wrapIndex(t),n=this.indexToPoint(t),o=this._viewOrigin,s=n.clone().translate(-o.x,-o.y);return{index:e,currentIndex:t,point:n,offset:i(s),zoom:this._zoom,size:this.options.tileSize,subdomain:this.subdomainText(),urlTemplate:this.options.urlTemplate,errorUrlTemplate:this.options.errorUrlTemplate}},wrapIndex:function(t){var e=n.pow(2,this._zoom);return{x:this.wrapValue(t.x,e),y:_(t.y,0,e-1)}},wrapValue:function(t,e){var i=n.abs(t)%e;return t=t>=0?i:e-(0===i?e:i)}}),w=r.extend({init:function(t,e){this.id=t,this.visible=!0,this._initOptions(e),this.createElement(),this.show()},options:{urlTemplate:"",errorUrlTemplate:""},createElement:function(){this.element=t("<img style='position: absolute; display: block;' alt='' />").css({width:this.options.size,height:this.options.size}).on("error",o(function(t){this.errorUrl()?t.target.setAttribute("src",this.errorUrl()):t.target.removeAttribute("src")},this))},show:function(){var t,e=this.element[0];e.style.top=f(this.options.offset.y),e.style.left=f(this.options.offset.x),t=this.url(),t&&e.setAttribute("src",t),e.style.visibility="visible",this.visible=!0},hide:function(){this.element[0].style.visibility="hidden",this.visible=!1},url:function(){var t=l(this.options.urlTemplate);return t(this.urlOptions())},errorUrl:function(){var t=l(this.options.errorUrlTemplate);return t(this.urlOptions())},urlOptions:function(){var t=this.options;return{zoom:t.zoom,subdomain:t.subdomain,z:t.zoom,x:t.index.x,y:t.index.y,s:t.subdomain,quadkey:t.quadkey,q:t.quadkey,culture:t.culture,c:t.culture}},destroy:function(){this.element&&(this.element.remove(),this.element=null)}}),b=r.extend({init:function(){this._items=[]},options:{maxSize:100},get:function(t,e){return this._items.length>=this.options.maxSize&&this._remove(t),this._create(e)},empty:function(){var t,e=this._items;for(t=0;t<e.length;t++)e[t].destroy();this._items=[]},reset:function(){var t,e=this._items;for(t=0;t<e.length;t++)e[t].hide()},_create:function(t){var e,i,n=this._items,o=d.hashKey(""+t.point+(""+t.offset)+t.zoom+t.urlTemplate);for(i=0;i<n.length;i++)if(n[i].id===o){e=n[i];break}return e?e.show():(e=new w(o,t),this._items.push(e)),e},_remove:function(t){var e,i,n=this._items,o=-1,s=-1;for(e=0;e<n.length;e++)i=n[e].options.point.distanceTo(t),i>o&&!n[e].visible&&(s=e,o=i);s!==-1&&(n[s].destroy(),n.splice(s,1))}});a(h,{map:{layers:{tile:v,TileLayer:v,ImageTile:w,TilePool:b,TileView:y}}})}(window.kendo.jQuery)},i(3))}});