123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987 |
- jvm.WorldMap = function(params) {
- var map = this,
- e;
- this.params = jvm.$.extend(true, {}, jvm.WorldMap.defaultParams, params);
- if (!jvm.WorldMap.maps[this.params.map]) {
- throw new Error('Attempt to use map which was not loaded: '+this.params.map);
- }
- this.mapData = jvm.WorldMap.maps[this.params.map];
- this.markers = {};
- this.regions = {};
- this.regionsColors = {};
- this.regionsData = {};
- this.container = jvm.$('<div>').css({width: '100%', height: '100%'}).addClass('jvectormap-container');
- this.params.container.append( this.container );
- this.container.data('mapObject', this);
- this.container.css({
- position: 'relative',
- overflow: 'hidden'
- });
- this.defaultWidth = this.mapData.width;
- this.defaultHeight = this.mapData.height;
- this.setBackgroundColor(this.params.backgroundColor);
- this.onResize = function(){
- map.setSize();
- }
- jvm.$(window).resize(this.onResize);
- for (e in jvm.WorldMap.apiEvents) {
- if (this.params[e]) {
- this.container.bind(jvm.WorldMap.apiEvents[e]+'.jvectormap', this.params[e]);
- }
- }
- this.canvas = new jvm.VectorCanvas(this.container[0], this.width, this.height);
- if ( ('ontouchstart' in window) || (window.DocumentTouch && document instanceof DocumentTouch) ) {
- if (this.params.bindTouchEvents) {
- this.bindContainerTouchEvents();
- }
- } else {
- this.bindContainerEvents();
- }
- this.bindElementEvents();
- this.createLabel();
- if (this.params.zoomButtons) {
- this.bindZoomButtons();
- }
- this.createRegions();
- this.createMarkers(this.params.markers || {});
- this.setSize();
- if (this.params.focusOn) {
- if (typeof this.params.focusOn === 'object') {
- this.setFocus.call(this, this.params.focusOn.scale, this.params.focusOn.x, this.params.focusOn.y);
- } else {
- this.setFocus.call(this, this.params.focusOn);
- }
- }
- if (this.params.selectedRegions) {
- this.setSelectedRegions(this.params.selectedRegions);
- }
- if (this.params.selectedMarkers) {
- this.setSelectedMarkers(this.params.selectedMarkers);
- }
- if (this.params.series) {
- this.createSeries();
- }
- };
- jvm.WorldMap.prototype = {
- transX: 0,
- transY: 0,
- scale: 1,
- baseTransX: 0,
- baseTransY: 0,
- baseScale: 1,
- width: 0,
- height: 0,
-
- setBackgroundColor: function(backgroundColor) {
- this.container.css('background-color', backgroundColor);
- },
- resize: function() {
- var curBaseScale = this.baseScale;
- if (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);
- } else {
- this.baseScale = this.width / this.defaultWidth;
- this.baseTransY = Math.abs(this.height - this.defaultHeight * this.baseScale) / (2 * this.baseScale);
- }
- this.scale *= this.baseScale / curBaseScale;
- this.transX *= this.baseScale / curBaseScale;
- this.transY *= this.baseScale / curBaseScale;
- },
-
- setSize: 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 key,
- i;
- for (key in this.series) {
- for (i = 0; i < this.series[key].length; i++) {
- this.series[key][i].clear();
- }
- }
- this.scale = this.baseScale;
- this.transX = this.baseTransX;
- this.transY = this.baseTransY;
- this.applyTransform();
- },
- applyTransform: function() {
- var maxTransX,
- maxTransY,
- minTransX,
- minTransY;
- if (this.defaultWidth * this.scale <= this.width) {
- maxTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
- minTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
- } else {
- maxTransX = 0;
- minTransX = (this.width - this.defaultWidth * this.scale) / this.scale;
- }
- if (this.defaultHeight * this.scale <= this.height) {
- maxTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
- minTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
- } else {
- maxTransY = 0;
- minTransY = (this.height - this.defaultHeight * this.scale) / this.scale;
- }
- if (this.transY > maxTransY) {
- this.transY = maxTransY;
- } else if (this.transY < minTransY) {
- this.transY = minTransY;
- }
- if (this.transX > maxTransX) {
- this.transX = maxTransX;
- } else if (this.transX < minTransX) {
- this.transX = minTransX;
- }
- this.canvas.applyTransformParams(this.scale, this.transX, this.transY);
- if (this.markers) {
- this.repositionMarkers();
- }
- this.container.trigger('viewportChange', [this.scale/this.baseScale, this.transX, this.transY]);
- },
- bindContainerEvents: function(){
- var mouseDown = false,
- oldPageX,
- oldPageY,
- map = this;
- this.container.mousemove(function(e){
- if (mouseDown) {
- map.transX -= (oldPageX - e.pageX) / map.scale;
- map.transY -= (oldPageY - e.pageY) / map.scale;
- map.applyTransform();
- oldPageX = e.pageX;
- oldPageY = e.pageY;
- }
- return false;
- }).mousedown(function(e){
- mouseDown = true;
- oldPageX = e.pageX;
- oldPageY = e.pageY;
- return false;
- });
- jvm.$('body').mouseup(function(){
- mouseDown = false;
- });
- if (this.params.zoomOnScroll) {
- this.container.mousewheel(function(event, delta, deltaX, deltaY) {
- var offset = jvm.$(map.container).offset(),
- centerX = event.pageX - offset.left,
- centerY = event.pageY - offset.top,
- zoomStep = Math.pow(1.3, deltaY);
- map.label.hide();
- map.setScale(map.scale * zoomStep, centerX, centerY);
- event.preventDefault();
- });
- }
- },
- bindContainerTouchEvents: function(){
- var touchStartScale,
- touchStartDistance,
- map = this,
- touchX,
- touchY,
- centerTouchX,
- centerTouchY,
- lastTouchesLength,
- handleTouchEvent = function(e){
- var touches = e.originalEvent.touches,
- offset,
- scale,
- transXOld,
- transYOld;
- if (e.type == 'touchstart') {
- lastTouchesLength = 0;
- }
- if (touches.length == 1) {
- if (lastTouchesLength == 1) {
- transXOld = map.transX;
- transYOld = map.transY;
- map.transX -= (touchX - touches[0].pageX) / map.scale;
- map.transY -= (touchY - touches[0].pageY) / map.scale;
- map.applyTransform();
- map.label.hide();
- if (transXOld != map.transX || transYOld != map.transY) {
- e.preventDefault();
- }
- }
- touchX = touches[0].pageX;
- touchY = touches[0].pageY;
- } else if (touches.length == 2) {
- if (lastTouchesLength == 2) {
- scale = Math.sqrt(
- Math.pow(touches[0].pageX - touches[1].pageX, 2) +
- Math.pow(touches[0].pageY - touches[1].pageY, 2)
- ) / touchStartDistance;
- map.setScale(
- touchStartScale * scale,
- centerTouchX,
- centerTouchY
- )
- map.label.hide();
- e.preventDefault();
- } else {
- offset = jvm.$(map.container).offset();
- if (touches[0].pageX > touches[1].pageX) {
- centerTouchX = touches[1].pageX + (touches[0].pageX - touches[1].pageX) / 2;
- } else {
- centerTouchX = touches[0].pageX + (touches[1].pageX - touches[0].pageX) / 2;
- }
- if (touches[0].pageY > touches[1].pageY) {
- centerTouchY = touches[1].pageY + (touches[0].pageY - touches[1].pageY) / 2;
- } else {
- centerTouchY = touches[0].pageY + (touches[1].pageY - touches[0].pageY) / 2;
- }
- centerTouchX -= offset.left;
- centerTouchY -= offset.top;
- touchStartScale = map.scale;
- touchStartDistance = Math.sqrt(
- Math.pow(touches[0].pageX - touches[1].pageX, 2) +
- Math.pow(touches[0].pageY - touches[1].pageY, 2)
- );
- }
- }
- lastTouchesLength = touches.length;
- };
- jvm.$(this.container).bind('touchstart', handleTouchEvent);
- jvm.$(this.container).bind('touchmove', handleTouchEvent);
- },
- bindElementEvents: function(){
- var map = this,
- mouseMoved;
- this.container.mousemove(function(){
- mouseMoved = true;
- });
-
- this.container.delegate("[class~='jvectormap-element']", 'mouseover mouseout', function(e){
- var path = this,
- baseVal = jvm.$(this).attr('class').baseVal ? jvm.$(this).attr('class').baseVal : jvm.$(this).attr('class'),
- type = baseVal.indexOf('jvectormap-region') === -1 ? 'marker' : 'region',
- code = type == 'region' ? jvm.$(this).attr('data-code') : jvm.$(this).attr('data-index'),
- element = type == 'region' ? map.regions[code].element : map.markers[code].element,
- labelText = type == 'region' ? map.mapData.paths[code].name : (map.markers[code].config.name || ''),
- labelShowEvent = jvm.$.Event(type+'LabelShow.jvectormap'),
- overEvent = jvm.$.Event(type+'Over.jvectormap');
- if (e.type == 'mouseover') {
- map.container.trigger(overEvent, [code]);
- if (!overEvent.isDefaultPrevented()) {
- element.setHovered(true);
- }
- map.label.text(labelText);
- map.container.trigger(labelShowEvent, [map.label, code]);
- if (!labelShowEvent.isDefaultPrevented()) {
- map.label.show();
- map.labelWidth = map.label.width();
- map.labelHeight = map.label.height();
- }
- } else {
- element.setHovered(false);
- map.label.hide();
- map.container.trigger(type+'Out.jvectormap', [code]);
- }
- });
-
- this.container.delegate("[class~='jvectormap-element']", 'mousedown', function(e){
- mouseMoved = false;
- });
-
- this.container.delegate("[class~='jvectormap-element']", 'mouseup', function(e){
- var path = this,
- baseVal = jvm.$(this).attr('class').baseVal ? jvm.$(this).attr('class').baseVal : jvm.$(this).attr('class'),
- type = baseVal.indexOf('jvectormap-region') === -1 ? 'marker' : 'region',
- code = type == 'region' ? jvm.$(this).attr('data-code') : jvm.$(this).attr('data-index'),
- clickEvent = jvm.$.Event(type+'Click.jvectormap'),
- element = type == 'region' ? map.regions[code].element : map.markers[code].element;
- if (!mouseMoved) {
- map.container.trigger(clickEvent, [code]);
- if ((type === 'region' && map.params.regionsSelectable) || (type === 'marker' && map.params.markersSelectable)) {
- if (!clickEvent.isDefaultPrevented()) {
- if (map.params[type+'sSelectableOne']) {
- map.clearSelected(type+'s');
- }
- element.setSelected(!element.isSelected);
- }
- }
- }
- });
- },
- bindZoomButtons: function() {
- var map = this;
- jvm.$('<div/>').addClass('jvectormap-zoomin').text('+').appendTo(this.container);
- jvm.$('<div/>').addClass('jvectormap-zoomout').html('−').appendTo(this.container);
- this.container.find('.jvectormap-zoomin').click(function(){
- map.setScale(map.scale * map.params.zoomStep, map.width / 2, map.height / 2);
- });
- this.container.find('.jvectormap-zoomout').click(function(){
- map.setScale(map.scale / map.params.zoomStep, map.width / 2, map.height / 2);
- });
- },
- createLabel: function(){
- var map = this;
- this.label = jvm.$('<div/>').addClass('jvectormap-label').appendTo(jvm.$('body'));
- this.container.mousemove(function(e){
- var left = e.pageX-15-map.labelWidth,
- top = e.pageY-15-map.labelHeight;
- if (left < 5) {
- left = e.pageX + 15;
- }
- if (top < 5) {
- top = e.pageY + 15;
- }
- if (map.label.is(':visible')) {
- map.label.css({
- left: left,
- top: top
- })
- }
- });
- },
- setScale: function(scale, anchorX, anchorY, isCentered) {
- var zoomStep,
- viewportChangeEvent = jvm.$.Event('zoom.jvectormap');
- if (scale > this.params.zoomMax * this.baseScale) {
- scale = this.params.zoomMax * this.baseScale;
- } else if (scale < this.params.zoomMin * this.baseScale) {
- scale = this.params.zoomMin * this.baseScale;
- }
- if (typeof anchorX != 'undefined' && typeof anchorY != 'undefined') {
- zoomStep = scale / this.scale;
- if (isCentered) {
- this.transX = anchorX + this.defaultWidth * (this.width / (this.defaultWidth * scale)) / 2;
- this.transY = anchorY + this.defaultHeight * (this.height / (this.defaultHeight * scale)) / 2;
- } else {
- this.transX -= (zoomStep - 1) / scale * anchorX;
- this.transY -= (zoomStep - 1) / scale * anchorY;
- }
- }
- this.scale = scale;
- this.applyTransform();
- this.container.trigger(viewportChangeEvent, [scale/this.baseScale]);
- },
-
- setFocus: function(scale, centerX, centerY){
- var bbox,
- itemBbox,
- newBbox,
- codes,
- i;
- if (jvm.$.isArray(scale) || this.regions[scale]) {
- if (jvm.$.isArray(scale)) {
- codes = scale;
- } else {
- codes = [scale]
- }
- for (i = 0; i < codes.length; i++) {
- if (this.regions[codes[i]]) {
- itemBbox = this.regions[codes[i]].element.getBBox();
- if (itemBbox) {
- if (typeof bbox == 'undefined') {
- bbox = itemBbox;
- } else {
- newBbox = {
- x: Math.min(bbox.x, itemBbox.x),
- y: Math.min(bbox.y, itemBbox.y),
- width: Math.max(bbox.x + bbox.width, itemBbox.x + itemBbox.width) - Math.min(bbox.x, itemBbox.x),
- height: Math.max(bbox.y + bbox.height, itemBbox.y + itemBbox.height) - Math.min(bbox.y, itemBbox.y)
- }
- bbox = newBbox;
- }
- }
- }
- }
- this.setScale(
- Math.min(this.width / bbox.width, this.height / bbox.height),
- - (bbox.x + bbox.width / 2),
- - (bbox.y + bbox.height / 2),
- true
- );
- } else {
- scale = scale * this.baseScale;
- this.setScale(scale, - centerX * this.defaultWidth, - centerY * this.defaultHeight, true);
- }
- },
- getSelected: function(type){
- var key,
- selected = [];
- for (key in this[type]) {
- if (this[type][key].element.isSelected) {
- selected.push(key);
- }
- }
- return selected;
- },
-
- getSelectedRegions: function(){
- return this.getSelected('regions');
- },
-
- getSelectedMarkers: function(){
- return this.getSelected('markers');
- },
- setSelected: function(type, keys){
- var i;
- if (typeof keys != 'object') {
- keys = [keys];
- }
- if (jvm.$.isArray(keys)) {
- for (i = 0; i < keys.length; i++) {
- this[type][keys[i]].element.setSelected(true);
- }
- } else {
- for (i in keys) {
- this[type][i].element.setSelected(!!keys[i]);
- }
- }
- },
-
- setSelectedRegions: function(keys){
- this.setSelected('regions', keys);
- },
-
- setSelectedMarkers: function(keys){
- this.setSelected('markers', keys);
- },
- clearSelected: function(type){
- var select = {},
- selected = this.getSelected(type),
- i;
- for (i = 0; i < selected.length; i++) {
- select[selected[i]] = false;
- };
- this.setSelected(type, select);
- },
-
- clearSelectedRegions: function(){
- this.clearSelected('regions');
- },
-
- clearSelectedMarkers: function(){
- this.clearSelected('markers');
- },
-
- getMapObject: function(){
- return this;
- },
-
- getRegionName: function(code){
- return this.mapData.paths[code].name;
- },
- createRegions: function(){
- var key,
- region,
- map = this;
- for (key in this.mapData.paths) {
- region = this.canvas.addPath({
- d: this.mapData.paths[key].path,
- "data-code": key
- }, jvm.$.extend(true, {}, this.params.regionStyle));
- jvm.$(region.node).bind('selected', function(e, isSelected){
- map.container.trigger('regionSelected.jvectormap', [jvm.$(this).attr('data-code'), isSelected, map.getSelectedRegions()]);
- });
- region.addClass('jvectormap-region jvectormap-element');
- this.regions[key] = {
- element: region,
- config: this.mapData.paths[key]
- };
- }
- },
- createMarkers: function(markers) {
- var i,
- marker,
- point,
- markerConfig,
- markersArray,
- map = this;
- this.markersGroup = this.markersGroup || this.canvas.addGroup();
- if (jvm.$.isArray(markers)) {
- markersArray = markers.slice();
- markers = {};
- for (i = 0; i < markersArray.length; i++) {
- markers[i] = markersArray[i];
- }
- }
- for (i in markers) {
- markerConfig = markers[i] instanceof Array ? {latLng: markers[i]} : markers[i];
- point = this.getMarkerPosition( markerConfig );
- if (point !== false) {
- marker = this.canvas.addCircle({
- "data-index": i,
- cx: point.x,
- cy: point.y
- }, jvm.$.extend(true, {}, this.params.markerStyle, {initial: markerConfig.style || {}}), this.markersGroup);
- marker.addClass('jvectormap-marker jvectormap-element');
- jvm.$(marker.node).bind('selected', function(e, isSelected){
- map.container.trigger('markerSelected.jvectormap', [jvm.$(this).attr('data-index'), isSelected, map.getSelectedMarkers()]);
- });
- if (this.markers[i]) {
- this.removeMarkers([i]);
- }
- this.markers[i] = {element: marker, config: markerConfig};
- }
- }
- },
- repositionMarkers: function() {
- var i,
- point;
- for (i in this.markers) {
- point = this.getMarkerPosition( this.markers[i].config );
- if (point !== false) {
- this.markers[i].element.setStyle({cx: point.x, cy: point.y});
- }
- }
- },
- getMarkerPosition: function(markerConfig) {
- if (jvm.WorldMap.maps[this.params.map].projection) {
- return this.latLngToPoint.apply(this, markerConfig.latLng || [0, 0]);
- } else {
- return {
- x: markerConfig.coords[0]*this.scale + this.transX*this.scale,
- y: markerConfig.coords[1]*this.scale + this.transY*this.scale
- };
- }
- },
-
- addMarker: function(key, marker, seriesData){
- var markers = {},
- data = [],
- values,
- i,
- seriesData = seriesData || [];
- markers[key] = marker;
- for (i = 0; i < seriesData.length; i++) {
- values = {};
- values[key] = seriesData[i];
- data.push(values);
- }
- this.addMarkers(markers, data);
- },
-
- addMarkers: function(markers, seriesData){
- var i;
- seriesData = seriesData || [];
- this.createMarkers(markers);
- for (i = 0; i < seriesData.length; i++) {
- this.series.markers[i].setValues(seriesData[i] || {});
- };
- },
-
- removeMarkers: function(markers){
- var i;
- for (i = 0; i < markers.length; i++) {
- this.markers[ markers[i] ].element.remove();
- delete this.markers[ markers[i] ];
- };
- },
-
- removeAllMarkers: function(){
- var i,
- markers = [];
- for (i in this.markers) {
- markers.push(i);
- }
- this.removeMarkers(markers)
- },
-
- latLngToPoint: function(lat, lng) {
- var point,
- proj = jvm.WorldMap.maps[this.params.map].projection,
- centralMeridian = proj.centralMeridian,
- width = this.width - this.baseTransX * 2 * this.baseScale,
- height = this.height - this.baseTransY * 2 * this.baseScale,
- inset,
- bbox,
- scaleFactor = this.scale / this.baseScale;
- if (lng < (-180 + centralMeridian)) {
- lng += 360;
- }
- point = jvm.Proj[proj.type](lat, lng, centralMeridian);
- inset = this.getInsetForPoint(point.x, point.y);
- if (inset) {
- bbox = inset.bbox;
- point.x = (point.x - bbox[0].x) / (bbox[1].x - bbox[0].x) * inset.width * this.scale;
- point.y = (point.y - bbox[0].y) / (bbox[1].y - bbox[0].y) * inset.height * this.scale;
- return {
- x: point.x + this.transX*this.scale + inset.left*this.scale,
- y: point.y + this.transY*this.scale + inset.top*this.scale
- };
- } else {
- return false;
- }
- },
-
- pointToLatLng: function(x, y) {
- var proj = jvm.WorldMap.maps[this.params.map].projection,
- centralMeridian = proj.centralMeridian,
- insets = jvm.WorldMap.maps[this.params.map].insets,
- i,
- inset,
- bbox,
- nx,
- ny;
- for (i = 0; i < insets.length; i++) {
- inset = insets[i];
- bbox = inset.bbox;
- nx = x - (this.transX*this.scale + inset.left*this.scale);
- ny = y - (this.transY*this.scale + inset.top*this.scale);
- nx = (nx / (inset.width * this.scale)) * (bbox[1].x - bbox[0].x) + bbox[0].x;
- ny = (ny / (inset.height * this.scale)) * (bbox[1].y - bbox[0].y) + bbox[0].y;
- if (nx > bbox[0].x && nx < bbox[1].x && ny > bbox[0].y && ny < bbox[1].y) {
- return jvm.Proj[proj.type + '_inv'](nx, -ny, centralMeridian);
- }
- }
- return false;
- },
- getInsetForPoint: function(x, y){
- var insets = jvm.WorldMap.maps[this.params.map].insets,
- i,
- bbox;
- for (i = 0; i < insets.length; i++) {
- bbox = insets[i].bbox;
- if (x > bbox[0].x && x < bbox[1].x && y > bbox[0].y && y < bbox[1].y) {
- return insets[i];
- }
- }
- },
- createSeries: function(){
- var i,
- key;
- this.series = {
- markers: [],
- regions: []
- };
- for (key in this.params.series) {
- for (i = 0; i < this.params.series[key].length; i++) {
- this.series[key][i] = new jvm.DataSeries(
- this.params.series[key][i],
- this[key]
- );
- }
- }
- },
-
- remove: function(){
- this.label.remove();
- this.container.remove();
- jvm.$(window).unbind('resize', this.onResize);
- }
- };
- jvm.WorldMap.maps = {};
- jvm.WorldMap.defaultParams = {
- map: 'world_mill_en',
- backgroundColor: '#505050',
- zoomButtons: true,
- zoomOnScroll: true,
- zoomMax: 8,
- zoomMin: 1,
- zoomStep: 1.6,
- regionsSelectable: false,
- markersSelectable: false,
- bindTouchEvents: true,
- regionStyle: {
- initial: {
- fill: 'white',
- "fill-opacity": 1,
- stroke: 'none',
- "stroke-width": 0,
- "stroke-opacity": 1
- },
- hover: {
- "fill-opacity": 0.8
- },
- selected: {
- fill: 'yellow'
- },
- selectedHover: {
- }
- },
- markerStyle: {
- initial: {
- fill: 'grey',
- stroke: '#505050',
- "fill-opacity": 1,
- "stroke-width": 1,
- "stroke-opacity": 1,
- r: 5
- },
- hover: {
- stroke: 'black',
- "stroke-width": 2
- },
- selected: {
- fill: 'blue'
- },
- selectedHover: {
- }
- }
- };
- jvm.WorldMap.apiEvents = {
- onRegionLabelShow: 'regionLabelShow',
- onRegionOver: 'regionOver',
- onRegionOut: 'regionOut',
- onRegionClick: 'regionClick',
- onRegionSelected: 'regionSelected',
- onMarkerLabelShow: 'markerLabelShow',
- onMarkerOver: 'markerOver',
- onMarkerOut: 'markerOut',
- onMarkerClick: 'markerClick',
- onMarkerSelected: 'markerSelected',
- onViewportChange: 'viewportChange'
- };
|