Guest User

Untitled

a guest
Apr 12th, 2013
2,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * jVectorMap version 1.1
  3.  *
  4.  * Copyright 2011-2012, Kirill Lebedev
  5.  * Licensed under the MIT license.
  6.  *
  7.  */
  8. (function (e) {
  9.     var t = {
  10.         set : {
  11.             colors : 1,
  12.             values : 1,
  13.             backgroundColor : 1,
  14.             scaleColors : 1,
  15.             normalizeFunction : 1,
  16.             focus : 1
  17.         },
  18.         get : {
  19.             selectedRegions : 1,
  20.             selectedMarkers : 1,
  21.             mapObject : 1,
  22.             regionName : 1
  23.         }
  24.     };
  25.     e.fn.vectorMap = function (e) {
  26.         var n,
  27.         r,
  28.         i,
  29.         n = this.children(".jvectormap-container").data("mapObject");
  30.         if (e === "addMap")
  31.             jvm.WorldMap.maps[arguments[1]] = arguments[2];
  32.         else {
  33.             if (!(e !== "set" && e !== "get" || !t[e][arguments[1]]))
  34.                 return r = arguments[1].charAt(0).toUpperCase() + arguments[1].substr(1), n[e + r].apply(n, Array.prototype.slice.call(arguments, 2));
  35.             e = e || {},
  36.             e.container = this,
  37.             n = new jvm.WorldMap(e)
  38.         }
  39.         return this
  40.     }
  41. })(jQuery), function (e) {
  42.     function r(t) {
  43.         var n = t || window.event,
  44.         r = [].slice.call(arguments, 1),
  45.         i = 0,
  46.         s = !0,
  47.         o = 0,
  48.         u = 0;
  49.         return t = e.event.fix(n),
  50.         t.type = "mousewheel",
  51.         n.wheelDelta && (i = n.wheelDelta / 120),
  52.         n.detail && (i = -n.detail / 3),
  53.         u = i,
  54.         n.axis !== undefined && n.axis === n.HORIZONTAL_AXIS && (u = 0, o = -1 * i),
  55.         n.wheelDeltaY !== undefined && (u = n.wheelDeltaY / 120),
  56.         n.wheelDeltaX !== undefined && (o = -1 * n.wheelDeltaX / 120),
  57.         r.unshift(t, i, o, u),
  58.         (e.event.dispatch || e.event.handle).apply(this, r)
  59.     }
  60.     var t = ["DOMMouseScroll", "mousewheel"];
  61.     if (e.event.fixHooks)
  62.         for (var n = t.length; n; )
  63.             e.event.fixHooks[t[--n]] = e.event.mouseHooks;
  64.     e.event.special.mousewheel = {
  65.         setup : function () {
  66.             if (this.addEventListener)
  67.                 for (var e = t.length; e; )
  68.                     this.addEventListener(t[--e], r, !1);
  69.             else
  70.                 this.onmousewheel = r
  71.         },
  72.         teardown : function () {
  73.             if (this.removeEventListener)
  74.                 for (var e = t.length; e; )
  75.                     this.removeEventListener(t[--e], r, !1);
  76.             else
  77.                 this.onmousewheel = null
  78.         }
  79.     },
  80.     e.fn.extend({
  81.         mousewheel : function (e) {
  82.             return e ? this.bind("mousewheel", e) : this.trigger("mousewheel")
  83.         },
  84.         unmousewheel : function (e) {
  85.             return this.unbind("mousewheel", e)
  86.         }
  87.     })
  88. }
  89. (jQuery);
  90. var jvm = {
  91.     inherits : function (e, t) {
  92.         function n() {}
  93.        
  94.         n.prototype = t.prototype,
  95.         e.prototype = new n,
  96.         e.prototype.constructor = e,
  97.         e.parentClass = t
  98.     },
  99.     mixin : function (e, t) {
  100.         var n;
  101.         for (n in t.prototype)
  102.             t.prototype.hasOwnProperty(n) && (e.prototype[n] = t.prototype[n])
  103.     },
  104.     min : function (e) {
  105.         var t = Number.MAX_VALUE,
  106.         n;
  107.         if (e instanceof Array)
  108.             for (n = 0; n < e.length; n++)
  109.                 e[n] < t && (t = e[n]);
  110.         else
  111.             for (n in e)
  112.                 e[n] < t && (t = e[n]);
  113.         return t
  114.     },
  115.     max : function (e) {
  116.         var t = Number.MIN_VALUE,
  117.         n;
  118.         if (e instanceof Array)
  119.             for (n = 0; n < e.length; n++)
  120.                 e[n] > t && (t = e[n]);
  121.         else
  122.             for (n in e)
  123.                 e[n] > t && (t = e[n]);
  124.         return t
  125.     },
  126.     keys : function (e) {
  127.         var t = [],
  128.         n;
  129.         for (n in e)
  130.             t.push(n);
  131.         return t
  132.     },
  133.     values : function (e) {
  134.         var t = [],
  135.         n,
  136.         r;
  137.         for (r = 0; r < arguments.length; r++) {
  138.             e = arguments[r];
  139.             for (n in e)
  140.                 t.push(e[n])
  141.         }
  142.         return t
  143.     }
  144. };
  145. jvm.$ = jQuery, jvm.AbstractElement = function (e, t) {
  146.     this.node = this.createElement(e),
  147.     this.name = e,
  148.     this.properties = {},
  149.     t && this.set(t)
  150. }, jvm.AbstractElement.prototype.set = function (e, t) {
  151.     var n;
  152.     if (typeof e == "object")
  153.         for (n in e)
  154.             this.properties[n] = e[n], this.applyAttr(n, e[n]);
  155.     else
  156.         this.properties[e] = t, this.applyAttr(e, t)
  157. }, jvm.AbstractElement.prototype.get = function (e) {
  158.     return this.properties[e]
  159. }, jvm.AbstractElement.prototype.applyAttr = function (e, t) {
  160.     this.node.setAttribute(e, t)
  161. }, jvm.AbstractElement.prototype.remove = function () {
  162.     jvm.$(this.node).remove()
  163. }, jvm.AbstractCanvasElement = function (e, t, n) {
  164.     this.container = e,
  165.     this.setSize(t, n),
  166.     this.rootElement = new jvm[this.classPrefix + "GroupElement"],
  167.     this.node.appendChild(this.rootElement.node),
  168.     this.container.appendChild(this.node)
  169. }, jvm.AbstractCanvasElement.prototype.add = function (e, t) {
  170.     t = t || this.rootElement,
  171.     t.add(e),
  172.     e.canvas = this
  173. }, jvm.AbstractCanvasElement.prototype.addPath = function (e, t, n) {
  174.     var r = new jvm[this.classPrefix + "PathElement"](e, t);
  175.     return this.add(r, n),
  176.     r
  177. }, jvm.AbstractCanvasElement.prototype.addCircle = function (e, t, n) {
  178.     var r = new jvm[this.classPrefix + "CircleElement"](e, t);
  179.     return this.add(r, n),
  180.     r
  181. }, jvm.AbstractCanvasElement.prototype.addGroup = function (e) {
  182.     var t = new jvm[this.classPrefix + "GroupElement"];
  183.     return e ? e.node.appendChild(t.node) : this.node.appendChild(t.node),
  184.     t.canvas = this,
  185.     t
  186. }, jvm.AbstractShapeElement = function (e, t, n) {
  187.     this.style = n || {},
  188.     this.style.current = {},
  189.     this.isHovered = !1,
  190.     this.isSelected = !1,
  191.     this.updateStyle()
  192. }, jvm.AbstractShapeElement.prototype.setHovered = function (e) {
  193.     this.isHovered !== e && (this.isHovered = e, this.updateStyle())
  194. }, jvm.AbstractShapeElement.prototype.setSelected = function (e) {
  195.     this.isSelected !== e && (this.isSelected = e, this.updateStyle(), jvm.$(this.node).trigger("selected", [e]))
  196. }, jvm.AbstractShapeElement.prototype.setStyle = function (e, t) {
  197.     var n = {};
  198.     typeof e == "object" ? n = e : n[e] = t,
  199.     jvm.$.extend(this.style.current, n),
  200.     this.updateStyle()
  201. }, jvm.AbstractShapeElement.prototype.updateStyle = function () {
  202.     var e = {};
  203.     jvm.$.extend(e, this.style.initial || {}),
  204.     jvm.$.extend(e, this.style.current || {}),
  205.     this.isHovered && jvm.$.extend(e, this.style.hover || {}),
  206.     this.isSelected && (jvm.$.extend(e, this.style.selected || {}), this.isHovered && jvm.$.extend(e, this.style.selectedHover || {})),
  207.     this.set(e)
  208. }, jvm.SVGElement = function (e, t) {
  209.     jvm.SVGElement.parentClass.apply(this, arguments)
  210. }, jvm.inherits(jvm.SVGElement, jvm.AbstractElement), jvm.SVGElement.svgns = "http://www.w3.org/2000/svg", jvm.SVGElement.prototype.createElement = function (e) {
  211.     return document.createElementNS(jvm.SVGElement.svgns, e)
  212. }, jvm.SVGElement.prototype.addClass = function (e) {
  213.     this.node.setAttribute("class", e)
  214. }, jvm.SVGElement.prototype.getElementCtr = function (e) {
  215.     return jvm["SVG" + e]
  216. }, jvm.SVGElement.prototype.getBBox = function () {
  217.     return this.node.getBBox()
  218. }, jvm.SVGGroupElement = function () {
  219.     jvm.SVGGroupElement.parentClass.call(this, "g")
  220. }, jvm.inherits(jvm.SVGGroupElement, jvm.SVGElement), jvm.SVGGroupElement.prototype.add = function (e) {
  221.     this.node.appendChild(e.node)
  222. }, jvm.SVGCanvasElement = function (e, t, n) {
  223.     this.classPrefix = "SVG",
  224.     jvm.SVGCanvasElement.parentClass.call(this, "svg"),
  225.     jvm.AbstractCanvasElement.apply(this, arguments)
  226. }, jvm.inherits(jvm.SVGCanvasElement, jvm.SVGElement), jvm.mixin(jvm.SVGCanvasElement, jvm.AbstractCanvasElement), jvm.SVGCanvasElement.prototype.setSize = function (e, t) {
  227.     this.width = e,
  228.     this.height = t,
  229.     this.node.setAttribute("width", e),
  230.     this.node.setAttribute("height", t)
  231. }, jvm.SVGCanvasElement.prototype.applyTransformParams = function (e, t, n) {
  232.     this.scale = e,
  233.     this.transX = t,
  234.     this.transY = n,
  235.     this.rootElement.node.setAttribute("transform", "scale(" + e + ") translate(" + t + ", " + n + ")")
  236. }, jvm.SVGShapeElement = function (e, t, n) {
  237.     jvm.SVGShapeElement.parentClass.call(this, e, t),
  238.     jvm.AbstractShapeElement.apply(this, arguments)
  239. }, jvm.inherits(jvm.SVGShapeElement, jvm.SVGElement), jvm.mixin(jvm.SVGShapeElement, jvm.AbstractShapeElement), jvm.SVGPathElement = function (e, t) {
  240.     jvm.SVGPathElement.parentClass.call(this, "path", e, t),
  241.     this.node.setAttribute("fill-rule", "evenodd")
  242. }, jvm.inherits(jvm.SVGPathElement, jvm.SVGShapeElement), jvm.SVGCircleElement = function (e, t) {
  243.     jvm.SVGCircleElement.parentClass.call(this, "circle", e, t)
  244. }, jvm.inherits(jvm.SVGCircleElement, jvm.SVGShapeElement), jvm.VMLElement = function (e, t) {
  245.     jvm.VMLElement.VMLInitialized || jvm.VMLElement.initializeVML(),
  246.     jvm.VMLElement.parentClass.apply(this, arguments)
  247. }, jvm.inherits(jvm.VMLElement, jvm.AbstractElement), jvm.VMLElement.VMLInitialized = !1, jvm.VMLElement.initializeVML = function () {
  248.     try {
  249.         document.namespaces.rvml || document.namespaces.add("rvml", "urn:schemas-microsoft-com:vml"),
  250.         jvm.VMLElement.prototype.createElement = function (e) {
  251.             return document.createElement("<rvml:" + e + ' class="rvml">')
  252.         }
  253.     } catch (e) {
  254.         jvm.VMLElement.prototype.createElement = function (e) {
  255.             return document.createElement("<" + e + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')
  256.         }
  257.     }
  258.     document.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)"),
  259.     jvm.VMLElement.VMLInitialized = !0
  260. }, jvm.VMLElement.prototype.getElementCtr = function (e) {
  261.     return jvm["VML" + e]
  262. }, jvm.VMLElement.prototype.addClass = function (e) {
  263.     jvm.$(this.node).addClass(e)
  264. }, jvm.VMLElement.prototype.applyAttr = function (e, t) {
  265.     this.node[e] = t
  266. }, jvm.VMLElement.prototype.getBBox = function () {
  267.     var e = jvm.$(this.node);
  268.     return {
  269.         x : e.position().left / this.canvas.scale,
  270.         y : e.position().top / this.canvas.scale,
  271.         width : e.width() / this.canvas.scale,
  272.         height : e.height() / this.canvas.scale
  273.     }
  274. }, jvm.VMLGroupElement = function () {
  275.     jvm.VMLGroupElement.parentClass.call(this, "group"),
  276.     this.node.style.left = "0px",
  277.     this.node.style.top = "0px",
  278.     this.node.coordorigin = "0 0"
  279. }, jvm.inherits(jvm.VMLGroupElement, jvm.VMLElement), jvm.VMLGroupElement.prototype.add = function (e) {
  280.     this.node.appendChild(e.node)
  281. }, jvm.VMLCanvasElement = function (e, t, n) {
  282.     this.classPrefix = "VML",
  283.     jvm.VMLCanvasElement.parentClass.call(this, "group"),
  284.     jvm.AbstractCanvasElement.apply(this, arguments),
  285.     this.node.style.position = "absolute"
  286. }, jvm.inherits(jvm.VMLCanvasElement, jvm.VMLElement), jvm.mixin(jvm.VMLCanvasElement, jvm.AbstractCanvasElement), jvm.VMLCanvasElement.prototype.setSize = function (e, t) {
  287.     var n,
  288.     r,
  289.     i,
  290.     s;
  291.     this.width = e,
  292.     this.height = t,
  293.     this.node.style.width = e + "px",
  294.     this.node.style.height = t + "px",
  295.     this.node.coordsize = e + " " + t,
  296.     this.node.coordorigin = "0 0";
  297.     if (this.rootElement) {
  298.         n = this.rootElement.node.getElementsByTagName("shape");
  299.         for (i = 0, s = n.length; i < s; i++)
  300.             n[i].coordsize = e + " " + t, n[i].style.width = e + "px", n[i].style.height = t + "px";
  301.         r = this.node.getElementsByTagName("group");
  302.         for (i = 0, s = r.length; i < s; i++)
  303.             r[i].coordsize = e + " " + t, r[i].style.width = e + "px", r[i].style.height = t + "px"
  304.     }
  305. }, jvm.VMLCanvasElement.prototype.applyTransformParams = function (e, t, n) {
  306.     this.scale = e,
  307.     this.transX = t,
  308.     this.transY = n,
  309.     this.rootElement.node.coordorigin = this.width - t - this.width / 100 + "," + (this.height - n - this.height / 100),
  310.     this.rootElement.node.coordsize = this.width / e + "," + this.height / e
  311. }, jvm.VMLShapeElement = function (e, t) {
  312.     jvm.VMLShapeElement.parentClass.call(this, e, t),
  313.     this.fillElement = new jvm.VMLElement("fill"),
  314.     this.strokeElement = new jvm.VMLElement("stroke"),
  315.     this.node.appendChild(this.fillElement.node),
  316.     this.node.appendChild(this.strokeElement.node),
  317.     this.node.stroked = !1,
  318.     jvm.AbstractShapeElement.apply(this, arguments)
  319. }, jvm.inherits(jvm.VMLShapeElement, jvm.VMLElement), jvm.mixin(jvm.VMLShapeElement, jvm.AbstractShapeElement), jvm.VMLShapeElement.prototype.applyAttr = function (e, t) {
  320.     switch (e) {
  321.     case "fill":
  322.         this.node.fillcolor = t;
  323.         break;
  324.     case "fill-opacity":
  325.         this.fillElement.node.opacity = Math.round(t * 100) + "%";
  326.         break;
  327.     case "stroke":
  328.         t === "none" ? this.node.stroked = !1 : this.node.stroked = !0,
  329.         this.node.strokecolor = t;
  330.         break;
  331.     case "stroke-opacity":
  332.         this.strokeElement.node.opacity = Math.round(t * 100) + "%";
  333.         break;
  334.     case "stroke-width":
  335.         parseInt(t, 10) === 0 ? this.node.stroked = !1 : this.node.stroked = !0,
  336.         this.node.strokeweight = t;
  337.         break;
  338.     case "d":
  339.         this.node.path = jvm.VMLPathElement.pathSvgToVml(t);
  340.         break;
  341.     default:
  342.         jvm.VMLShapeElement.parentClass.prototype.applyAttr.apply(this, arguments)
  343.     }
  344. }, jvm.VMLPathElement = function (e, t) {
  345.     var n = new jvm.VMLElement("skew");
  346.     jvm.VMLPathElement.parentClass.call(this, "shape", e, t),
  347.     this.node.coordorigin = "0 0",
  348.     n.node.on = !0,
  349.     n.node.matrix = "0.01,0,0,0.01,0,0",
  350.     n.node.offset = "0,0",
  351.     this.node.appendChild(n.node)
  352. }, jvm.inherits(jvm.VMLPathElement, jvm.VMLShapeElement), jvm.VMLPathElement.prototype.applyAttr = function (e, t) {
  353.     e === "d" ? this.node.path = jvm.VMLPathElement.pathSvgToVml(t) : jvm.VMLShapeElement.prototype.applyAttr.call(this, e, t)
  354. }, jvm.VMLPathElement.pathSvgToVml = function (e) {
  355.     var t = "",
  356.     n = 0,
  357.     r = 0,
  358.     i,
  359.     s;
  360.     return e = e.replace(/(-?\d+)e(-?\d+)/g, "0"),
  361.     e.replace(/([MmLlHhVvCcSs])\s*((?:-?\d*(?:\.\d+)?\s*,?\s*)+)/g, function (e, t, o, u) {
  362.         o = o.replace(/(\d)-/g, "$1,-").replace(/^\s+/g, "").replace(/\s+$/g, "").replace(/\s+/g, ",").split(","),
  363.         o[0] || o.shift();
  364.         for (var a = 0, f = o.length; a < f; a++)
  365.             o[a] = Math.round(100 * o[a]);
  366.         switch (t) {
  367.         case "m":
  368.             return n += o[0],
  369.             r += o[1],
  370.             "t" + o.join(",");
  371.         case "M":
  372.             return n = o[0],
  373.             r = o[1],
  374.             "m" + o.join(",");
  375.         case "l":
  376.             return n += o[0],
  377.             r += o[1],
  378.             "r" + o.join(",");
  379.         case "L":
  380.             return n = o[0],
  381.             r = o[1],
  382.             "l" + o.join(",");
  383.         case "h":
  384.             return n += o[0],
  385.             "r" + o[0] + ",0";
  386.         case "H":
  387.             return n = o[0],
  388.             "l" + n + "," + r;
  389.         case "v":
  390.             return r += o[0],
  391.             "r0," + o[0];
  392.         case "V":
  393.             return r = o[0],
  394.             "l" + n + "," + r;
  395.         case "c":
  396.             return i = n + o[o.length - 4],
  397.             s = r + o[o.length - 3],
  398.             n += o[o.length - 2],
  399.             r += o[o.length - 1],
  400.             "v" + o.join(",");
  401.         case "C":
  402.             return i = o[o.length - 4],
  403.             s = o[o.length - 3],
  404.             n = o[o.length - 2],
  405.             r = o[o.length - 1],
  406.             "c" + o.join(",");
  407.         case "s":
  408.             return o.unshift(r - s),
  409.             o.unshift(n - i),
  410.             i = n + o[o.length - 4],
  411.             s = r + o[o.length - 3],
  412.             n += o[o.length - 2],
  413.             r += o[o.length - 1],
  414.             "v" + o.join(",");
  415.         case "S":
  416.             return o.unshift(r + r - s),
  417.             o.unshift(n + n - i),
  418.             i = o[o.length - 4],
  419.             s = o[o.length - 3],
  420.             n = o[o.length - 2],
  421.             r = o[o.length - 1],
  422.             "c" + o.join(",")
  423.         }
  424.         return ""
  425.     }).replace(/z/g, "e")
  426. }, jvm.VMLCircleElement = function (e, t) {
  427.     jvm.VMLCircleElement.parentClass.call(this, "oval", e, t)
  428. }, jvm.inherits(jvm.VMLCircleElement, jvm.VMLShapeElement), jvm.VMLCircleElement.prototype.applyAttr = function (e, t) {
  429.     switch (e) {
  430.     case "r":
  431.         this.node.style.width = t * 2 + "px",
  432.         this.node.style.height = t * 2 + "px",
  433.         this.applyAttr("cx", this.get("cx") || 0),
  434.         this.applyAttr("cy", this.get("cy") || 0);
  435.         break;
  436.     case "cx":
  437.         if (!t)
  438.             return;
  439.         this.node.style.left = t - (this.get("r") || 0) + "px";
  440.         break;
  441.     case "cy":
  442.         if (!t)
  443.             return;
  444.         this.node.style.top = t - (this.get("r") || 0) + "px";
  445.         break;
  446.     default:
  447.         jvm.VMLCircleElement.parentClass.prototype.applyAttr.call(this, e, t)
  448.     }
  449. }, jvm.VectorCanvas = function (e, t, n) {
  450.     return this.mode = window.SVGAngle ? "svg" : "vml",
  451.     this.mode == "svg" ? this.impl = new jvm.SVGCanvasElement(e, t, n) : this.impl = new jvm.VMLCanvasElement(e, t, n),
  452.     this.impl
  453. }, jvm.SimpleScale = function (e) {
  454.     this.scale = e
  455. }, jvm.SimpleScale.prototype.getValue = function (e) {
  456.     return e
  457. }, jvm.OrdinalScale = function (e) {
  458.     this.scale = e
  459. }, jvm.OrdinalScale.prototype.getValue = function (e) {
  460.     return this.scale[e]
  461. }, jvm.NumericScale = function (e, t, n, r) {
  462.     this.scale = [],
  463.     t = t || "linear",
  464.     e && this.setScale(e),
  465.     t && this.setNormalizeFunction(t),
  466.     n && this.setMin(n),
  467.     r && this.setMax(r)
  468. }, jvm.NumericScale.prototype = {
  469.     setMin : function (e) {
  470.         this.clearMinValue = e,
  471.         typeof this.normalize == "function" ? this.minValue = this.normalize(e) : this.minValue = e
  472.     },
  473.     setMax : function (e) {
  474.         this.clearMaxValue = e,
  475.         typeof this.normalize == "function" ? this.maxValue = this.normalize(e) : this.maxValue = e
  476.     },
  477.     setScale : function (e) {
  478.         var t;
  479.         for (t = 0; t < e.length; t++)
  480.             this.scale[t] = [e[t]]
  481.     },
  482.     setNormalizeFunction : function (e) {
  483.         e === "polynomial" ? this.normalize = function (e) {
  484.             return Math.pow(e, .2)
  485.         }
  486.          : e === "linear" ? delete this.normalize : this.normalize = e,
  487.         this.setMin(this.clearMinValue),
  488.         this.setMax(this.clearMaxValue)
  489.     },
  490.     getValue : function (e) {
  491.         var t = [],
  492.         n = 0,
  493.         r,
  494.         i = 0,
  495.         s;
  496.         typeof this.normalize == "function" && (e = this.normalize(e));
  497.         for (i = 0; i < this.scale.length - 1; i++)
  498.             r = this.vectorLength(this.vectorSubtract(this.scale[i + 1], this.scale[i])), t.push(r), n += r;
  499.         s = (this.maxValue - this.minValue) / n;
  500.         for (i = 0; i < t.length; i++)
  501.             t[i] *= s;
  502.         i = 0,
  503.         e -= this.minValue;
  504.         while (e - t[i] >= 0)
  505.             e -= t[i], i++;
  506.         return i == this.scale.length - 1 ? e = this.vectorToNum(this.scale[i]) : e = this.vectorToNum(this.vectorAdd(this.scale[i], this.vectorMult(this.vectorSubtract(this.scale[i + 1], this.scale[i]), e / t[i]))),
  507.         e
  508.     },
  509.     vectorToNum : function (e) {
  510.         var t = 0,
  511.         n;
  512.         for (n = 0; n < e.length; n++)
  513.             t += Math.round(e[n]) * Math.pow(256, e.length - n - 1);
  514.         return t
  515.     },
  516.     vectorSubtract : function (e, t) {
  517.         var n = [],
  518.         r;
  519.         for (r = 0; r < e.length; r++)
  520.             n[r] = e[r] - t[r];
  521.         return n
  522.     },
  523.     vectorAdd : function (e, t) {
  524.         var n = [],
  525.         r;
  526.         for (r = 0; r < e.length; r++)
  527.             n[r] = e[r] + t[r];
  528.         return n
  529.     },
  530.     vectorMult : function (e, t) {
  531.         var n = [],
  532.         r;
  533.         for (r = 0; r < e.length; r++)
  534.             n[r] = e[r] * t;
  535.         return n
  536.     },
  537.     vectorLength : function (e) {
  538.         var t = 0,
  539.         n;
  540.         for (n = 0; n < e.length; n++)
  541.             t += e[n] * e[n];
  542.         return Math.sqrt(t)
  543.     }
  544. }, jvm.ColorScale = function (e, t, n, r) {
  545.     jvm.ColorScale.parentClass.apply(this, arguments)
  546. }, jvm.inherits(jvm.ColorScale, jvm.NumericScale), jvm.ColorScale.prototype.setScale = function (e) {
  547.     var t;
  548.     for (t = 0; t < e.length; t++)
  549.         this.scale[t] = jvm.ColorScale.rgbToArray(e[t])
  550. }, jvm.ColorScale.prototype.getValue = function (e) {
  551.     return jvm.ColorScale.numToRgb(jvm.ColorScale.parentClass.prototype.getValue.call(this, e))
  552. }, jvm.ColorScale.arrayToRgb = function (e) {
  553.     var t = "#",
  554.     n,
  555.     r;
  556.     for (r = 0; r < e.length; r++)
  557.         n = e[r].toString(16), t += n.length == 1 ? "0" + n : n;
  558.     return t
  559. }, jvm.ColorScale.numToRgb = function (e) {
  560.     e = e.toString(16);
  561.     while (e.length < 6)
  562.         e = "0" + e;
  563.     return "#" + e
  564. }, jvm.ColorScale.rgbToArray = function (e) {
  565.     return e = e.substr(1),
  566.     [parseInt(e.substr(0, 2), 16), parseInt(e.substr(2, 2), 16), parseInt(e.substr(4, 2), 16)]
  567. }, jvm.DataSeries = function (e, t) {
  568.     var n;
  569.     e = e || {},
  570.     e.attribute = e.attribute || "fill",
  571.     this.elements = t,
  572.     this.params = e,
  573.     e.attributes && this.setAttributes(e.attributes),
  574.     jvm.$.isArray(e.scale) ? (n = e.attribute === "fill" || e.attribute === "stroke" ? jvm.ColorScale : jvm.NumericScale, this.scale = new n(e.scale, e.normalizeFunction, e.min, e.max)) : e.scale ? this.scale = new jvm.OrdinalScale(e.scale) : this.scale = new jvm.SimpleScale(e.scale),
  575.     e.values && (this.values = e.values || {}, this.setValues(e.values))
  576. }, jvm.DataSeries.prototype = {
  577.     setAttributes : function (e, t) {
  578.         var n = e,
  579.         r;
  580.         if (typeof e == "string")
  581.             this.elements[e] && this.elements[e].setStyle(this.params.attribute, t);
  582.         else
  583.             for (r in n)
  584.                 this.elements[r] && this.elements[r].element.setStyle(this.params.attribute, n[r])
  585.     },
  586.     setValues : function (e) {
  587.         var t = Number.MIN_VALUE,
  588.         n = Number.MAX_VALUE,
  589.         r,
  590.         i,
  591.         s = {};
  592.         if (this.scale instanceof jvm.OrdinalScale || this.scale instanceof jvm.SimpleScale)
  593.             for (i in e)
  594.                 e[i] ? s[i] = this.scale.getValue(e[i]) : s[i] = this.elements[i].element.style.initial[this.params.attribute];
  595.         else {
  596.             if (!this.params.min || !this.params.max) {
  597.                 for (i in e)
  598.                     r = parseFloat(e[i]), r > t && (t = e[i]), r < n && (n = r);
  599.                 this.params.min || this.scale.setMin(n),
  600.                 this.params.max || this.scale.setMax(t),
  601.                 this.params.min = n,
  602.                 this.params.max = t
  603.             }
  604.             for (i in e)
  605.                 r = parseFloat(e[i]), isNaN(r) ? s[i] = this.elements[i].element.style.initial[this.params.attribute] : s[i] = this.scale.getValue(r)
  606.         }
  607.         this.setAttributes(s),
  608.         $.extend(this.values, e)
  609.     },
  610.     clear : function () {
  611.         var e,
  612.         t = {};
  613.         for (e in this.values)
  614.             t[e] = this.elements[e].element.style.initial[this.params.attribute];
  615.         this.setAttributes(t),
  616.         this.values = {}
  617.        
  618.     },
  619.     setScale : function (e) {
  620.        
  621.         this.scale.setScale(e),
  622.         this.values && this.setValues(this.values)
  623.     },
  624.     setNormalizeFunction : function (e) {
  625.         this.scale.setNormalizeFunction(e),
  626.         this.values && this.setValues(this.values)
  627.     }
  628. }, jvm.Proj = {
  629.     mill : function (e, t, n) {
  630.         return {
  631.             x : (t - n) / 360 * jvm.WorldMap.circumference,
  632.             y :  - (180 / Math.PI * (5 / 4) * Math.log(Math.tan(Math.PI / 4 + .8 * e * Math.PI / 360))) / 360 * jvm.WorldMap.circumference
  633.         }
  634.     },
  635.     merc : function (e, t, n) {
  636.         return {
  637.             x : (t - n) / 360 * jvm.WorldMap.circumference,
  638.             y :  - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + e * Math.PI / 360))) / 360 * jvm.WorldMap.circumference
  639.         }
  640.     },
  641.     aea : function (e, t, n) {
  642.         var r = 0,
  643.         i = n / 180 * Math.PI,
  644.         s = 29.5 / 180 * Math.PI,
  645.         o = 45.5 / 180 * Math.PI,
  646.         u = e / 180 * Math.PI,
  647.         a = t / 180 * Math.PI,
  648.         f = (Math.sin(s) + Math.sin(o)) / 2,
  649.         l = Math.cos(s) * Math.cos(s) + 2 * f * Math.sin(s),
  650.         c = f * (a - i),
  651.         h = Math.sqrt(l - 2 * f * Math.sin(u)) / f,
  652.         p = Math.sqrt(l - 2 * f * Math.sin(r)) / f;
  653.         return {
  654.             x : h * Math.sin(c) / (2 * Math.PI) * jvm.WorldMap.circumference,
  655.             y :  - (p - h * Math.cos(c)) / (2 * Math.PI) * jvm.WorldMap.circumference
  656.         }
  657.     },
  658.     lcc : function (e, t, r) {
  659.         var i = 0,
  660.         s = r / 180 * Math.PI,
  661.         o = t / 180 * Math.PI,
  662.         u = 33 / 180 * Math.PI,
  663.         a = .25 * Math.PI,
  664.         f = e / 180 * Math.PI;
  665.         return n = Math.log(Math.cos(u) * (1 / Math.cos(a))) / Math.log(Math.tan(Math.PI / 4 + a / 2) * (1 / Math.tan(Math.PI / 4 + u / 2))),
  666.         F = Math.cos(u) * Math.pow(Math.tan(Math.PI / 4 + u / 2), n) / n,
  667.         ro = F * Math.pow(1 / Math.tan(Math.PI / 4 + f / 2), n),
  668.         ro0 = F * Math.pow(1 / Math.tan(Math.PI / 4 + i / 2), n), {
  669.             x : ro * Math.sin(n * (o - s)) / (2 * Math.PI) * jvm.WorldMap.circumference,
  670.             y :  - (ro0 - ro * Math.cos(n * (o - s))) / (2 * Math.PI) * jvm.WorldMap.circumference
  671.         }
  672.     }
  673. }, jvm.WorldMap = function (e) {
  674.     var t = this,
  675.     n;
  676.     this.params = jvm.$.extend(!0, {}, jvm.WorldMap.defaultParams, e),
  677.     this.mapData = jvm.WorldMap.maps[this.params.map],
  678.     this.markers = {},
  679.     this.regions = {},
  680.     this.regionsColors = {},
  681.     this.regionsData = {},
  682.     this.container = jvm.$("<div>").css({
  683.             width : "100%",
  684.             height : "100%"
  685.         }).addClass("jvectormap-container"),
  686.     this.params.container.append(this.container),
  687.     this.container.data("mapObject", this),
  688.     this.container.css({
  689.         position : "relative",
  690.         overflow : "hidden"
  691.     }),
  692.     this.defaultWidth = this.mapData.width,
  693.     this.defaultHeight = this.mapData.height,
  694.     //this.setBackgroundColor(this.params.backgroundColor),
  695.     this.onResize = function () {
  696.         t.setSize()
  697.     },
  698.     jvm.$(window).resize(this.onResize);
  699.     for (n in jvm.WorldMap.apiEvents)
  700.         this.params[n] && this.container.bind(jvm.WorldMap.apiEvents[n] + ".jvectormap", this.params[n]);
  701.     this.canvas = new jvm.VectorCanvas(this.container[0], this.width, this.height),
  702.     "ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch ? this.params.bindTouchEvents && this.bindContainerTouchEvents() : this.bindContainerEvents(),
  703.     this.bindElementEvents(),
  704.     this.createLabel(),
  705.     this.bindZoomButtons(),
  706.     this.createRegions(),
  707.     this.createMarkers(this.params.markers || {}),
  708.     this.setSize(),
  709.     this.params.focusOn && (typeof this.params.focusOn == "object" ? this.setFocus.call(this, this.params.focusOn.scale, this.params.focusOn.x, this.params.focusOn.y) : this.setFocus.call(this, this.params.focusOn)),
  710.     this.params.selectedRegions && this.setSelectedRegions(this.params.selectedRegions),
  711.     this.params.selectedMarkers && this.setSelectedMarkers(this.params.selectedMarkers),
  712.     this.params.series && this.createSeries()
  713. }, jvm.WorldMap.prototype = {
  714.     transX : 0,
  715.     transY : 0,
  716.     scale : 1,
  717.     baseTransX : 0,
  718.     baseTransY : 0,
  719.     baseScale : 1,
  720.     width : 0,
  721.     height : 0,
  722.     setBackgroundColor : function (e) {
  723.         this.container.css("background-color", e)
  724.     },
  725.     resize : function () {
  726.         var e = this.baseScale;
  727.         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)),
  728.         this.scale *= this.baseScale / e,
  729.         this.transX *= this.baseScale / e,
  730.         this.transY *= this.baseScale / e
  731.     },
  732.     setSize : function () {
  733.         this.width = this.container.width(),
  734.         this.height = this.container.height(),
  735.         this.resize(),
  736.         this.canvas.setSize(this.width, this.height),
  737.         this.applyTransform()
  738.     },
  739.     reset : function () {
  740.         var e,
  741.         t;
  742.         for (e in this.series)
  743.             for (t = 0; t < this.series[e].length; t++)
  744.                 this.series[e][t].clear();
  745.         this.scale = this.baseScale,
  746.         this.transX = this.baseTransX,
  747.         this.transY = this.baseTransY,
  748.         this.applyTransform()
  749.     },
  750.     applyTransform : function () {
  751.         var e,
  752.         t,
  753.         n,
  754.         r;
  755.         this.defaultWidth * this.scale <= this.width ? (e = (this.width - this.defaultWidth * this.scale) / (2 * this.scale), n = (this.width - this.defaultWidth * this.scale) / (2 * this.scale)) : (e = 0, n = (this.width - this.defaultWidth * this.scale) / this.scale),
  756.         this.defaultHeight * this.scale <= this.height ? (t = (this.height - this.defaultHeight * this.scale) / (2 * this.scale), r = (this.height - this.defaultHeight * this.scale) / (2 * this.scale)) : (t = 0, r = (this.height - this.defaultHeight * this.scale) / this.scale),
  757.         this.transY > t ? this.transY = t : this.transY < r && (this.transY = r),
  758.         this.transX > e ? this.transX = e : this.transX < n && (this.transX = n),
  759.         this.canvas.applyTransformParams(this.scale, this.transX, this.transY),
  760.         this.markers && this.repositionMarkers()
  761.         this.container.trigger("viewportChange", [this.scale / this.baseScale, this.transX, this.transY])
  762.     },
  763.     bindContainerEvents : function () {
  764.         var e = !1,
  765.         t,
  766.         n,
  767.         r = this;
  768.         this.container.mousemove(function (i) {
  769.             return e && (r.transX -= (t - i.pageX) / r.scale, r.transY -= (n - i.pageY) / r.scale, r.applyTransform(), t = i.pageX, n = i.pageY),
  770.             !1
  771.         }).mousedown(function (r) {
  772.             return e = !0,
  773.             t = r.pageX,
  774.             n = r.pageY,
  775.             !1
  776.         }),
  777.         jvm.$("body").mouseup(function () {
  778.             e = !1
  779.         }),
  780.         this.params.zoomOnScroll && this.container.mousewheel(function (e, t, n, i) {
  781.             var s = jvm.$(r.container).offset(),
  782.             o = e.pageX - s.left,
  783.             u = e.pageY - s.top,
  784.             a = Math.pow(1.3, i);
  785.             r.label.hide(),
  786.             r.setScale(r.scale * a, o, u),
  787.             e.preventDefault()
  788.         })
  789.     },
  790.     bindContainerTouchEvents : function () {
  791.         var e,
  792.         t,
  793.         n,
  794.         r = this,
  795.         i,
  796.         s,
  797.         o,
  798.         u;
  799.         jvm.$(this.container).bind("gesturestart", function (i) {
  800.             return e = r.scale,
  801.             t = r.transX,
  802.             n = r.transY,
  803.             !1
  804.         }),
  805.         jvm.$(this.container).bind("gesturechange", function (t) {
  806.             var n = t.originalEvent.scale;
  807.             return r.setScale(e * n, o, u),
  808.             r.label.hide(),
  809.             !1
  810.         }),
  811.         jvm.$(this.container).bind("touchstart", function (e) {
  812.             var t = e.originalEvent.touches;
  813.             t.length == 2 && (t[0].pageX > t[1].pageX ? o = t[1].pageX + (t[0].pageX - t[1].pageX) / 2 : o = t[0].pageX + (t[1].pageX - t[0].pageX) / 2, t[0].pageY > t[1].pageY ? u = t[1].pageY + (t[0].pageY - t[1].pageY) / 2 : u = t[0].pageY + (t[1].pageY - t[0].pageY) / 2),
  814.             i = e.originalEvent.touches[0].pageX,
  815.             s = e.originalEvent.touches[0].pageY
  816.         }),
  817.         jvm.$(this.container).bind("touchmove", function (e) {
  818.             var t;
  819.             if (r.scale != r.baseScale)
  820.                 return e.originalEvent.touches.length == 1 && i && s ? (t = e.originalEvent.touches[0], r.transX -= (i - t.pageX) / r.scale, r.transY -= (s - t.pageY) / r.scale, r.applyTransform(), r.label.hide(), i = t.pageX, s = t.pageY) : (i = !1, s = !1), !1
  821.         })
  822.     },
  823.     bindElementEvents : function () {
  824.         var e = this,
  825.         t;
  826.         this.container.mousemove(function () {
  827.             t = !0
  828.         }),
  829.         this.container.delegate("[class~='jvectormap-element']", "mouseover mouseout", function (t) {
  830.             var n = this,
  831.             r = jvm.$(this).attr("class").indexOf("jvectormap-region") === -1 ? "marker" : "region",
  832.             i = r == "region" ? jvm.$(this).attr("data-code") : jvm.$(this).attr("data-index"),
  833.             s = r == "region" ? e.regions[i].element : e.markers[i].element,
  834.             o = r == "region" ? e.mapData.paths[i].name : e.markers[i].config.name || "",
  835.             u = jvm.$.Event(r + "LabelShow.jvectormap"),
  836.             a = jvm.$.Event(r + "Over.jvectormap");
  837.             t.type == "mouseover" ? (e.container.trigger(a, [i]), a.isDefaultPrevented() || s.setHovered(!0), e.label.text(o), e.container.trigger(u, [e.label, i]), u.isDefaultPrevented() || (e.label.show(), e.labelWidth = e.label.width(), e.labelHeight = e.label.height())) : (s.setHovered(!1), e.label.hide(), e.container.trigger(r + "Out.jvectormap", [i]))
  838.         }),
  839.         this.container.delegate("[class~='jvectormap-element']", "mousedown", function (e) {
  840.             t = !1
  841.         }),
  842.         this.container.delegate("[class~='jvectormap-element']", "mouseup", function (n) {
  843.             var r = this,
  844.             i = jvm.$(this).attr("class").indexOf("jvectormap-region") === -1 ? "marker" : "region",
  845.             s = i == "region" ? jvm.$(this).attr("data-code") : jvm.$(this).attr("data-index"),
  846.             o = jvm.$.Event(i + "Click.jvectormap"),
  847.             u = i == "region" ? e.regions[s].element : e.markers[s].element;
  848.             if (!t) {
  849.                 e.container.trigger(o, [s]);
  850.                 if (i === "region" && e.params.regionsSelectable || i === "marker" && e.params.markersSelectable)
  851.                     o.isDefaultPrevented() || (e.params[i + "sSelectableOne"] && e.clearSelected(i + "s"), u.setSelected(!u.isSelected))
  852.             }
  853.         })
  854.     },
  855.     bindZoomButtons : function () {
  856.         var e = this;
  857.         jvm.$("<div/>").addClass("jvectormap-zoomin").text("+").appendTo(this.container),
  858.         jvm.$("<div/>").addClass("jvectormap-zoomout").html("&#x2212;").appendTo(this.container),
  859.         this.container.find(".jvectormap-zoomin").click(function () {
  860.             e.setScale(e.scale + e.params.zoomStep)
  861.         }),
  862.         this.container.find(".jvectormap-zoomout").click(function () {
  863.             e.setScale(e.scale - e.params.zoomStep)
  864.         })
  865.         this.container.find(".jvectormap-zoomout").hide();
  866.     },
  867.     createLabel : function () {
  868.         var e = this;
  869.         this.label = jvm.$("<div/>").addClass("jvectormap-label").appendTo(jvm.$("body")),
  870.         this.container.mousemove(function (t) {
  871.             var n = t.pageX - 15 - e.labelWidth,
  872.             r = t.pageY - 15 - e.labelHeight;
  873.             n < 350 && (n = t.pageX + 50),
  874.             r < 350 && (r = t.pageY + 50),
  875.             e.label.is(":visible") && e.label.css({
  876.                 left : n,
  877.                 top : r
  878.             })
  879.         })
  880.     },
  881.     setScale : function (e, t, n, r) {
  882.        
  883.         var i,
  884.         s = jvm.$.Event("zoom.jvectormap");
  885.         e > this.params.zoomMax * this.baseScale ? e = this.params.zoomMax * this.baseScale : e < this.params.zoomMin * this.baseScale && (e = this.params.zoomMin * this.baseScale),
  886.         typeof t != "undefined" && typeof n != "undefined" && (i = e / this.scale, r ? (this.transX = t + this.defaultWidth * (this.width / (this.defaultWidth * e)) / 2, this.transY = n + this.defaultHeight * (this.height / (this.defaultHeight * e)) / 2) : (this.transX -= (i - 1) / e * t, this.transY -= (i - 1) / e * n)),
  887.         this.scale = e,
  888.         this.applyTransform(),
  889.         this.container.trigger(s, [e / this.baseScale])
  890.         if(e >= this.params.zoomMax-4.5){
  891.             $('.jvectormap-zoomin').hide();
  892.         }else{
  893.             $('.jvectormap-zoomin').show();
  894.         }
  895.         if(e< this.params.zoomMin){
  896.             $('.jvectormap-zoomout').hide();
  897.            
  898.             //this.removeAllMarkers();
  899.         }else{
  900.             $('.jvectormap-zoomout').show();
  901.         }
  902.        
  903.     },
  904.     setFocus : function (e, t, n) {
  905.         var r;
  906.         typeof e == "string" && this.regions[e] ? (r = this.regions[e].element.getBBox(), this.setScale(Math.min(this.width / r.width, this.height / r.height),  - (r.x + r.width / 2),  - (r.y + r.height / 2), !0)) : this.setScale(e, -t * this.defaultWidth, -n * this.defaultHeight, !0)
  907.     },
  908.     getSelected : function (e) {
  909.         var t,
  910.         n = [];
  911.         for (t in this[e])
  912.             this[e][t].element.isSelected && n.push(t);
  913.         return n
  914.     },
  915.     getSelectedRegions : function () {
  916.         return this.getSelected("regions")
  917.     },
  918.     setSelectedRegions : function () {
  919.         return this.getSelected("regions")
  920.     },
  921.     setSelectedRegionStyle : function (r,c) {
  922.         return this.regions[r].element.style.selected.fill = c;
  923.     },
  924.     getSelectedMarkers : function () {
  925.         return this.getSelected("markers")
  926.     },
  927.     setSelected : function (e, t) {
  928.         var n;
  929.         typeof t != "object" && (t = [t]);
  930.         if (jvm.$.isArray(t))
  931.             for (n = 0; n < t.length; n++)
  932.                 this[e][t[n]].element.setSelected(!0);
  933.         else
  934.             for (n in t)
  935.                 this[e][n].element.setSelected(!!t[n])
  936.     },
  937.     setSelectedRegions : function (e) {
  938.         this.setSelected("regions", e)
  939.     },
  940.     setSelectedMarkers : function (e) {
  941.         this.setSelected("markers", e)
  942.     },
  943.     clearSelected : function (e) {
  944.         var t = {},
  945.         n = this.getSelected(e),
  946.         r;
  947.         for (r = 0; r < n.length; r++)
  948.             t[n[r]] = !1;
  949.         this.setSelected(e, t)
  950.     },
  951.     clearSelectedRegions : function () {
  952.         this.clearSelected("regions")
  953.     },
  954.     clearSelectedMarkers : function () {
  955.         this.clearSelected("markers")
  956.     },
  957.     getMapObject : function () {
  958.         return this
  959.     },
  960.     getRegionName : function (e) {
  961.         return this.mapData.paths[e].name
  962.     },
  963.     createRegions : function () {
  964.         var e,
  965.         t,
  966.         n = this;
  967.         for (e in this.mapData.paths)
  968.             t = this.canvas.addPath({
  969.                     d : this.mapData.paths[e].path,
  970.                     "data-code" : e
  971.                 }, jvm.$.extend(!0, {}, this.params.regionStyle)), jvm.$(t.node).bind("selected", function (e, t) {
  972.                 n.container.trigger("regionSelected.jvectormap", [jvm.$(this).attr("data-code"), t, n.getSelectedRegions()])
  973.             }), t.addClass("jvectormap-region jvectormap-element"), this.regions[e] = {
  974.                 element : t,
  975.                 config : this.mapData.paths[e]
  976.             }
  977.     },
  978.     createMarkers : function (e) {
  979.         var t,
  980.         n,
  981.         r,
  982.         i,
  983.         s,
  984.         o = this;
  985.         this.markersGroup = this.markersGroup || this.canvas.addGroup();
  986.         if (jvm.$.isArray(e)) {
  987.             s = e.slice(),
  988.             e = {};
  989.             for (t = 0; t < s.length; t++)
  990.                 e[t] = s[t]
  991.         }
  992.         for (t in e)
  993.             i = e[t]instanceof Array ? {
  994.                 latLng : e[t]
  995.             }
  996.          : e[t],
  997.         r = this.latLngToPoint.apply(this, i.latLng || [0, 0]),
  998.         n = this.canvas.addCircle({
  999.                 "data-index" : t,
  1000.                 cx : r.x,
  1001.                 cy : r.y
  1002.             }, jvm.$.extend(!0, {}, this.params.markerStyle, {
  1003.                     initial : i.style || {}
  1004.                    
  1005.                 }), this.markersGroup),
  1006.         n.addClass("jvectormap-marker jvectormap-element"),
  1007.         jvm.$(n.node).bind("selected", function (e, t) {
  1008.             o.container.trigger("markerSelected.jvectormap", [jvm.$(this).attr("data-index"), t, o.getSelectedMarkers()])
  1009.         }),
  1010.         this.markers[t] && this.removeMarkers([t]),
  1011.         this.markers[t] = {
  1012.             element : n,
  1013.             config : i
  1014.         }
  1015.     },
  1016.     repositionMarkers : function () {
  1017.         var e,
  1018.         t;
  1019.         for (e in this.markers)
  1020.             t = this.latLngToPoint.apply(this, this.markers[e].config.latLng), this.markers[e].element.setStyle({
  1021.                 cx : t.x,
  1022.                 cy : t.y
  1023.             })
  1024.     },
  1025.     addMarker : function (e, t, n) {
  1026.         var r = {},
  1027.         i = [],
  1028.         s,
  1029.         o;
  1030.         r[e] = t;
  1031.         for (o = 0; o < n.length; o++)
  1032.             s = {},
  1033.         s[e] = n[o],
  1034.         i.push(s);
  1035.         this.addMarkers(r, i)
  1036.     },
  1037.     addMarkers : function (e, t) {
  1038.         var n;
  1039.         t = t || [],
  1040.         this.createMarkers(e);
  1041.         console.log(e);
  1042.         for (n = 0; n < t.length; n++)
  1043.             this.series.markers[n].setValues(t[n] || {})
  1044.     },
  1045.     removeMarkers : function (e) {
  1046.         var t;
  1047.         for (t = 0; t < e.length; t++)
  1048.             this.markers[e[t]].element.remove(), delete this.markers[e[t]]
  1049.     },
  1050.     removeAllMarkers : function () {
  1051.         var e,
  1052.         t = [];
  1053.         for (e in this.markers)
  1054.             t.push(e);
  1055.         this.removeMarkers(t)
  1056.     },
  1057.     latLngToPoint : function (e, t) {
  1058.         var n,
  1059.         r = jvm.WorldMap.maps[this.params.map].projection,
  1060.         i = r.centralMeridian,
  1061.         s = this.width - this.baseTransX * 2 * this.baseScale,
  1062.         o = this.height - this.baseTransY * 2 * this.baseScale,
  1063.         u,
  1064.         a,
  1065.         f = this.scale / this.baseScale;
  1066.         return t < -180 + i && (t += 360),
  1067.         n = jvm.Proj[r.type](e, t, i),
  1068.         u = this.getInsetForPoint(n.x, n.y),
  1069.         u ? (a = u.bbox, n.x = (n.x - a[0].x) / (a[1].x - a[0].x) * u.width * this.scale, n.y = (n.y - a[0].y) / (a[1].y - a[0].y) * u.height * this.scale, {
  1070.             x : n.x + this.transX * this.scale + u.left * this.scale,
  1071.             y : n.y + this.transY * this.scale + u.top * this.scale
  1072.         }) : {
  1073.             x : 0,
  1074.             y : 0
  1075.         }
  1076.     },
  1077.     getInsetForPoint : function (e, t) {
  1078.         var n = jvm.WorldMap.maps[this.params.map].insets,
  1079.         r,
  1080.         i;
  1081.         for (r = 0; r < n.length; r++) {
  1082.             i = n[r].bbox;
  1083.             if (e > i[0].x && e < i[1].x && t > i[0].y && t < i[1].y)
  1084.                 return n[r]
  1085.         }
  1086.     },
  1087.     createSeries : function () {
  1088.         var e,
  1089.         t;
  1090.         this.series = {
  1091.             markers : [],
  1092.             regions : []
  1093.         };
  1094.         for (t in this.params.series)
  1095.             for (e = 0; e < this.params.series[t].length; e++)
  1096.                 this.series[t][e] = new jvm.DataSeries(this.params.series[t][e], this[t])
  1097.     },
  1098.     remove : function () {
  1099.         this.label.remove(),
  1100.         this.container.remove(),
  1101.         jvm.$(window).unbind("resize", this.onResize)
  1102.     }
  1103. }, jvm.WorldMap.maps = {}, jvm.WorldMap.circumference = 6381372 * Math.PI * 2, jvm.WorldMap.defaultParams = {
  1104.     map : "world_mill_en",
  1105.     backgroundColor : "#505050",
  1106.     zoomOnScroll : !0,
  1107.     zoomMax : 16,
  1108.     zoomMin : 1,
  1109.     zoomStep : 1,
  1110.     regionsSelectable : !1,
  1111.     markersSelectable : !1,
  1112.     bindTouchEvents : !0,
  1113.     regionStyle : {
  1114.         initial : {
  1115.             fill : "white",
  1116.             "fill-opacity" : 1,
  1117.             stroke : "none",
  1118.             "stroke-width" : 0,
  1119.             "stroke-opacity" : 1
  1120.         },
  1121.         hover : {
  1122.             "fill-opacity" : .8
  1123.         },
  1124.         selected : {
  1125.             fill : "yellow"
  1126.         },
  1127.         selectedHover : {}
  1128.        
  1129.     },
  1130.     markerStyle : {
  1131.         initial : {
  1132.             fill : "grey",
  1133.             stroke : "#505050",
  1134.             "fill-opacity" : 1,
  1135.             "stroke-width" : 1,
  1136.             "stroke-opacity" : 1,
  1137.             r : 5
  1138.         },
  1139.         hover : {
  1140.             stroke : "black",
  1141.             "stroke-width" : 2
  1142.         },
  1143.         selected : {
  1144.             fill : "blue"
  1145.         },
  1146.         selectedHover : {}
  1147.        
  1148.     }
  1149. }, jvm.WorldMap.apiEvents = {
  1150.     onRegionLabelShow : "regionLabelShow",
  1151.     onRegionOver : "regionOver",
  1152.     onRegionOut : "regionOut",
  1153.     onRegionClick : "regionClick",
  1154.     onRegionSelected : "regionSelected",
  1155.     onMarkerLabelShow : "markerLabelShow",
  1156.     onMarkerOver : "markerOver",
  1157.     onMarkerOut : "markerOut",
  1158.     onMarkerClick : "markerClick",
  1159.     onMarkerSelected : "markerSelected",
  1160.     onZoom : "zoom",
  1161.     onViewportChange:"viewportChange"
  1162. };
Add Comment
Please, Sign In to add comment