@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 4.33 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(896)},3:function(t,e){t.exports=function(){throw Error("define cannot be used indirect")}},891:function(t,e){t.exports=require("../location")},896:function(t,e,i){var n,o,a;!function(r,define){o=[i(897),i(891),i(898),i(899)],n=r,a="function"==typeof n?n.apply(e,o):n,!(void 0!==a&&(t.exports=a))}(function(){!function(t,e){var i=document,n=Math,o=t.inArray,a=t.proxy,r=window.kendo,s=r.Class,h=r.data.DataSource,c=r.ui.Tooltip,d=r.dataviz,l=r.deepExtend,u=d.map,p=u.Location,f=u.layers.Layer,m=f.extend({init:function(t,e){f.fn.init.call(this,t,e),this._markerClick=a(this._markerClick,this),this.element.on("click",".k-marker",this._markerClick),this.items=[],this._initDataSource()},destroy:function(){f.fn.destroy.call(this),this.element.off("click",".k-marker",this._markerClick),this.dataSource.unbind("change",this._dataChange),this.clear()},options:{zIndex:1e3,autoBind:!0,dataSource:{},locationField:"location",titleField:"title"},add:function(e){if(!t.isArray(e))return this._addOne(e);for(var i=0;i<e.length;i++)this._addOne(e[i])},remove:function(t){t.destroy();var e=o(t,this.items);e>-1&&this.items.splice(e,1)},clear:function(){for(var t=0;t<this.items.length;t++)this.items[t].destroy();this.items=[]},update:function(t){var e,i=t.location();i&&(t.showAt(this.map.locationToView(i)),e={marker:t,layer:this},this.map.trigger("markerActivate",e))},_reset:function(){var t,e;for(f.fn._reset.call(this),t=this.items,e=0;e<t.length;e++)this.update(t[e])},bind:function(t,e){var i,n,o=u.Marker.create(t,this.options);if(o.dataItem=e,i={marker:o,layer:this},n=this.map.trigger("markerCreated",i),!n)return this.add(o),o},setDataSource:function(t){this.dataSource&&this.dataSource.unbind("change",this._dataChange),this.dataSource=r.data.DataSource.create(t),this.dataSource.bind("change",this._dataChange),this.options.autoBind&&this.dataSource.fetch()},_addOne:function(t){var e=k.create(t,this.options);return e.addTo(this),e},_initDataSource:function(){var t=this.options.dataSource;this._dataChange=a(this._dataChange,this),this.dataSource=h.create(t).bind("change",this._dataChange),t&&this.options.autoBind&&this.dataSource.fetch()},_dataChange:function(t){this._load(t.sender.view())},_load:function(t){var e,i,n,o;for(this._data=t,this.clear(),e=r.getter(this.options.locationField),i=r.getter(this.options.titleField),n=0;n<t.length;n++)o=t[n],this.bind({location:e(o),title:i(o)},o)},_markerClick:function(e){var i={marker:t(e.target).data("kendoMarker"),layer:this};this.map.trigger("markerClick",i)}}),k=s.extend({init:function(t){this.options=t||{}},addTo:function(t){this.layer=t.markers||t,this.layer.items.push(this),this.layer.update(this)},location:function(t){return t?(this.options.location=p.create(t).toArray(),this.layer&&this.layer.update(this),this):p.create(this.options.location)},showAt:function(t){this.render(),this.element.css({left:n.round(t.x),top:n.round(t.y)}),this.tooltip&&this.tooltip.popup&&this.tooltip.popup._position()},hide:function(){this.element&&(this.element.remove(),this.element=null),this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)},destroy:function(){this.layer=null,this.hide()},render:function(){var e,n;this.element||(e=this.options,n=this.layer,this.element=t(i.createElement("span")).addClass("k-marker k-icon k-i-marker-"+r.toHyphens(e.shape||"pin")).attr("title",e.title).attr(e.attributes||{}).data("kendoMarker",this).css("zIndex",e.zIndex),n&&n.element.append(this.element),this.renderTooltip())},renderTooltip:function(){var t,e,i=this,n=i.options.title,o=i.options.tooltip||{};o&&c&&(t=o.template,t&&(e=r.template(t),o.content=function(t){return t.location=i.location(),t.marker=i,e(t)}),(n||o.content||o.contentUrl)&&(this.tooltip=new c(this.element,o),this.tooltip.marker=this))}});k.create=function(t,e){return t instanceof k?t:new k(l({},e,t))},l(d,{map:{layers:{marker:m,MarkerLayer:m},Marker:k}})}(window.kendo.jQuery)},i(3))},897:function(t,e){t.exports=require("./base")},898:function(t,e){t.exports=require("../../../kendo.data")},899:function(t,e){t.exports=require("../../../kendo.tooltip")}});