UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 10.6 kB
module.exports=function(t){function i(o){if(e[o])return e[o].exports;var n=e[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}var e={};return i.m=t,i.c=e,i.p="",i(0)}({0:function(t,i,e){t.exports=e(929)},3:function(t,i){t.exports=function(){throw Error("define cannot be used indirect")}},913:function(t,i){t.exports=require("./location")},929:function(t,i,e){var o,n,r;!function(s,define){n=[e(930),e(913)],o=s,r="function"==typeof o?o.apply(i,n):o,!(void 0!==r&&(t.exports=r))}(function(){!function(t,i){var e=document,o=Math,n=o.min,r=o.pow,s=t.proxy,a=window.kendo,h=a.ui.Widget,l=a.deepExtend,c=a.dataviz,u=c.ui,m=a.geometry,p=m.Point,g=c.map,f=g.Extent,v=g.Location,d=g.crs.EPSG3857,_=a.util,y=_.renderPos,w=a.drawing.util,z=w.defined,x=w.limitValue,T=w.valueOrDefault,b="k-",E=.9,L=.93,S="DOMMouseScroll mousewheel",C=5,O=1,k=h.extend({init:function(t,i){a.destroy(t),h.fn.init.call(this,t),this._initOptions(i),this.bind(this.events,i),this.crs=new d,this.element.addClass(b+this.options.name.toLowerCase()).css("position","relative").empty().append(e.createElement("div")),this._viewOrigin=this._getOrigin(),this._initScroller(),this._initMarkers(),this._initControls(),this._initLayers(),this._reset(),this._mousewheel=s(this._mousewheel,this),this.element.bind(S,this._mousewheel)},options:{name:"Map",controls:{attribution:!0,navigator:{panStep:100},zoom:!0},layers:[],layerDefaults:{shape:{style:{fill:{color:"#fff"},stroke:{color:"#aaa",width:.5}}},bubble:{style:{fill:{color:"#fff",opacity:.5},stroke:{color:"#aaa",width:.5}}},marker:{shape:"pinTarget",tooltip:{position:"top"}}},center:[0,0],zoom:3,minSize:256,minZoom:1,maxZoom:19,markers:[],markerDefaults:{shape:"pinTarget",tooltip:{position:"top"}},wraparound:!0},events:["beforeReset","click","markerActivate","markerClick","markerCreated","pan","panEnd","reset","shapeClick","shapeCreated","shapeFeatureCreated","shapeMouseEnter","shapeMouseLeave","zoomEnd","zoomStart"],destroy:function(){this.scroller.destroy(),this.navigator&&this.navigator.destroy(),this.attribution&&this.attribution.destroy(),this.zoomControl&&this.zoomControl.destroy(),this.markers.destroy();for(var t=0;t<this.layers.length;t++)this.layers[t].destroy();h.fn.destroy.call(this)},zoom:function(t){var i=this.options;return z(t)?(t=o.round(x(t,i.minZoom,i.maxZoom)),i.zoom!==t&&(i.zoom=t,this._reset()),this):i.zoom},center:function(t){return t?(this.options.center=v.create(t).toArray(),this._reset(),this):v.create(this.options.center)},extent:function(t){return t?(this._setExtent(t),this):this._getExtent()},setOptions:function(t){h.fn.setOptions.call(this,t),this._reset()},locationToLayer:function(t,i){var e=!this.options.wraparound;return t=v.create(t),this.crs.toPoint(t,this._layerSize(i),e)},layerToLocation:function(t,i){var e=!this.options.wraparound;return t=p.create(t),this.crs.toLocation(t,this._layerSize(i),e)},locationToView:function(t){var i,e;return t=v.create(t),i=this.locationToLayer(this._viewOrigin),e=this.locationToLayer(t),e.translateWith(i.scale(-1))},viewToLocation:function(t,i){var e=this.locationToLayer(this._getOrigin(),i);return t=p.create(t),t=t.clone().translateWith(e),this.layerToLocation(t,i)},eventOffset:function(t){var i,e,o,n,r,s=this.element.offset();return t.x||t.y?(n="location",e=t.x[n]-s.left,o=t.y[n]-s.top,i=new m.Point(e,o)):(r=t.originalEvent||t,e=T(r.pageX,r.clientX)-s.left,o=T(r.pageY,r.clientY)-s.top,i=new m.Point(e,o)),i},eventToView:function(t){var i=this.eventOffset(t);return this.locationToView(this.viewToLocation(i))},eventToLayer:function(t){return this.locationToLayer(this.eventToLocation(t))},eventToLocation:function(t){var i=this.eventOffset(t);return this.viewToLocation(i)},viewSize:function(){var t=this.element,i=this._layerSize(),e=t.width();return this.options.wraparound||(e=n(i,e)),{width:e,height:n(i,t.height())}},exportVisual:function(){return this._reset(),!1},_setOrigin:function(t,i){var e,o=this.viewSize();return t=this._origin=v.create(t),e=this.locationToLayer(t,i),e.x+=o.width/2,e.y+=o.height/2,this.options.center=this.layerToLocation(e,i).toArray(),this},_getOrigin:function(t){var i,e=this.viewSize();return!t&&this._origin||(i=this.locationToLayer(this.center()),i.x-=e.width/2,i.y-=e.height/2,this._origin=this.layerToLocation(i)),this._origin},_setExtent:function(t){var i,e,n,r,s,a,h,l=f.create(t),c=l.se.clone();for(this.options.wraparound&&c.lng<0&&t.nw.lng>0&&(c.lng=180+(180+c.lng)),t=new f(l.nw,c),this.center(t.center()),i=this.element.width(),e=this.element.height(),n=this.options.maxZoom;n>=this.options.minZoom&&(r=this.locationToLayer(t.nw,n),s=this.locationToLayer(t.se,n),a=o.abs(s.x-r.x),h=o.abs(s.y-r.y),!(a<=i&&h<=e));n--);this.zoom(n)},_getExtent:function(){var t,i=this._getOrigin(),e=this.locationToLayer(i),o=this.viewSize();return e.x+=o.width,e.y+=o.height,t=this.layerToLocation(e),new f(i,t)},_zoomAround:function(t,i){this._setOrigin(this.layerToLocation(t,i),i),this.zoom(i)},_initControls:function(){var t=this.options.controls;u.Attribution&&t.attribution&&this._createAttribution(t.attribution),a.support.mobileOS||(u.Navigator&&t.navigator&&this._createNavigator(t.navigator),u.ZoomControl&&t.zoom&&this._createZoomControl(t.zoom))},_createControlElement:function(i,e){var o=i.position||e,n="."+y(o).replace(" ","."),r=t(".k-map-controls"+n,this.element);return 0===r.length&&(r=t("<div>").addClass("k-map-controls "+y(o)).appendTo(this.element)),t("<div>").appendTo(r)},_createAttribution:function(t){var i=this._createControlElement(t,"bottomRight");this.attribution=new u.Attribution(i,t)},_createNavigator:function(t){var i=this._createControlElement(t,"topLeft"),e=this.navigator=new u.Navigator(i,t);this._navigatorPan=s(this._navigatorPan,this),e.bind("pan",this._navigatorPan),this._navigatorCenter=s(this._navigatorCenter,this),e.bind("center",this._navigatorCenter)},_navigatorPan:function(t){var i=this,e=i.scroller,o=e.scrollLeft+t.x,n=e.scrollTop-t.y,r=this._virtualSize,s=this.element.height(),a=this.element.width();o=x(o,r.x.min,r.x.max-a),n=x(n,r.y.min,r.y.max-s),i.scroller.one("scroll",function(t){i._scrollEnd(t)}),i.scroller.scrollTo(-o,-n)},_navigatorCenter:function(){this.center(this.options.center)},_createZoomControl:function(t){var i=this._createControlElement(t,"topLeft"),e=this.zoomControl=new u.ZoomControl(i,t);this._zoomControlChange=s(this._zoomControlChange,this),e.bind("change",this._zoomControlChange)},_zoomControlChange:function(t){this.trigger("zoomStart",{originalEvent:t})||(this.zoom(this.zoom()+t.delta),this.trigger("zoomEnd",{originalEvent:t}))},_initScroller:function(){var t=a.support.mobileOS?L:E,i=this.options.zoomable!==!1,e=this.scroller=new a.mobile.ui.Scroller(this.element.children(0),{friction:t,velocityMultiplier:C,zoom:i,mousewheelScrolling:!1,supportDoubleTap:!0});e.bind("scroll",s(this._scroll,this)),e.bind("scrollEnd",s(this._scrollEnd,this)),e.userEvents.bind("gesturestart",s(this._scaleStart,this)),e.userEvents.bind("gestureend",s(this._scale,this)),e.userEvents.bind("doubleTap",s(this._doubleTap,this)),e.userEvents.bind("tap",s(this._tap,this)),this.scrollElement=e.scrollElement},_initLayers:function(){var t,i,e,o,n,r=this.options.layers,s=this.layers=[];for(t=0;t<r.length;t++)i=r[t],e=i.type||"shape",o=this.options.layerDefaults[e],n=c.map.layers[e],s.push(new n(this,l({},o,i)))},_initMarkers:function(){this.markers=new g.layers.MarkerLayer(this,this.options.markerDefaults),this.markers.add(this.options.markers)},_scroll:function(t){var i=this.locationToLayer(this._viewOrigin).round(),e=t.sender.movable,o=new m.Point(e.x,e.y).scale(-1).scale(1/e.scale);i.x+=o.x,i.y+=o.y,this._scrollOffset=o,this._setOrigin(this.layerToLocation(i)),this.trigger("pan",{originalEvent:t,origin:this._getOrigin(),center:this.center()})},_scrollEnd:function(t){this._scrollOffset&&this._panComplete()&&(this._scrollOffset=null,this._panEndTS=new Date,this.trigger("panEnd",{originalEvent:t,origin:this._getOrigin(),center:this.center()}))},_panComplete:function(){return new Date-(this._panEndTS||0)>50},_scaleStart:function(t){if(this.trigger("zoomStart",{originalEvent:t})){var i=t.touches[1];i&&i.cancel()}},_scale:function(t){var i=this.scroller.movable.scale,e=this._scaleToZoom(i),o=new m.Point(t.center.x,t.center.y),n=this.viewToLocation(o,e),r=this.locationToLayer(n,e),s=r.translate(-o.x,-o.y);this._zoomAround(s,e),this.trigger("zoomEnd",{originalEvent:t})},_scaleToZoom:function(t){var i=this._layerSize()*t,e=i/this.options.minSize,n=o.log(e)/o.log(2);return o.round(n)},_reset:function(){this.attribution&&this.attribution.filter(this.center(),this.zoom()),this._viewOrigin=this._getOrigin(!0),this._resetScroller(),this.trigger("beforeReset"),this.trigger("reset")},_resetScroller:function(){var t,i,e,o,n=this.scroller,s=n.dimensions.x,a=n.dimensions.y,h=this._layerSize(),l=this.extent().nw,c=this.locationToLayer(l).round();n.movable.round=!0,n.reset(),n.userEvents.cancel(),t=this.zoom(),n.dimensions.forcedMinScale=r(2,this.options.minZoom-t),n.dimensions.maxScale=r(2,this.options.maxZoom-t),i={min:-c.x,max:h-c.x},e={min:-c.y,max:h-c.y},this.options.wraparound&&(i.max=20*h,i.min=-i.max),this.options.pannable===!1&&(o=this.viewSize(),i.min=e.min=0,i.max=o.width,e.max=o.height),s.makeVirtual(),a.makeVirtual(),s.virtualSize(i.min,i.max),a.virtualSize(e.min,e.max),this._virtualSize={x:i,y:e}},_renderLayers:function(){var t,i,e,o,n,r=this.options.layers,s=this.layers=[],a=this.scrollWrap;for(a.empty(),t=0;t<r.length;t++)i=r[t],e=i.type||"shape",o=this.options.layerDefaults[e],n=c.map.layers[e],s.push(new n(this,l({},o,i)))},_layerSize:function(t){return t=T(t,this.options.zoom),this.options.minSize*r(2,t)},_tap:function(t){if(this._panComplete()){var i=this.eventOffset(t);this.trigger("click",{originalEvent:t,location:this.viewToLocation(i)})}},_doubleTap:function(t){var i,e,o,n,r,s=this.options;s.zoomable!==!1&&(this.trigger("zoomStart",{originalEvent:t})||(i=this.zoom()+O,e=this.eventOffset(t),o=this.viewToLocation(e),n=this.locationToLayer(o,i),r=n.translate(-e.x,-e.y),this._zoomAround(r,i),this.trigger("zoomEnd",{originalEvent:t})))},_mousewheel:function(t){var i,e,o,n,r,s,a,h;t.preventDefault(),i=c.mwDelta(t)>0?-1:1,e=this.options,o=this.zoom(),n=x(o+i,e.minZoom,e.maxZoom),e.zoomable!==!1&&n!==o&&(this.trigger("zoomStart",{originalEvent:t})||(r=this.eventOffset(t),s=this.viewToLocation(r),a=this.locationToLayer(s,n),h=a.translate(-r.x,-r.y),this._zoomAround(h,n),this.trigger("zoomEnd",{originalEvent:t})))}});c.ui.plugin(k)}(window.kendo.jQuery)},e(3))},930:function(t,i){t.exports=require("./crs")}});