svgmap 2.14.0 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/demo/react/app/package-lock.json +37 -12
- package/dist/svgMap.css +17 -2
- package/dist/svgMap.js +27 -8
- package/dist/svgMap.min.css +1 -1
- package/dist/svgMap.min.js +1 -1
- package/package.json +1 -1
- package/src/js/svgMap.js +27 -8
- package/src/scss/map.scss +18 -2
- package/src/scss/variables.scss +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svgmap",
|
|
3
3
|
"description": "svgMap is a JavaScript library that lets you easily create an interactable world map comparing customizable data for each country.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.16.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/svgMap.min.js",
|
package/src/js/svgMap.js
CHANGED
|
@@ -45,6 +45,9 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
45
45
|
// The message to show for MacOS
|
|
46
46
|
mouseWheelKeyMessageMac: 'Press the [COMMAND] key to zoom',
|
|
47
47
|
|
|
48
|
+
// Position of the zoom buttons
|
|
49
|
+
zoomButtonsPosition: 'bottomLeft',
|
|
50
|
+
|
|
48
51
|
// Data colors
|
|
49
52
|
colorMax: '#CC0033',
|
|
50
53
|
colorMin: '#FFE5D9',
|
|
@@ -88,6 +91,9 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
88
91
|
|
|
89
92
|
// Set to true to show a drop down menu with the continents
|
|
90
93
|
showContinentSelector: false,
|
|
94
|
+
|
|
95
|
+
// Reset zoom on resize
|
|
96
|
+
resetZoomOnResize: false,
|
|
91
97
|
};
|
|
92
98
|
|
|
93
99
|
this.options = Object.assign({}, defaultOptions, options || {});
|
|
@@ -405,9 +411,9 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
405
411
|
});
|
|
406
412
|
|
|
407
413
|
data.data[data.applyData].thresholdMax &&
|
|
408
|
-
|
|
414
|
+
(max = Math.min(max, data.data[data.applyData].thresholdMax));
|
|
409
415
|
data.data[data.applyData].thresholdMin &&
|
|
410
|
-
|
|
416
|
+
(min = Math.max(min, data.data[data.applyData].thresholdMin));
|
|
411
417
|
|
|
412
418
|
// Loop through countries and set colors
|
|
413
419
|
Object.keys(this.countries).forEach(
|
|
@@ -809,6 +815,7 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
809
815
|
'svgMap-map-controls-wrapper',
|
|
810
816
|
this.mapWrapper
|
|
811
817
|
);
|
|
818
|
+
mapControlsWrapper.classList.add('svgMap-controls-position-' + this.options.zoomButtonsPosition);
|
|
812
819
|
var zoomContainer = this.createElement(
|
|
813
820
|
'div',
|
|
814
821
|
'svgMap-map-controls-zoom',
|
|
@@ -1097,6 +1104,12 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
1097
1104
|
|
|
1098
1105
|
// Initial zoom statuses
|
|
1099
1106
|
this.setControlStatuses();
|
|
1107
|
+
|
|
1108
|
+
// Zoom reset on resize
|
|
1109
|
+
if (this.options.resetZoomOnResize) {
|
|
1110
|
+
const resizeObserver = new ResizeObserver(() => this.mapReset());
|
|
1111
|
+
resizeObserver.observe(this.mapWrapper);
|
|
1112
|
+
}
|
|
1100
1113
|
};
|
|
1101
1114
|
|
|
1102
1115
|
// Create the tooltip content
|
|
@@ -1171,7 +1184,7 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
1171
1184
|
if ((value !== undefined && this.options.hideMissingData === true) || this.options.hideMissingData === false) {
|
|
1172
1185
|
item.floatingNumbers && (value = value.toFixed(1));
|
|
1173
1186
|
item.thousandSeparator &&
|
|
1174
|
-
|
|
1187
|
+
(value = this.numberWithCommas(value, item.thousandSeparator));
|
|
1175
1188
|
value = item.format
|
|
1176
1189
|
? item.format.replace('{0}', '<span>' + value + '</span>')
|
|
1177
1190
|
: '<span>' + value + '</span>';
|
|
@@ -1217,8 +1230,8 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
1217
1230
|
svgMap.prototype.zoomMap = function (direction) {
|
|
1218
1231
|
if (
|
|
1219
1232
|
this[
|
|
1220
|
-
|
|
1221
|
-
|
|
1233
|
+
'zoomControl' + direction.charAt(0).toUpperCase() + direction.slice(1)
|
|
1234
|
+
].classList.contains('svgMap-disabled')
|
|
1222
1235
|
) {
|
|
1223
1236
|
return false;
|
|
1224
1237
|
}
|
|
@@ -1239,6 +1252,12 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
1239
1252
|
}
|
|
1240
1253
|
};
|
|
1241
1254
|
|
|
1255
|
+
// Zoom reset
|
|
1256
|
+
svgMap.prototype.mapReset = function () {
|
|
1257
|
+
this.mapPanZoom.resize()
|
|
1258
|
+
this.zoomMap('reset')
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1242
1261
|
// Zoom to Contient
|
|
1243
1262
|
|
|
1244
1263
|
svgMap.prototype.zoomContinent = function (contientIso) {
|
|
@@ -1275,7 +1294,7 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
1275
1294
|
}
|
|
1276
1295
|
|
|
1277
1296
|
this.autoHideMouseWheelNoticeTimeout &&
|
|
1278
|
-
|
|
1297
|
+
clearTimeout(this.autoHideMouseWheelNoticeTimeout);
|
|
1279
1298
|
this.autoHideMouseWheelNoticeTimeout = setTimeout(
|
|
1280
1299
|
function () {
|
|
1281
1300
|
this.hideMouseWheelZoomNotice();
|
|
@@ -1291,7 +1310,7 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
1291
1310
|
svgMap.prototype.hideMouseWheelZoomNotice = function () {
|
|
1292
1311
|
this.wrapper.classList.remove('svgMap-block-zoom-notice-active');
|
|
1293
1312
|
this.autoHideMouseWheelNoticeTimeout &&
|
|
1294
|
-
|
|
1313
|
+
clearTimeout(this.autoHideMouseWheelNoticeTimeout);
|
|
1295
1314
|
};
|
|
1296
1315
|
|
|
1297
1316
|
// Block shing the zoom wheel notice for some time
|
|
@@ -1299,7 +1318,7 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
1299
1318
|
svgMap.prototype.blockMouseWheelZoomNotice = function (duration) {
|
|
1300
1319
|
this.mouseWheelNoticeJustHidden = true;
|
|
1301
1320
|
this.mouseWheelNoticeJustHiddenTimeout &&
|
|
1302
|
-
|
|
1321
|
+
clearTimeout(this.mouseWheelNoticeJustHiddenTimeout);
|
|
1303
1322
|
this.mouseWheelNoticeJustHiddenTimeout = setTimeout(
|
|
1304
1323
|
function () {
|
|
1305
1324
|
this.mouseWheelNoticeJustHidden = false;
|
package/src/scss/map.scss
CHANGED
|
@@ -70,14 +70,29 @@
|
|
|
70
70
|
|
|
71
71
|
.svgMap-map-controls-wrapper {
|
|
72
72
|
position: absolute;
|
|
73
|
-
bottom: 10px;
|
|
74
|
-
left: 10px;
|
|
75
73
|
z-index: 1;
|
|
76
74
|
display: flex;
|
|
77
75
|
overflow: hidden;
|
|
78
76
|
border-radius: 2px;
|
|
79
77
|
box-shadow: $mapControlsBoxShadow;
|
|
80
78
|
|
|
79
|
+
&.svgMap-controls-position-bottomLeft {
|
|
80
|
+
bottom: 10px;
|
|
81
|
+
left: 10px;
|
|
82
|
+
}
|
|
83
|
+
&.svgMap-controls-position-bottomRight {
|
|
84
|
+
bottom: 10px;
|
|
85
|
+
right: 10px;
|
|
86
|
+
}
|
|
87
|
+
&.svgMap-controls-position-topLeft {
|
|
88
|
+
top: 10px;
|
|
89
|
+
left: 10px;
|
|
90
|
+
}
|
|
91
|
+
&.svgMap-controls-position-topRight {
|
|
92
|
+
top: 10px;
|
|
93
|
+
right: 10px;
|
|
94
|
+
}
|
|
95
|
+
|
|
81
96
|
&.svgMap-disabled {
|
|
82
97
|
display: none;
|
|
83
98
|
}
|
|
@@ -214,6 +229,7 @@
|
|
|
214
229
|
// Countries
|
|
215
230
|
|
|
216
231
|
.svgMap-country {
|
|
232
|
+
fill: $colorNoData;
|
|
217
233
|
stroke: $countryStrokeColor;
|
|
218
234
|
stroke-width: 1;
|
|
219
235
|
stroke-linejoin: round;
|