jvectormap-next
Version:
jQuery plugin for embedding vector maps with reach API and methods for data visualization to the web-pages.
11 lines (10 loc) • 49.6 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self)["jvectormap-next"]=e()}(this,(function(){"use strict";var t={inherits:function(t,e){function a(){}a.prototype=e.prototype,t.prototype=new a,t.prototype.constructor=t,t.parentClass=e},mixin:function(t,e){var a;for(a in e.prototype)e.prototype.hasOwnProperty(a)&&(t.prototype[a]=e.prototype[a])},min:function(t){var e,a=Number.MAX_VALUE;if(t instanceof Array)for(e=0;e<t.length;e++)t[e]<a&&(a=t[e]);else for(e in t)t[e]<a&&(a=t[e]);return a},max:function(t){var e,a=Number.MIN_VALUE;if(t instanceof Array)for(e=0;e<t.length;e++)t[e]>a&&(a=t[e]);else for(e in t)t[e]>a&&(a=t[e]);return a},keys:function(t){var e,a=[];for(e in t)a.push(e);return a},values:function(t){var e,a,s=[];for(a=0;a<arguments.length;a++)for(e in t=arguments[a])s.push(t[e]);return s},whenImageLoaded:function(e){var a=new t.$.Deferred,s=t.$("<img/>");return s.on("error",(function(){a.reject()})).on("load",(function(){a.resolve(s)})),s.attr("src",e),a},isImageUrl:function(t){return/\.\w{3,4}$/.test(t)}};Array.prototype.indexOf||(Array.prototype.indexOf=function(t,e){var a;if(null==this)throw new TypeError('"this" is null or not defined');var s=Object(this),i=s.length>>>0;if(0===i)return-1;var n=+e||0;if(Math.abs(n)===1/0&&(n=0),n>=i)return-1;for(a=Math.max(n>=0?n:i-Math.abs(n),0);a<i;){if(a in s&&s[a]===t)return a;a++}return-1});var e=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){
/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
* Licensed under the MIT License (LICENSE.txt).
*
* Version: 3.1.9
*
* Requires: jQuery 1.2.2+
*/
t.exports=function(t){var e,a,s=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],i="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],n=Array.prototype.slice;if(t.event.fixHooks)for(var r=s.length;r;)t.event.fixHooks[s[--r]]=t.event.mouseHooks;var o=t.event.special.mousewheel={version:"3.1.9",setup:function(){if(this.addEventListener)for(var e=i.length;e;)this.addEventListener(i[--e],h,!1);else this.onmousewheel=h;t.data(this,"mousewheel-line-height",o.getLineHeight(this)),t.data(this,"mousewheel-page-height",o.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var t=i.length;t;)this.removeEventListener(i[--t],h,!1);else this.onmousewheel=null},getLineHeight:function(e){return parseInt(t(e)["offsetParent"in t.fn?"offsetParent":"parent"]().css("fontSize"),10)},getPageHeight:function(e){return t(e).height()},settings:{adjustOldDeltas:!0}};function h(s){var i=s||window.event,r=n.call(arguments,1),o=0,h=0,p=0,d=0;if((s=t.event.fix(i)).type="mousewheel","detail"in i&&(p=-1*i.detail),"wheelDelta"in i&&(p=i.wheelDelta),"wheelDeltaY"in i&&(p=i.wheelDeltaY),"wheelDeltaX"in i&&(h=-1*i.wheelDeltaX),"axis"in i&&i.axis===i.HORIZONTAL_AXIS&&(h=-1*p,p=0),o=0===p?h:p,"deltaY"in i&&(o=p=-1*i.deltaY),"deltaX"in i&&(h=i.deltaX,0===p&&(o=-1*h)),0!==p||0!==h){if(1===i.deltaMode){var m=t.data(this,"mousewheel-line-height");o*=m,p*=m,h*=m}else if(2===i.deltaMode){var u=t.data(this,"mousewheel-page-height");o*=u,p*=u,h*=u}return d=Math.max(Math.abs(p),Math.abs(h)),(!a||d<a)&&(a=d,c(i,d)&&(a/=40)),c(i,d)&&(o/=40,h/=40,p/=40),o=Math[o>=1?"floor":"ceil"](o/a),h=Math[h>=1?"floor":"ceil"](h/a),p=Math[p>=1?"floor":"ceil"](p/a),s.deltaX=h,s.deltaY=p,s.deltaFactor=a,s.deltaMode=0,r.unshift(s,o,h,p),e&&clearTimeout(e),e=setTimeout(l,200),(t.event.dispatch||t.event.handle).apply(this,r)}}function l(){a=null}function c(t,e){return o.settings.adjustOldDeltas&&"mousewheel"===t.type&&e%120==0}t.fn.extend({mousewheel:function(t){return t?this.bind("mousewheel",t):this.trigger("mousewheel")},unmousewheel:function(t){return this.unbind("mousewheel",t)}})}}));function a(a){if(!a||!a.fn)throw new Error("jvectormap-next requires a jQuery instance with a fn prototype.");if(a.fn.vectorMap)return a.fn.vectorMap;!function(t){if(t.event.special.mousewheel)return t.event.special.mousewheel;if("function"!=typeof e)throw new Error("jvectormap-next could not initialize jquery-mousewheel.");e(t),t.event.special.mousewheel}(a),t.$=a;var s={set:{colors:1,values:1,backgroundColor:1,scaleColors:1,normalizeFunction:1,focus:1},get:{selectedRegions:1,selectedMarkers:1,mapObject:1,regionName:1}};return a.fn.vectorMap=function(e){var a=this.children(".jvectormap-container").data("mapObject");if("addMap"===e)t.Map.maps[arguments[1]]=arguments[2];else{if(("set"===e||"get"===e)&&s[e][arguments[1]])return a[e+(arguments[1].charAt(0).toUpperCase()+arguments[1].substr(1))].apply(a,Array.prototype.slice.call(arguments,2));(e=e||{}).container=this,a=new t.Map(e)}return this},a.fn.vectorMap}t.AbstractElement=function(t,e){this.node=this.createElement(t),this.name=t,this.properties={},e&&this.set(e)},t.AbstractElement.prototype.set=function(t,e){var a;if("object"==typeof t)for(a in t)this.properties[a]=t[a],this.applyAttr(a,t[a]);else this.properties[t]=e,this.applyAttr(t,e)},t.AbstractElement.prototype.get=function(t){return this.properties[t]},t.AbstractElement.prototype.applyAttr=function(t,e){this.node.setAttribute(t,e)},t.AbstractElement.prototype.remove=function(){t.$(this.node).remove()},t.AbstractCanvasElement=function(e,a,s){this.container=e,this.setSize(a,s),this.rootElement=new t[this.classPrefix+"GroupElement"],this.node.appendChild(this.rootElement.node),this.container.appendChild(this.node)},t.AbstractCanvasElement.prototype.add=function(t,e){(e=e||this.rootElement).add(t),t.canvas=this},t.AbstractCanvasElement.prototype.addPath=function(e,a,s){var i=new t[this.classPrefix+"PathElement"](e,a);return this.add(i,s),i},t.AbstractCanvasElement.prototype.addCircle=function(e,a,s){var i=new t[this.classPrefix+"CircleElement"](e,a);return this.add(i,s),i},t.AbstractCanvasElement.prototype.addImage=function(e,a,s){var i=new t[this.classPrefix+"ImageElement"](e,a);return this.add(i,s),i},t.AbstractCanvasElement.prototype.addText=function(e,a,s){var i=new t[this.classPrefix+"TextElement"](e,a);return this.add(i,s),i},t.AbstractCanvasElement.prototype.addGroup=function(e){var a=new t[this.classPrefix+"GroupElement"];return e?e.node.appendChild(a.node):this.node.appendChild(a.node),a.canvas=this,a},t.AbstractShapeElement=function(t,e,a){this.style=a||{},this.style.current=this.style.current||{},this.isHovered=!1,this.isSelected=!1,this.updateStyle()},t.AbstractShapeElement.prototype.setStyle=function(e,a){var s={};"object"==typeof e?s=e:s[e]=a,t.$.extend(this.style.current,s),this.updateStyle()},t.AbstractShapeElement.prototype.updateStyle=function(){var e={};t.AbstractShapeElement.mergeStyles(e,this.style.initial),t.AbstractShapeElement.mergeStyles(e,this.style.current),this.isHovered&&t.AbstractShapeElement.mergeStyles(e,this.style.hover),this.isSelected&&(t.AbstractShapeElement.mergeStyles(e,this.style.selected),this.isHovered&&t.AbstractShapeElement.mergeStyles(e,this.style.selectedHover)),this.set(e)},t.AbstractShapeElement.mergeStyles=function(t,e){var a;for(a in e=e||{})null===e[a]?delete t[a]:t[a]=e[a]},t.SVGElement=function(e,a){t.SVGElement.parentClass.apply(this,arguments)},t.inherits(t.SVGElement,t.AbstractElement),t.SVGElement.svgns="http://www.w3.org/2000/svg",t.SVGElement.prototype.createElement=function(e){return document.createElementNS(t.SVGElement.svgns,e)},t.SVGElement.prototype.addClass=function(t){this.node.setAttribute("class",t)},t.SVGElement.prototype.getElementCtr=function(e){return t["SVG"+e]},t.SVGElement.prototype.getBBox=function(){return this.node.getBBox()},t.SVGGroupElement=function(){t.SVGGroupElement.parentClass.call(this,"g")},t.inherits(t.SVGGroupElement,t.SVGElement),t.SVGGroupElement.prototype.add=function(t){this.node.appendChild(t.node)},t.SVGCanvasElement=function(e,a,s){this.classPrefix="SVG",t.SVGCanvasElement.parentClass.call(this,"svg"),this.defsElement=new t.SVGElement("defs"),this.node.appendChild(this.defsElement.node),t.AbstractCanvasElement.apply(this,arguments)},t.inherits(t.SVGCanvasElement,t.SVGElement),t.mixin(t.SVGCanvasElement,t.AbstractCanvasElement),t.SVGCanvasElement.prototype.setSize=function(t,e){this.width=t,this.height=e,this.node.setAttribute("width",t),this.node.setAttribute("height",e)},t.SVGCanvasElement.prototype.applyTransformParams=function(t,e,a){this.scale=t,this.transX=e,this.transY=a,this.rootElement.node.setAttribute("transform","scale("+t+") translate("+e+", "+a+")")},t.SVGShapeElement=function(e,a,s){t.SVGShapeElement.parentClass.call(this,e,a),t.AbstractShapeElement.apply(this,arguments)},t.inherits(t.SVGShapeElement,t.SVGElement),t.mixin(t.SVGShapeElement,t.AbstractShapeElement),t.SVGShapeElement.prototype.applyAttr=function(e,a){var s,i,n=this;"fill"===e&&t.isImageUrl(a)?t.SVGShapeElement.images[a]?this.applyAttr("fill","url(#image"+t.SVGShapeElement.images[a]+")"):t.whenImageLoaded(a).then((function(e){(i=new t.SVGElement("image")).node.setAttributeNS("http://www.w3.org/1999/xlink","href",a),i.applyAttr("x","0"),i.applyAttr("y","0"),i.applyAttr("width",e[0].width),i.applyAttr("height",e[0].height),(s=new t.SVGElement("pattern")).applyAttr("id","image"+t.SVGShapeElement.imageCounter),s.applyAttr("x",0),s.applyAttr("y",0),s.applyAttr("width",e[0].width/2),s.applyAttr("height",e[0].height/2),s.applyAttr("viewBox","0 0 "+e[0].width+" "+e[0].height),s.applyAttr("patternUnits","userSpaceOnUse"),s.node.appendChild(i.node),n.canvas.defsElement.node.appendChild(s.node),t.SVGShapeElement.images[a]=t.SVGShapeElement.imageCounter++,n.applyAttr("fill","url(#image"+t.SVGShapeElement.images[a]+")")})):t.SVGShapeElement.parentClass.prototype.applyAttr.apply(this,arguments)},t.SVGShapeElement.imageCounter=1,t.SVGShapeElement.images={},t.SVGPathElement=function(e,a){t.SVGPathElement.parentClass.call(this,"path",e,a),this.node.setAttribute("fill-rule","evenodd")},t.inherits(t.SVGPathElement,t.SVGShapeElement),t.SVGCircleElement=function(e,a){t.SVGCircleElement.parentClass.call(this,"circle",e,a)},t.inherits(t.SVGCircleElement,t.SVGShapeElement),t.SVGImageElement=function(e,a){t.SVGImageElement.parentClass.call(this,"image",e,a)},t.inherits(t.SVGImageElement,t.SVGShapeElement),t.SVGImageElement.prototype.applyAttr=function(e,a){var s,i=this;"image"==e?("object"==typeof a?(s=a.url,this.offset=a.offset):(s=a,this.offset=[0,0]),t.whenImageLoaded(s).then((function(e){i.node.setAttributeNS("http://www.w3.org/1999/xlink","href",s),i.width=e[0].width,i.height=e[0].height,i.applyAttr("width",i.width),i.applyAttr("height",i.height),i.applyAttr("x",i.cx-i.width/2+i.offset[0]),i.applyAttr("y",i.cy-i.height/2+i.offset[1]),t.$(i.node).trigger("imageloaded",[e])}))):"cx"==e?(this.cx=a,this.width&&this.applyAttr("x",a-this.width/2+this.offset[0])):"cy"==e?(this.cy=a,this.height&&this.applyAttr("y",a-this.height/2+this.offset[1])):t.SVGImageElement.parentClass.prototype.applyAttr.apply(this,arguments)},t.SVGTextElement=function(e,a){t.SVGTextElement.parentClass.call(this,"text",e,a)},t.inherits(t.SVGTextElement,t.SVGShapeElement),t.SVGTextElement.prototype.applyAttr=function(e,a){"text"===e?this.node.textContent=a:t.SVGTextElement.parentClass.prototype.applyAttr.apply(this,arguments)},t.VMLElement=function(e,a){t.VMLElement.VMLInitialized||t.VMLElement.initializeVML(),t.VMLElement.parentClass.apply(this,arguments)},t.inherits(t.VMLElement,t.AbstractElement),t.VMLElement.VMLInitialized=!1,t.VMLElement.initializeVML=function(){try{document.namespaces.rvml||document.namespaces.add("rvml","urn:schemas-microsoft-com:vml"),t.VMLElement.prototype.createElement=function(t){return document.createElement("<rvml:"+t+' class="rvml">')}}catch(e){t.VMLElement.prototype.createElement=function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}document.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)"),t.VMLElement.VMLInitialized=!0},t.VMLElement.prototype.getElementCtr=function(e){return t["VML"+e]},t.VMLElement.prototype.addClass=function(e){t.$(this.node).addClass(e)},t.VMLElement.prototype.applyAttr=function(t,e){this.node[t]=e},t.VMLElement.prototype.getBBox=function(){var e=t.$(this.node);return{x:e.position().left/this.canvas.scale,y:e.position().top/this.canvas.scale,width:e.width()/this.canvas.scale,height:e.height()/this.canvas.scale}},t.VMLGroupElement=function(){t.VMLGroupElement.parentClass.call(this,"group"),this.node.style.left="0px",this.node.style.top="0px",this.node.coordorigin="0 0"},t.inherits(t.VMLGroupElement,t.VMLElement),t.VMLGroupElement.prototype.add=function(t){this.node.appendChild(t.node)},t.VMLCanvasElement=function(e,a,s){this.classPrefix="VML",t.VMLCanvasElement.parentClass.call(this,"group"),t.AbstractCanvasElement.apply(this,arguments),this.node.style.position="absolute"},t.inherits(t.VMLCanvasElement,t.VMLElement),t.mixin(t.VMLCanvasElement,t.AbstractCanvasElement),t.VMLCanvasElement.prototype.setSize=function(t,e){var a,s,i,n;if(this.width=t,this.height=e,this.node.style.width=t+"px",this.node.style.height=e+"px",this.node.coordsize=t+" "+e,this.node.coordorigin="0 0",this.rootElement){for(i=0,n=(a=this.rootElement.node.getElementsByTagName("shape")).length;i<n;i++)a[i].coordsize=t+" "+e,a[i].style.width=t+"px",a[i].style.height=e+"px";for(i=0,n=(s=this.node.getElementsByTagName("group")).length;i<n;i++)s[i].coordsize=t+" "+e,s[i].style.width=t+"px",s[i].style.height=e+"px"}},t.VMLCanvasElement.prototype.applyTransformParams=function(t,e,a){this.scale=t,this.transX=e,this.transY=a,this.rootElement.node.coordorigin=this.width-e-this.width/100+","+(this.height-a-this.height/100),this.rootElement.node.coordsize=this.width/t+","+this.height/t},t.VMLShapeElement=function(e,a){t.VMLShapeElement.parentClass.call(this,e,a),this.fillElement=new t.VMLElement("fill"),this.strokeElement=new t.VMLElement("stroke"),this.node.appendChild(this.fillElement.node),this.node.appendChild(this.strokeElement.node),this.node.stroked=!1,t.AbstractShapeElement.apply(this,arguments)},t.inherits(t.VMLShapeElement,t.VMLElement),t.mixin(t.VMLShapeElement,t.AbstractShapeElement),t.VMLShapeElement.prototype.applyAttr=function(e,a){switch(e){case"fill":this.node.fillcolor=a;break;case"fill-opacity":this.fillElement.node.opacity=Math.round(100*a)+"%";break;case"stroke":this.node.stroked="none"!==a,this.node.strokecolor=a;break;case"stroke-opacity":this.strokeElement.node.opacity=Math.round(100*a)+"%";break;case"stroke-width":0===parseInt(a,10)?this.node.stroked=!1:this.node.stroked=!0,this.node.strokeweight=a;break;case"d":this.node.path=t.VMLPathElement.pathSvgToVml(a);break;default:t.VMLShapeElement.parentClass.prototype.applyAttr.apply(this,arguments)}},t.VMLPathElement=function(e,a){var s=new t.VMLElement("skew");t.VMLPathElement.parentClass.call(this,"shape",e,a),this.node.coordorigin="0 0",s.node.on=!0,s.node.matrix="0.01,0,0,0.01,0,0",s.node.offset="0,0",this.node.appendChild(s.node)},t.inherits(t.VMLPathElement,t.VMLShapeElement),t.VMLPathElement.prototype.applyAttr=function(e,a){"d"===e?this.node.path=t.VMLPathElement.pathSvgToVml(a):t.VMLShapeElement.prototype.applyAttr.call(this,e,a)},t.VMLPathElement.pathSvgToVml=function(t){var e,a,s=0,i=0;return(t=t.replace(/(-?\d+)e(-?\d+)/g,"0")).replace(/([MmLlHhVvCcSs])\s*((?:-?\d*(?:\.\d+)?\s*,?\s*)+)/g,(function(t,n,r,o){(r=r.replace(/(\d)-/g,"$1,-").replace(/^\s+/g,"").replace(/\s+$/g,"").replace(/\s+/g,",").split(","))[0]||r.shift();for(var h=0,l=r.length;h<l;h++)r[h]=Math.round(100*r[h]);switch(n){case"m":return s+=r[0],i+=r[1],"t"+r.join(",");case"M":return s=r[0],i=r[1],"m"+r.join(",");case"l":return s+=r[0],i+=r[1],"r"+r.join(",");case"L":return s=r[0],i=r[1],"l"+r.join(",");case"h":return s+=r[0],"r"+r[0]+",0";case"H":return"l"+(s=r[0])+","+i;case"v":return i+=r[0],"r0,"+r[0];case"V":return i=r[0],"l"+s+","+i;case"c":return e=s+r[r.length-4],a=i+r[r.length-3],s+=r[r.length-2],i+=r[r.length-1],"v"+r.join(",");case"C":return e=r[r.length-4],a=r[r.length-3],s=r[r.length-2],i=r[r.length-1],"c"+r.join(",");case"s":return r.unshift(i-a),r.unshift(s-e),e=s+r[r.length-4],a=i+r[r.length-3],s+=r[r.length-2],i+=r[r.length-1],"v"+r.join(",");case"S":return r.unshift(i+i-a),r.unshift(s+s-e),e=r[r.length-4],a=r[r.length-3],s=r[r.length-2],i=r[r.length-1],"c"+r.join(",")}return""})).replace(/z/g,"e")},t.VMLCircleElement=function(e,a){t.VMLCircleElement.parentClass.call(this,"oval",e,a)},t.inherits(t.VMLCircleElement,t.VMLShapeElement),t.VMLCircleElement.prototype.applyAttr=function(e,a){switch(e){case"r":this.node.style.width=2*a+"px",this.node.style.height=2*a+"px",this.applyAttr("cx",this.get("cx")||0),this.applyAttr("cy",this.get("cy")||0);break;case"cx":if(!a)return;this.node.style.left=a-(this.get("r")||0)+"px";break;case"cy":if(!a)return;this.node.style.top=a-(this.get("r")||0)+"px";break;default:t.VMLCircleElement.parentClass.prototype.applyAttr.call(this,e,a)}},t.VMLImageElement=function(e,a){t.VMLImageElement.parentClass.call(this,"image",e,a)},t.inherits(t.VMLImageElement,t.VMLShapeElement),t.VMLImageElement.prototype.applyAttr=function(e,a){var s=this;"image"==e?t.whenImageLoaded(a).then((function(e){s.node.setAttribute("src",a),s.width=e[0].width,s.height=e[0].height,s.applyAttr("width",s.width),s.applyAttr("height",s.height),t.VMLImageElement.images[a]=t.VMLImageElement.imageCounter++,s.applyAttr("x",s.cx-s.width/2),s.applyAttr("y",s.cy-s.height/2),t.$(s.node).trigger("imageloaded",[e])})):"cx"==e?(this.cx=a,this.width&&this.applyAttr("x",a-this.width/2)):"cy"==e?(this.cy=a,this.height&&this.applyAttr("y",a-this.height/2)):"width"==e||"height"==e?this.node.style[e]=a+"px":"x"==e||"y"==e?this.node.style["x"==e?"left":"top"]=a+"px":t.VMLImageElement.parentClass.prototype.applyAttr.apply(this,arguments)},t.VMLImageElement.imageCounter=1,t.VMLImageElement.images={},t.VectorCanvas=function(e,a,s){return this.mode=window.SVGAngle?"svg":"vml","svg"==this.mode?this.impl=new t.SVGCanvasElement(e,a,s):this.impl=new t.VMLCanvasElement(e,a,s),this.impl.mode=this.mode,this.impl},t.SimpleScale=function(t){this.scale=t},t.SimpleScale.prototype.getValue=function(t){return t},t.OrdinalScale=function(t){this.scale=t},t.OrdinalScale.prototype.getValue=function(t){return this.scale[t]},t.OrdinalScale.prototype.getTicks=function(){var t,e=[];for(t in this.scale)e.push({label:t,value:this.scale[t]});return e},t.NumericScale=function(t,e,a,s){this.scale=[],e=e||"linear",t&&this.setScale(t),e&&this.setNormalizeFunction(e),void 0!==a&&this.setMin(a),void 0!==s&&this.setMax(s)},t.NumericScale.prototype={setMin:function(t){this.clearMinValue=t,"function"==typeof this.normalize?this.minValue=this.normalize(t):this.minValue=t},setMax:function(t){this.clearMaxValue=t,"function"==typeof this.normalize?this.maxValue=this.normalize(t):this.maxValue=t},setScale:function(t){var e;for(this.scale=[],e=0;e<t.length;e++)this.scale[e]=[t[e]]},setNormalizeFunction:function(t){"polynomial"===t?this.normalize=function(t){return Math.pow(t,.2)}:"linear"===t?delete this.normalize:this.normalize=t,this.setMin(this.clearMinValue),this.setMax(this.clearMaxValue)},getValue:function(t){var e,a,s=[],i=0,n=0;for("function"==typeof this.normalize&&(t=this.normalize(t)),n=0;n<this.scale.length-1;n++)e=this.vectorLength(this.vectorSubtract(this.scale[n+1],this.scale[n])),s.push(e),i+=e;for(a=(this.maxValue-this.minValue)/i,n=0;n<s.length;n++)s[n]*=a;for(n=0,t-=this.minValue;t-s[n]>=0;)t-=s[n],n++;return t=n==this.scale.length-1?this.vectorToNum(this.scale[n]):this.vectorToNum(this.vectorAdd(this.scale[n],this.vectorMult(this.vectorSubtract(this.scale[n+1],this.scale[n]),t/s[n])))},vectorToNum:function(t){var e,a=0;for(e=0;e<t.length;e++)a+=Math.round(t[e])*Math.pow(256,t.length-e-1);return a},vectorSubtract:function(t,e){var a,s=[];for(a=0;a<t.length;a++)s[a]=t[a]-e[a];return s},vectorAdd:function(t,e){var a,s=[];for(a=0;a<t.length;a++)s[a]=t[a]+e[a];return s},vectorMult:function(t,e){var a,s=[];for(a=0;a<t.length;a++)s[a]=t[a]*e;return s},vectorLength:function(t){var e,a=0;for(e=0;e<t.length;e++)a+=t[e]*t[e];return Math.sqrt(a)},getTicks:function(){var t,e,a=[this.clearMinValue,this.clearMaxValue],s=a[1]-a[0],i=Math.pow(10,Math.floor(Math.log(s/5)/Math.LN10)),n=5/s*i,r=[];for(n<=.15?i*=10:n<=.35?i*=5:n<=.75&&(i*=2),a[0]=Math.floor(a[0]/i)*i,a[1]=Math.ceil(a[1]/i)*i,t=a[0];t<=a[1];)e=t==a[0]?this.clearMinValue:t==a[1]?this.clearMaxValue:t,r.push({label:t,value:this.getValue(e)}),t+=i;return r}},t.ColorScale=function(e,a,s,i){t.ColorScale.parentClass.apply(this,arguments)},t.inherits(t.ColorScale,t.NumericScale),t.ColorScale.prototype.setScale=function(e){var a;for(a=0;a<e.length;a++)this.scale[a]=t.ColorScale.rgbToArray(e[a])},t.ColorScale.prototype.getValue=function(e){return t.ColorScale.numToRgb(t.ColorScale.parentClass.prototype.getValue.call(this,e))},t.ColorScale.arrayToRgb=function(t){var e,a,s="#";for(a=0;a<t.length;a++)s+=1==(e=t[a].toString(16)).length?"0"+e:e;return s},t.ColorScale.numToRgb=function(t){for(t=t.toString(16);t.length<6;)t="0"+t;return"#"+t},t.ColorScale.rgbToArray=function(t){return t=t.substr(1),[parseInt(t.substr(0,2),16),parseInt(t.substr(2,2),16),parseInt(t.substr(4,2),16)]},t.Legend=function(e){this.params=e||{},this.map=this.params.map,this.series=this.params.series,this.body=t.$("<div/>"),this.body.addClass("jvectormap-legend"),this.params.cssClass&&this.body.addClass(this.params.cssClass),e.vertical?this.map.legendCntVertical.append(this.body):this.map.legendCntHorizontal.append(this.body),this.render()},t.Legend.prototype.render=function(){var e,a,s,i,n=this.series.scale.getTicks(),r=t.$("<div/>").addClass("jvectormap-legend-inner");for(this.body.html(""),this.params.title&&this.body.append(t.$("<div/>").addClass("jvectormap-legend-title").html(this.params.title)),this.body.append(r),e=0;e<n.length;e++){switch(a=t.$("<div/>").addClass("jvectormap-legend-tick"),s=t.$("<div/>").addClass("jvectormap-legend-tick-sample"),this.series.params.attribute){case"fill":t.isImageUrl(n[e].value)?s.css("background","url("+n[e].value+")"):s.css("background",n[e].value);break;case"stroke":s.css("background",n[e].value);break;case"image":s.css("background","url("+("object"==typeof n[e].value?n[e].value.url:n[e].value)+") no-repeat center center");break;case"r":t.$("<div/>").css({"border-radius":n[e].value,border:this.map.params.markerStyle.initial["stroke-width"]+"px "+this.map.params.markerStyle.initial.stroke+" solid",width:2*n[e].value+"px",height:2*n[e].value+"px",background:this.map.params.markerStyle.initial.fill}).appendTo(s)}a.append(s),i=n[e].label,this.params.labelRender&&(i=this.params.labelRender(i)),a.append(t.$("<div>"+i+" </div>").addClass("jvectormap-legend-tick-text")),r.append(a)}r.append(t.$("<div/>").css("clear","both"))},t.DataSeries=function(e,a,s){var i;(e=e||{}).attribute=e.attribute||"fill",this.elements=a,this.params=e,this.map=s,e.attributes&&this.setAttributes(e.attributes),Array.isArray(e.scale)?(i="fill"===e.attribute||"stroke"===e.attribute?t.ColorScale:t.NumericScale,this.scale=new i(e.scale,e.normalizeFunction,e.min,e.max)):e.scale?this.scale=new t.OrdinalScale(e.scale):this.scale=new t.SimpleScale(e.scale),this.values=e.values||{},this.setValues(this.values),this.params.legend&&(this.legend=new t.Legend(t.$.extend({map:this.map,series:this},this.params.legend)))},t.DataSeries.prototype={setAttributes:function(t,e){var a,s=t;if("string"==typeof t)this.elements[t]&&this.elements[t].setStyle(this.params.attribute,e);else for(a in s)this.elements[a]&&this.elements[a].element.setStyle(this.params.attribute,s[a])},setValues:function(e){var a,s,i=-Number.MAX_VALUE,n=Number.MAX_VALUE,r={};if(this.scale instanceof t.OrdinalScale||this.scale instanceof t.SimpleScale)for(s in e)e[s]?r[s]=this.scale.getValue(e[s]):r[s]=this.elements[s].element.style.initial[this.params.attribute];else{if(void 0===this.params.min||void 0===this.params.max)for(s in e)(a=parseFloat(e[s]))>i&&(i=a),a<n&&(n=a);for(s in void 0===this.params.min?(this.scale.setMin(n),this.params.min=n):this.scale.setMin(this.params.min),void 0===this.params.max?(this.scale.setMax(i),this.params.max=i):this.scale.setMax(this.params.max),e)"indexOf"!=s&&(a=parseFloat(e[s]),isNaN(a)?r[s]=this.elements[s].element.style.initial[this.params.attribute]:r[s]=this.scale.getValue(a))}this.setAttributes(r),t.$.extend(this.values,e)},clear:function(){var t,e={};for(t in this.values)this.elements[t]&&(e[t]=this.elements[t].element.shape.style.initial[this.params.attribute]);this.setAttributes(e),this.values={}},setScale:function(t){this.scale.setScale(t),this.values&&this.setValues(this.values)},setNormalizeFunction:function(t){this.scale.setNormalizeFunction(t),this.values&&this.setValues(this.values)}},t.Proj={degRad:180/Math.PI,radDeg:Math.PI/180,radius:6381372,sgn:function(t){return t>0?1:t<0?-1:t},mill:function(t,e,a){return{x:this.radius*(e-a)*this.radDeg,y:-this.radius*Math.log(Math.tan((45+.4*t)*this.radDeg))/.8}},mill_inv:function(t,e,a){return{lat:(2.5*Math.atan(Math.exp(.8*e/this.radius))-5*Math.PI/8)*this.degRad,lng:(a*this.radDeg+t/this.radius)*this.degRad}},merc:function(t,e,a){return{x:this.radius*(e-a)*this.radDeg,y:-this.radius*Math.log(Math.tan(Math.PI/4+t*Math.PI/360))}},merc_inv:function(t,e,a){return{lat:(2*Math.atan(Math.exp(e/this.radius))-Math.PI/2)*this.degRad,lng:(a*this.radDeg+t/this.radius)*this.degRad}},aea:function(t,e,a){var s=a*this.radDeg,i=29.5*this.radDeg,n=45.5*this.radDeg,r=t*this.radDeg,o=e*this.radDeg,h=(Math.sin(i)+Math.sin(n))/2,l=Math.cos(i)*Math.cos(i)+2*h*Math.sin(i),c=h*(o-s),p=Math.sqrt(l-2*h*Math.sin(r))/h,d=Math.sqrt(l-2*h*Math.sin(0))/h;return{x:p*Math.sin(c)*this.radius,y:-(d-p*Math.cos(c))*this.radius}},aea_inv:function(t,e,a){var s=t/this.radius,i=e/this.radius,n=a*this.radDeg,r=29.5*this.radDeg,o=45.5*this.radDeg,h=(Math.sin(r)+Math.sin(o))/2,l=Math.cos(r)*Math.cos(r)+2*h*Math.sin(r),c=Math.sqrt(l-2*h*Math.sin(0))/h,p=Math.sqrt(s*s+(c-i)*(c-i)),d=Math.atan(s/(c-i));return{lat:Math.asin((l-p*p*h*h)/(2*h))*this.degRad,lng:(n+d/h)*this.degRad}},lcc:function(t,e,a){var s=a*this.radDeg,i=e*this.radDeg,n=33*this.radDeg,r=45*this.radDeg,o=t*this.radDeg,h=Math.log(Math.cos(n)*(1/Math.cos(r)))/Math.log(Math.tan(Math.PI/4+r/2)*(1/Math.tan(Math.PI/4+n/2))),l=Math.cos(n)*Math.pow(Math.tan(Math.PI/4+n/2),h)/h,c=l*Math.pow(1/Math.tan(Math.PI/4+o/2),h),p=l*Math.pow(1/Math.tan(Math.PI/4+0),h);return{x:c*Math.sin(h*(i-s))*this.radius,y:-(p-c*Math.cos(h*(i-s)))*this.radius}},lcc_inv:function(t,e,a){var s=t/this.radius,i=e/this.radius,n=a*this.radDeg,r=33*this.radDeg,o=45*this.radDeg,h=Math.log(Math.cos(r)*(1/Math.cos(o)))/Math.log(Math.tan(Math.PI/4+o/2)*(1/Math.tan(Math.PI/4+r/2))),l=Math.cos(r)*Math.pow(Math.tan(Math.PI/4+r/2),h)/h,c=l*Math.pow(1/Math.tan(Math.PI/4+0),h),p=this.sgn(h)*Math.sqrt(s*s+(c-i)*(c-i)),d=Math.atan(s/(c-i));return{lat:(2*Math.atan(Math.pow(l/p,1/h))-Math.PI/2)*this.degRad,lng:(n+d/h)*this.degRad}}},t.MapObject=function(t){},t.MapObject.prototype.getLabelText=function(t){return this.config.label?"function"==typeof this.config.label.render?this.config.label.render(t):t:null},t.MapObject.prototype.getLabelOffsets=function(t){var e;return this.config.label&&("function"==typeof this.config.label.offsets?e=this.config.label.offsets(t):"object"==typeof this.config.label.offsets&&(e=this.config.label.offsets[t])),e||[0,0]},t.MapObject.prototype.setHovered=function(t){this.isHovered!==t&&(this.isHovered=t,this.shape.isHovered=t,this.shape.updateStyle(),this.label&&(this.label.isHovered=t,this.label.updateStyle()))},t.MapObject.prototype.setSelected=function(e){this.isSelected!==e&&(this.isSelected=e,this.shape.isSelected=e,this.shape.updateStyle(),this.label&&(this.label.isSelected=e,this.label.updateStyle()),t.$(this.shape).trigger("selected",[e]))},t.MapObject.prototype.setStyle=function(){this.shape.setStyle.apply(this.shape,arguments)},t.MapObject.prototype.remove=function(){this.shape.remove(),this.label&&this.label.remove()},t.Region=function(t){var e,a,s,i;this.config=t,this.map=this.config.map,i=t.canvas.addGroup(t.canvas.rootElement),this.shape=t.canvas.addPath({d:t.path},t.style,i),t.canvas.addPath({d:t.path,"data-code":t.code},{initial:{fill:"transparent",stroke:"transparent","stroke-width":t.margin}},i).addClass("jvectormap-region jvectormap-element"),e=this.shape.getBBox(),a=this.getLabelText(t.code),this.config.label&&a&&(s=this.getLabelOffsets(t.code),this.labelX=e.x+e.width/2+s[0],this.labelY=e.y+e.height/2+s[1],this.label=t.canvas.addText({text:a,"text-anchor":"middle","alignment-baseline":"central",x:this.labelX,y:this.labelY,"data-code":t.code},t.labelStyle,t.labelsGroup),this.label.addClass("jvectormap-region jvectormap-element"))},t.inherits(t.Region,t.MapObject),t.Region.prototype.updateLabelPosition=function(){this.label&&this.label.set({x:this.labelX*this.map.scale+this.map.transX*this.map.scale,y:this.labelY*this.map.scale+this.map.transY*this.map.scale})},t.Marker=function(t){var e;this.config=t,this.map=this.config.map,this.isImage=!!this.config.style.initial.image,this.createShape(),e=this.getLabelText(t.index),this.config.label&&e&&(this.offsets=this.getLabelOffsets(t.index),this.labelX=t.cx/this.map.scale-this.map.transX,this.labelY=t.cy/this.map.scale-this.map.transY,this.label=t.canvas.addText({text:e,"data-index":t.index,dy:"0.6ex",x:this.labelX,y:this.labelY},t.labelStyle,t.labelsGroup),this.label.addClass("jvectormap-marker jvectormap-element"))},t.inherits(t.Marker,t.MapObject),t.Marker.prototype.createShape=function(){var e=this;this.shape&&this.shape.remove(),this.shape=this.config.canvas[this.isImage?"addImage":"addCircle"]({"data-index":this.config.index,cx:this.config.cx,cy:this.config.cy},this.config.style,this.config.group),this.shape.addClass("jvectormap-marker jvectormap-element"),this.isImage&&t.$(this.shape.node).on("imageloaded",(function(){e.updateLabelPosition()}))},t.Marker.prototype.updateLabelPosition=function(){this.label&&this.label.set({x:this.labelX*this.map.scale+this.offsets[0]+this.map.transX*this.map.scale+5+(this.isImage?(this.shape.width||0)/2:this.shape.properties.r),y:this.labelY*this.map.scale+this.map.transY*this.map.scale+this.offsets[1]})},t.Marker.prototype.setStyle=function(e,a){var s;t.Marker.parentClass.prototype.setStyle.apply(this,arguments),"r"===e&&this.updateLabelPosition(),(s=!!this.shape.get("image"))!=this.isImage&&(this.isImage=s,this.config.style=t.$.extend(!0,{},this.shape.style),this.createShape())},t.Map=function(e){var a,s=this;if(this.params=t.$.extend(!0,{},t.Map.defaultParams,e),!t.Map.maps[this.params.map])throw new Error("Attempt to use map which was not loaded: "+this.params.map);for(a in this.mapData=t.Map.maps[this.params.map],this.markers={},this.regions={},this.regionsColors={},this.regionsData={},this.container=t.$("<div>").addClass("jvectormap-container"),this.params.container&&this.params.container.append(this.container),this.container.data("mapObject",this),this.defaultWidth=this.mapData.width,this.defaultHeight=this.mapData.height,this.setBackgroundColor(this.params.backgroundColor),this.onResize=function(){s.updateSize()},t.$(window).resize(this.onResize),t.Map.apiEvents)this.params[a]&&this.container.bind(t.Map.apiEvents[a]+".jvectormap",this.params[a]);this.canvas=new t.VectorCanvas(this.container[0],this.width,this.height),this.params.bindTouchEvents&&("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch?this.bindContainerTouchEvents():window.MSGesture&&this.bindContainerPointerEvents()),this.bindContainerEvents(),this.bindElementEvents(),this.createTip(),this.params.zoomButtons&&this.bindZoomButtons(),this.createRegions(),this.createMarkers(this.params.markers||{}),this.updateSize(),this.params.focusOn&&("string"==typeof this.params.focusOn?this.params.focusOn={region:this.params.focusOn}:Array.isArray(this.params.focusOn)&&(this.params.focusOn={regions:this.params.focusOn}),this.setFocus(this.params.focusOn)),this.params.selectedRegions&&this.setSelectedRegions(this.params.selectedRegions),this.params.selectedMarkers&&this.setSelectedMarkers(this.params.selectedMarkers),this.legendCntHorizontal=t.$("<div/>").addClass("jvectormap-legend-cnt jvectormap-legend-cnt-h"),this.legendCntVertical=t.$("<div/>").addClass("jvectormap-legend-cnt jvectormap-legend-cnt-v"),this.container.append(this.legendCntHorizontal),this.container.append(this.legendCntVertical),this.params.series&&this.createSeries()},t.Map.prototype={transX:0,transY:0,scale:1,baseTransX:0,baseTransY:0,baseScale:1,width:0,height:0,setBackgroundColor:function(t){this.container.css("background-color",t)},resize:function(){var t=this.baseScale;this.width/this.height>this.defaultWidth/this.defaultHeight?(this.baseScale=this.height/this.defaultHeight,this.baseTransX=Math.abs(this.width-this.defaultWidth*this.baseScale)/(2*this.baseScale)):(this.baseScale=this.width/this.defaultWidth,this.baseTransY=Math.abs(this.height-this.defaultHeight*this.baseScale)/(2*this.baseScale)),this.scale*=this.baseScale/t,this.transX*=this.baseScale/t,this.transY*=this.baseScale/t},updateSize:function(){this.width=this.container.width(),this.height=this.container.height(),this.resize(),this.canvas.setSize(this.width,this.height),this.applyTransform()},reset:function(){var t,e;for(t in this.series)for(e=0;e<this.series[t].length;e++)this.series[t][e].clear();this.scale=this.baseScale,this.transX=this.baseTransX,this.transY=this.baseTransY,this.applyTransform()},applyTransform:function(){var t,e,a,s;this.defaultWidth*this.scale<=this.width?(t=(this.width-this.defaultWidth*this.scale)/(2*this.scale),a=(this.width-this.defaultWidth*this.scale)/(2*this.scale)):(t=0,a=(this.width-this.defaultWidth*this.scale)/this.scale),this.defaultHeight*this.scale<=this.height?(e=(this.height-this.defaultHeight*this.scale)/(2*this.scale),s=(this.height-this.defaultHeight*this.scale)/(2*this.scale)):(e=0,s=(this.height-this.defaultHeight*this.scale)/this.scale),this.transY>e?this.transY=e:this.transY<s&&(this.transY=s),this.transX>t?this.transX=t:this.transX<a&&(this.transX=a),this.canvas.applyTransformParams(this.scale,this.transX,this.transY),this.markers&&this.repositionMarkers(),this.repositionLabels(),this.container.trigger("viewportChange",[this.scale/this.baseScale,this.transX,this.transY])},bindContainerEvents:function(){var e,a,s=!1,i=this;this.params.panOnDrag&&(this.container.mousemove((function(t){return s&&(i.transX-=(e-t.pageX)/i.scale,i.transY-=(a-t.pageY)/i.scale,i.applyTransform(),e=t.pageX,a=t.pageY),!1})).mousedown((function(t){return s=!0,e=t.pageX,a=t.pageY,!1})),this.onContainerMouseUp=function(){s=!1},t.$("body").mouseup(this.onContainerMouseUp)),this.params.zoomOnScroll&&this.container.mousewheel((function(e,a,s,n){var r=t.$(i.container).offset(),o=e.pageX-r.left,h=e.pageY-r.top,l=Math.pow(1+i.params.zoomOnScrollSpeed/1e3,e.deltaFactor*e.deltaY);i.tip.hide(),i.setScale(i.scale*l,o,h),e.preventDefault()}))},bindContainerTouchEvents:function(){var e,a,s,i,n,r,o,h=this,l=function(l){var c,p,d,m,u=l.originalEvent.touches;"touchstart"==l.type&&(o=0),1==u.length?(1==o&&(d=h.transX,m=h.transY,h.transX-=(s-u[0].pageX)/h.scale,h.transY-=(i-u[0].pageY)/h.scale,h.applyTransform(),h.tip.hide(),d==h.transX&&m==h.transY||l.preventDefault()),s=u[0].pageX,i=u[0].pageY):2==u.length&&(2==o?(p=Math.sqrt(Math.pow(u[0].pageX-u[1].pageX,2)+Math.pow(u[0].pageY-u[1].pageY,2))/a,h.setScale(e*p,n,r),h.tip.hide(),l.preventDefault()):(c=t.$(h.container).offset(),n=u[0].pageX>u[1].pageX?u[1].pageX+(u[0].pageX-u[1].pageX)/2:u[0].pageX+(u[1].pageX-u[0].pageX)/2,r=u[0].pageY>u[1].pageY?u[1].pageY+(u[0].pageY-u[1].pageY)/2:u[0].pageY+(u[1].pageY-u[0].pageY)/2,n-=c.left,r-=c.top,e=h.scale,a=Math.sqrt(Math.pow(u[0].pageX-u[1].pageX,2)+Math.pow(u[0].pageY-u[1].pageY,2)))),o=u.length};t.$(this.container).bind("touchstart",l),t.$(this.container).bind("touchmove",l)},bindContainerPointerEvents:function(){var t=this,e=new MSGesture,a=this.container[0];e.target=a,a.addEventListener("MSGestureChange",(function(e){var a,s;0==e.translationX&&0==e.translationY||(a=t.transX,s=t.transY,t.transX+=e.translationX/t.scale,t.transY+=e.translationY/t.scale,t.applyTransform(),t.tip.hide(),a==t.transX&&s==t.transY||e.preventDefault()),1!=e.scale&&(t.setScale(t.scale*e.scale,e.offsetX,e.offsetY),t.tip.hide(),e.preventDefault())}),!1),a.addEventListener("pointerdown",(function(t){e.addPointer(t.pointerId)}),!1)},bindElementEvents:function(){var e,a,s,i=this;this.container.mousemove((function(t){Math.abs(e-t.pageX)+Math.abs(a-t.pageY)>2&&(s=!0)})),this.container.delegate("[class~='jvectormap-element']","mouseover mouseout",(function(e){var a=-1===(t.$(this).attr("class").baseVal||t.$(this).attr("class")).indexOf("jvectormap-region")?"marker":"region",s="region"==a?t.$(this).attr("data-code"):t.$(this).attr("data-index"),n="region"==a?i.regions[s].element:i.markers[s].element,r="region"==a?i.mapData.paths[s].name:i.markers[s].config.name||"",o=t.$.Event(a+"TipShow.jvectormap"),h=t.$.Event(a+"Over.jvectormap");"mouseover"==e.type?(i.container.trigger(h,[s]),h.isDefaultPrevented()||n.setHovered(!0),i.tip.text(r),i.container.trigger(o,[i.tip,s]),o.isDefaultPrevented()||(i.tip.show(),i.tipWidth=i.tip.width(),i.tipHeight=i.tip.height())):(n.setHovered(!1),i.tip.hide(),i.container.trigger(a+"Out.jvectormap",[s]))})),this.container.delegate("[class~='jvectormap-element']","mousedown",(function(t){e=t.pageX,a=t.pageY,s=!1})),this.container.delegate("[class~='jvectormap-element']","mouseup",(function(){var e=-1===(t.$(this).attr("class").baseVal?t.$(this).attr("class").baseVal:t.$(this).attr("class")).indexOf("jvectormap-region")?"marker":"region",a="region"==e?t.$(this).attr("data-code"):t.$(this).attr("data-index"),n=t.$.Event(e+"Click.jvectormap"),r="region"==e?i.regions[a].element:i.markers[a].element;s||(i.container.trigger(n,[a]),("region"===e&&i.params.regionsSelectable||"marker"===e&&i.params.markersSelectable)&&(n.isDefaultPrevented()||(i.params[e+"sSelectableOne"]&&i.clearSelected(e+"s"),r.setSelected(!r.isSelected))))}))},bindZoomButtons:function(){var e=this;t.$("<div/>").addClass("jvectormap-zoomin").text("+").appendTo(this.container),t.$("<div/>").addClass("jvectormap-zoomout").html("−").appendTo(this.container),this.container.find(".jvectormap-zoomin").click((function(){e.setScale(e.scale*e.params.zoomStep,e.width/2,e.height/2,!1,e.params.zoomAnimate)})),this.container.find(".jvectormap-zoomout").click((function(){e.setScale(e.scale/e.params.zoomStep,e.width/2,e.height/2,!1,e.params.zoomAnimate)}))},createTip:function(){var e=this;t.$("body > .jvectormap-tip").remove(),this.tip=t.$("<div/>").addClass("jvectormap-tip").appendTo(t.$("body")),this.container.mousemove((function(t){var a=t.pageX-15-e.tipWidth,s=t.pageY-15-e.tipHeight;a<5&&(a=t.pageX+15),s<5&&(s=t.pageY+15),e.tip.css({left:a,top:s})}))},setScale:function(e,a,s,i,n){var r,o,h,l,c,p,d,m,u,g=t.$.Event("zoom.jvectormap"),f=this,v=0,y=Math.abs(Math.round(60*(e-this.scale)/Math.max(e,this.scale))),M=new t.$.Deferred;if(e>this.params.zoomMax*this.baseScale?e=this.params.zoomMax*this.baseScale:e<this.params.zoomMin*this.baseScale&&(e=this.params.zoomMin*this.baseScale),void 0!==a&&void 0!==s){var S=e/this.scale;i?(m=a+this.defaultWidth*(this.width/(this.defaultWidth*e))/2,u=s+this.defaultHeight*(this.height/(this.defaultHeight*e))/2):(m=this.transX-(S-1)/e*a,u=this.transY-(S-1)/e*s)}return n&&y>0?(o=this.scale,h=(e-o)/y,l=this.transX*this.scale,p=this.transY*this.scale,c=(m*e-l)/y,d=(u*e-p)/y,r=setInterval((function(){v+=1,f.scale=o+h*v,f.transX=(l+c*v)/f.scale,f.transY=(p+d*v)/f.scale,f.applyTransform(),v==y&&(clearInterval(r),f.container.trigger(g,[e/f.baseScale]),M.resolve())}),10)):(this.transX=m,this.transY=u,this.scale=e,this.applyTransform(),this.container.trigger(g,[e/this.baseScale]),M.resolve()),M},setFocus:function(t){var e,a,s,i,n;if((t=t||{}).region?s=[t.region]:t.regions&&(s=t.regions),s){for(i=0;i<s.length;i++)this.regions[s[i]]&&(a=this.regions[s[i]].element.shape.getBBox())&&(e=void 0===e?a:{x:Math.min(e.x,a.x),y:Math.min(e.y,a.y),width:Math.max(e.x+e.width,a.x+a.width)-Math.min(e.x,a.x),height:Math.max(e.y+e.height,a.y+a.height)-Math.min(e.y,a.y)});return this.setScale(Math.min(this.width/e.width,this.height/e.height),-(e.x+e.width/2),-(e.y+e.height/2),!0,t.animate)}return void 0!==t.lat&&void 0!==t.lng?(n=this.latLngToPoint(t.lat,t.lng),t.x=this.transX-n.x/this.scale,t.y=this.transY-n.y/this.scale):t.x&&t.y&&(t.x*=-this.defaultWidth,t.y*=-this.defaultHeight),this.setScale(t.scale*this.baseScale,t.x,t.y,!0,t.animate)},getSelected:function(t){var e,a=[];for(e in this[t])this[t][e].element.isSelected&&a.push(e);return a},getSelectedRegions:function(){return this.getSelected("regions")},getSelectedMarkers:function(){return this.getSelected("markers")},setSelected:function(t,e){var a;if("object"!=typeof e&&(e=[e]),Array.isArray(e))for(a=0;a<e.length;a++)this[t][e[a]].element.setSelected(!0);else for(a in e)this[t][a].element.setSelected(!!e[a])},setSelectedRegions:function(t){this.setSelected("regions",t)},setSelectedMarkers:function(t){this.setSelected("markers",t)},clearSelected:function(t){var e,a={},s=this.getSelected(t);for(e=0;e<s.length;e++)a[s[e]]=!1;this.setSelected(t,a)},clearSelectedRegions:function(){this.clearSelected("regions")},clearSelectedMarkers:function(){this.clearSelected("markers")},getMapObject:function(){return this},getRegionName:function(t){return this.mapData.paths[t].name},createRegions:function(){var e,a,s=this;for(e in this.regionLabelsGroup=this.regionLabelsGroup||this.canvas.addGroup(),this.mapData.paths)a=new t.Region({map:this,path:this.mapData.paths[e].path,code:e,style:t.$.extend(!0,{},this.params.regionStyle),margin:this.params.regionMargin,labelStyle:t.$.extend(!0,{},this.params.regionLabelStyle),canvas:this.canvas,labelsGroup:this.regionLabelsGroup,label:"vml"!=this.canvas.mode?this.params.labels&&this.params.labels.regions:null}),t.$(a.shape).bind("selected",(function(e,a){s.container.trigger("regionSelected.jvectormap",[t.$(this.node).attr("data-code"),a,s.getSelectedRegions()])})),this.regions[e]={element:a,config:this.mapData.paths[e]}},createMarkers:function(e){var a,s,i,n,r,o=this;if(this.markersGroup=this.markersGroup||this.canvas.addGroup(),this.markerLabelsGroup=this.markerLabelsGroup||this.canvas.addGroup(),Array.isArray(e))for(r=e.slice(),e={},a=0;a<r.length;a++)e[a]=r[a];for(a in e)n=e[a]instanceof Array?{latLng:e[a]}:e[a],!1!==(i=this.getMarkerPosition(n))&&(s=new t.Marker({map:this,style:t.$.extend(!0,{},this.params.markerStyle,{initial:n.style||{}}),labelStyle:t.$.extend(!0,{},this.params.markerLabelStyle),index:a,cx:i.x,cy:i.y,group:this.markersGroup,canvas:this.canvas,labelsGroup:this.markerLabelsGroup,label:"vml"!=this.canvas.mode?this.params.labels&&this.params.labels.markers:null}),t.$(s.shape).bind("selected",(function(e,a){o.container.trigger("markerSelected.jvectormap",[t.$(this.node).attr("data-index"),a,o.getSelectedMarkers()])})),this.markers[a]&&this.removeMarkers([a]),this.markers[a]={element:s,config:n})},repositionMarkers:function(){var t,e;for(t in this.markers)!1!==(e=this.getMarkerPosition(this.markers[t].config))&&this.markers[t].element.setStyle({cx:e.x,cy:e.y})},repositionLabels:function(){var t;for(t in this.regions)this.regions[t].element.updateLabelPosition();for(t in this.markers)this.markers[t].element.updateLabelPosition()},getMarkerPosition:function(e){return t.Map.maps[this.params.map].projection?this.latLngToPoint.apply(this,e.latLng||[0,0]):{x:e.coords[0]*this.scale+this.transX*this.scale,y:e.coords[1]*this.scale+this.transY*this.scale}},addMarker:function(t,e,a){var s,i,n={},r=[];a=a||[];for(n[t]=e,i=0;i<a.length;i++)s={},void 0!==a[i]&&(s[t]=a[i]),r.push(s);this.addMarkers(n,r)},addMarkers:function(t,e){var a;for(e=e||[],this.createMarkers(t),a=0;a<e.length;a++)this.series.markers[a].setValues(e[a]||{})},removeMarkers:function(t){var e;for(e=0;e<t.length;e++)this.markers[t[e]].element.remove(),delete this.markers[t[e]]},removeAllMarkers:function(){var t,e=[];for(t in this.markers)e.push(t);this.removeMarkers(e)},latLngToPoint:function(e,a){var s,i,n,r=t.Map.maps[this.params.map].projection,o=r.centralMeridian;return a<-180+o&&(a+=360),s=t.Proj[r.type](e,a,o),!!(i=this.getInsetForPoint(s.x,s.y))&&(n=i.bbox,s.x=(s.x-n[0].x)/(n[1].x-n[0].x)*i.width*this.scale,s.y=(s.y-n[0].y)/(n[1].y-n[0].y)*i.height*this.scale,{x:s.x+this.transX*this.scale+i.left*this.scale,y:s.y+this.transY*this.scale+i.top*this.scale})},pointToLatLng:function(e,a){var s,i,n,r,o,h=t.Map.maps[this.params.map].projection,l=h.centralMeridian,c=t.Map.maps[this.params.map].insets;for(s=0;s<c.length;s++)if(n=(i=c[s]).bbox,r=e-(this.transX*this.scale+i.left*this.scale),o=a-(this.transY*this.scale+i.top*this.scale),r=r/(i.width*this.scale)*(n[1].x-n[0].x)+n[0].x,o=o/(i.height*this.scale)*(n[1].y-n[0].y)+n[0].y,r>n[0].x&&r<n[1].x&&o>n[0].y&&o<n[1].y)return t.Proj[h.type+"_inv"](r,-o,l);return!1},getInsetForPoint:function(e,a){var s,i,n=t.Map.maps[this.params.map].insets;for(s=0;s<n.length;s++)if(e>(i=n[s].bbox)[0].x&&e<i[1].x&&a>i[0].y&&a<i[1].y)return n[s]},createSeries:function(){var e,a;for(a in this.series={markers:[],regions:[]},this.params.series)for(e=0;e<this.params.series[a].length;e++)this.series[a][e]=new t.DataSeries(this.params.series[a][e],this[a],this)},remove:function(){this.tip.remove(),this.container.remove(),t.$(window).unbind("resize",this.onResize),t.$("body").unbind("mouseup",this.onContainerMouseUp)}},t.Map.maps={},t.Map.defaultParams={map:"world_mill_en",backgroundColor:"#505050",zoomButtons:!0,zoomOnScroll:!0,zoomOnScrollSpeed:3,panOnDrag:!0,zoomMax:8,zoomMin:1,zoomStep:1.6,zoomAnimate:!0,regionsSelectable:!1,markersSelectable:!1,bindTouchEvents:!0,regionStyle:{initial:{fill:"white","fill-opacity":1,stroke:"none","stroke-width":0,"stroke-opacity":1},hover:{"fill-opacity":.8,cursor:"pointer"},selected:{fill:"yellow"},selectedHover:{}},regionMargin:0,regionLabelStyle:{initial:{"font-family":"Verdana","font-size":"12","font-weight":"bold",cursor:"default",fill:"black"},hover:{cursor:"pointer"}},markerStyle:{initial:{fill:"grey",stroke:"#505050","fill-opacity":1,"stroke-width":1,"stroke-opacity":1,r:5},hover:{stroke:"black","stroke-width":2,cursor:"pointer"},selected:{fill:"blue"},selectedHover:{}},markerLabelStyle:{initial:{"font-family":"Verdana","font-size":"12","font-weight":"bold",cursor:"default",fill:"black"},hover:{cursor:"pointer"}}},t.Map.apiEvents={onRegionTipShow:"regionTipShow",onRegionOver:"regionOver",onRegionOut:"regionOut",onRegionClick:"regionClick",onRegionSelected:"regionSelected",onMarkerTipShow:"markerTipShow",onMarkerOver:"markerOver",onMarkerOut:"markerOut",onMarkerClick:"markerClick",onMarkerSelected:"markerSelected",onViewportChange:"viewportChange"},t.MultiMap=function(e){var a=this;this.maps={},this.params=t.$.extend(!0,{},t.MultiMap.defaultParams,e),this.params.maxLevel=this.params.maxLevel||Number.MAX_VALUE,this.params.main=this.params.main||{},this.params.main.multiMapLevel=0,this.history=[this.addMap(this.params.main.map,this.params.main)],this.defaultProjection=this.history[0].mapData.projection.type,this.mapsLoaded={},this.params.container.css({position:"relative"}),this.backButton=t.$("<div/>").addClass("jvectormap-goback").text("Back").appendTo(this.params.container),this.backButton.hide(),this.backButton.click((function(){a.goBack()})),this.spinner=t.$("<div/>").addClass("jvectormap-spinner").appendTo(this.params.container),this.spinner.hide()},t.MultiMap.prototype={addMap:function(e,a){var s=t.$("<div/>").css({width:"100%",height:"100%"});return this.params.container.append(s),this.maps[e]=new t.Map(t.$.extend(a,{container:s})),this.params.maxLevel>a.multiMapLevel&&this.maps[e].container.on("regionClick.jvectormap",{scope:this},(function(t,e){var a=t.data.scope,s=a.params.mapNameByCode(e,a);a.drillDownPromise&&"pending"===a.drillDownPromise.state()||a.drillDown(s,e)})),this.maps[e]},downloadMap:function(e){var a=this,s=t.$.Deferred();return this.mapsLoaded[e]?s.resolve():t.$.get(this.params.mapUrlByCode(e,this)).then((function(){a.mapsLoaded[e]=!0,s.resolve()}),(function(){s.reject()})),s},drillDown:function(e,a){var s=this.history[this.history.length-1],i=this,n=s.setFocus({region:a,animate:!0}),r=this.downloadMap(a);n.then((function(){"pending"===r.state()&&i.spinner.show()})),r.always((function(){i.spinner.hide()})),this.drillDownPromise=t.$.when(r,n),this.drillDownPromise.then((function(){s.params.container.hide(),i.maps[e]?i.maps[e].params.container.show():i.addMap(e,{map:e,multiMapLevel:s.params.multiMapLevel+1}),i.history.push(i.maps[e]),i.backButton.show()}))},goBack:function(){var t=this.history.pop(),e=this.history[this.history.length-1],a=this;t.setFocus({scale:1,x:.5,y:.5,animate:!0}).then((function(){t.params.container.hide(),e.params.container.show(),e.updateSize(),1===a.history.length&&a.backButton.hide(),e.setFocus({scale:1,x:.5,y:.5,animate:!0})}))}},t.MultiMap.defaultParams={mapNameByCode:function(t,e){return t.toLowerCase()+"_"+e.defaultProjection+"_en"},mapUrlByCode:function(t,e){return"jquery-jvectormap-data-"+t.toLowerCase()+"-"+e.defaultProjection+"-en.js"}},"undefined"!=typeof globalThis?globalThis.jvm=t:"undefined"!=typeof window&&(window.jvm=t);var s="undefined"!=typeof globalThis?globalThis.jQuery:"undefined"!=typeof window?window.jQuery:"undefined"!=typeof jQuery?jQuery:void 0;return"function"==typeof s&&s.fn&&a(s),a}));
//# sourceMappingURL=jquery-jvectormap.min.js.map