67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
import { loadJQueryMouseWheel } from "@react-jvectormap/jquery-mousewheel";
|
|
|
|
/**
|
|
* jVectorMap version 2.0.5
|
|
*
|
|
* Copyright 2011-2014, Kirill Lebedev
|
|
*
|
|
* inspired from: https://github.com/alex-pex/jvectormap/blob/master/jvectormap-next/src/jquery-jvectormap.js
|
|
*/
|
|
export const loadJVectorMap = ($) =>
|
|
(function (factory) {
|
|
factory($);
|
|
})(function ($) {
|
|
loadJQueryMouseWheel($);
|
|
jvm.$ = $;
|
|
window.jvm = jvm;
|
|
|
|
const apiParams = {
|
|
set: {
|
|
colors: 1,
|
|
values: 1,
|
|
backgroundColor: 1,
|
|
scaleColors: 1,
|
|
normalizeFunction: 1,
|
|
focus: 1,
|
|
},
|
|
get: {
|
|
selectedRegions: 1,
|
|
selectedMarkers: 1,
|
|
mapObject: 1,
|
|
regionName: 1,
|
|
},
|
|
};
|
|
|
|
$.fn.multiMap = function (options) {
|
|
options.container = this;
|
|
new jvm.MultiMap(options);
|
|
return this;
|
|
};
|
|
|
|
$.fn.vectorMap = function (options) {
|
|
let map, methodName;
|
|
map = this.children(".jvectormap-container").data("mapObject");
|
|
if (options === "remove") {
|
|
this.remove();
|
|
} else if (options === "addMap") {
|
|
jvm.Map.maps[arguments[1]] = arguments[2];
|
|
} else if (
|
|
(options === "set" || options === "get") &&
|
|
apiParams[options][arguments[1]]
|
|
) {
|
|
methodName =
|
|
arguments[1].charAt(0).toUpperCase() + arguments[1].substr(1);
|
|
return map[options + methodName].apply(
|
|
map,
|
|
Array.prototype.slice.call(arguments, 2),
|
|
);
|
|
} else if (!map) {
|
|
options = options || {};
|
|
options.container = this;
|
|
map = new jvm.Map(options);
|
|
}
|
|
|
|
return this;
|
|
};
|
|
});
|