react-simple-maps 2.3.0 → 3.0.0-beta.3
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/dist/index.es.js +382 -244
- package/dist/index.js +428 -308
- package/dist/index.umd.js +1 -1
- package/package.json +19 -20
package/dist/index.js
CHANGED
|
@@ -1,110 +1,198 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { createContext, useMemo, useCallback, useContext, useState, useEffect, memo, useRef, Fragment } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as d3Geo from 'd3-geo';
|
|
4
|
+
import { geoGraticule } from 'd3-geo';
|
|
5
|
+
import { feature, mesh } from 'topojson-client';
|
|
6
|
+
import { zoom, zoomIdentity } from 'd3-zoom';
|
|
7
|
+
import { select } from 'd3-selection';
|
|
8
|
+
|
|
9
|
+
function ownKeys(object, enumerableOnly) {
|
|
10
|
+
var keys = Object.keys(object);
|
|
11
|
+
|
|
12
|
+
if (Object.getOwnPropertySymbols) {
|
|
13
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
14
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
15
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
16
|
+
})), keys.push.apply(keys, symbols);
|
|
17
|
+
}
|
|
2
18
|
|
|
3
|
-
|
|
19
|
+
return keys;
|
|
20
|
+
}
|
|
4
21
|
|
|
5
|
-
function
|
|
22
|
+
function _objectSpread2(target) {
|
|
23
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
24
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
25
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
26
|
+
_defineProperty(target, key, source[key]);
|
|
27
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
28
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
6
31
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var PropTypes = _interopDefault(require('prop-types'));
|
|
10
|
-
var d3Geo = require('d3-geo');
|
|
11
|
-
var topojsonClient = require('topojson-client');
|
|
12
|
-
var d3Zoom = require('d3-zoom');
|
|
13
|
-
var d3Selection = require('d3-selection');
|
|
32
|
+
return target;
|
|
33
|
+
}
|
|
14
34
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
35
|
+
function _typeof(obj) {
|
|
36
|
+
"@babel/helpers - typeof";
|
|
37
|
+
|
|
38
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
39
|
+
return typeof obj;
|
|
40
|
+
} : function (obj) {
|
|
41
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
42
|
+
}, _typeof(obj);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function _defineProperty(obj, key, value) {
|
|
46
|
+
if (key in obj) {
|
|
47
|
+
Object.defineProperty(obj, key, {
|
|
48
|
+
value: value,
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
obj[key] = value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return obj;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _extends() {
|
|
61
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
62
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
63
|
+
var source = arguments[i];
|
|
18
64
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
65
|
+
for (var key in source) {
|
|
66
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
67
|
+
target[key] = source[key];
|
|
68
|
+
}
|
|
22
69
|
}
|
|
23
70
|
}
|
|
71
|
+
|
|
72
|
+
return target;
|
|
73
|
+
};
|
|
74
|
+
return _extends.apply(this, arguments);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
78
|
+
if (source == null) return {};
|
|
79
|
+
var target = {};
|
|
80
|
+
var sourceKeys = Object.keys(source);
|
|
81
|
+
var key, i;
|
|
82
|
+
|
|
83
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
84
|
+
key = sourceKeys[i];
|
|
85
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
86
|
+
target[key] = source[key];
|
|
24
87
|
}
|
|
25
88
|
|
|
26
89
|
return target;
|
|
27
|
-
}
|
|
90
|
+
}
|
|
28
91
|
|
|
29
|
-
|
|
30
|
-
|
|
92
|
+
function _objectWithoutProperties(source, excluded) {
|
|
93
|
+
if (source == null) return {};
|
|
94
|
+
|
|
95
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
96
|
+
|
|
97
|
+
var key, i;
|
|
31
98
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
99
|
+
if (Object.getOwnPropertySymbols) {
|
|
100
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
101
|
+
|
|
102
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
103
|
+
key = sourceSymbolKeys[i];
|
|
104
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
105
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
106
|
+
target[key] = source[key];
|
|
107
|
+
}
|
|
36
108
|
}
|
|
37
109
|
|
|
38
110
|
return target;
|
|
39
|
-
}
|
|
111
|
+
}
|
|
40
112
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var _n = true;
|
|
45
|
-
var _d = false;
|
|
46
|
-
var _e = undefined;
|
|
113
|
+
function _slicedToArray(arr, i) {
|
|
114
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
115
|
+
}
|
|
47
116
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
117
|
+
function _arrayWithHoles(arr) {
|
|
118
|
+
if (Array.isArray(arr)) return arr;
|
|
119
|
+
}
|
|
51
120
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
121
|
+
function _iterableToArrayLimit(arr, i) {
|
|
122
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
123
|
+
|
|
124
|
+
if (_i == null) return;
|
|
125
|
+
var _arr = [];
|
|
126
|
+
var _n = true;
|
|
127
|
+
var _d = false;
|
|
128
|
+
|
|
129
|
+
var _s, _e;
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
133
|
+
_arr.push(_s.value);
|
|
134
|
+
|
|
135
|
+
if (i && _arr.length === i) break;
|
|
136
|
+
}
|
|
137
|
+
} catch (err) {
|
|
138
|
+
_d = true;
|
|
139
|
+
_e = err;
|
|
140
|
+
} finally {
|
|
141
|
+
try {
|
|
142
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
57
143
|
} finally {
|
|
58
|
-
|
|
59
|
-
if (!_n && _i["return"]) _i["return"]();
|
|
60
|
-
} finally {
|
|
61
|
-
if (_d) throw _e;
|
|
62
|
-
}
|
|
144
|
+
if (_d) throw _e;
|
|
63
145
|
}
|
|
64
|
-
|
|
65
|
-
return _arr;
|
|
66
146
|
}
|
|
67
147
|
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
return arr;
|
|
71
|
-
} else if (Symbol.iterator in Object(arr)) {
|
|
72
|
-
return sliceIterator(arr, i);
|
|
73
|
-
} else {
|
|
74
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}();
|
|
148
|
+
return _arr;
|
|
149
|
+
}
|
|
78
150
|
|
|
79
|
-
|
|
80
|
-
|
|
151
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
152
|
+
if (!o) return;
|
|
153
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
154
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
155
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
156
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
157
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function _arrayLikeToArray(arr, len) {
|
|
161
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
162
|
+
|
|
163
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
164
|
+
|
|
165
|
+
return arr2;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function _nonIterableRest() {
|
|
169
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
170
|
+
}
|
|
81
171
|
|
|
172
|
+
var _excluded$9 = ["width", "height", "projection", "projectionConfig"];
|
|
82
173
|
|
|
83
|
-
var
|
|
174
|
+
var geoPath = d3Geo.geoPath,
|
|
175
|
+
projections = _objectWithoutProperties(d3Geo, ["geoPath"]);
|
|
176
|
+
|
|
177
|
+
var MapContext = createContext();
|
|
84
178
|
|
|
85
179
|
var makeProjection = function makeProjection(_ref) {
|
|
86
180
|
var _ref$projectionConfig = _ref.projectionConfig,
|
|
87
|
-
projectionConfig = _ref$projectionConfig ===
|
|
181
|
+
projectionConfig = _ref$projectionConfig === void 0 ? {} : _ref$projectionConfig,
|
|
88
182
|
_ref$projection = _ref.projection,
|
|
89
|
-
projection = _ref$projection ===
|
|
183
|
+
projection = _ref$projection === void 0 ? "geoEqualEarth" : _ref$projection,
|
|
90
184
|
_ref$width = _ref.width,
|
|
91
|
-
width = _ref$width ===
|
|
185
|
+
width = _ref$width === void 0 ? 800 : _ref$width,
|
|
92
186
|
_ref$height = _ref.height,
|
|
93
|
-
height = _ref$height ===
|
|
94
|
-
|
|
187
|
+
height = _ref$height === void 0 ? 600 : _ref$height;
|
|
95
188
|
var isFunc = typeof projection === "function";
|
|
96
|
-
|
|
97
189
|
if (isFunc) return projection;
|
|
98
|
-
|
|
99
190
|
var proj = projections[projection]().translate([width / 2, height / 2]);
|
|
100
|
-
|
|
101
191
|
var supported = [proj.center ? "center" : null, proj.rotate ? "rotate" : null, proj.scale ? "scale" : null, proj.parallels ? "parallels" : null];
|
|
102
|
-
|
|
103
192
|
supported.forEach(function (d) {
|
|
104
193
|
if (!d) return;
|
|
105
194
|
proj = proj[d](projectionConfig[d] || proj[d]());
|
|
106
195
|
});
|
|
107
|
-
|
|
108
196
|
return proj;
|
|
109
197
|
};
|
|
110
198
|
|
|
@@ -113,27 +201,26 @@ var MapProvider = function MapProvider(_ref2) {
|
|
|
113
201
|
height = _ref2.height,
|
|
114
202
|
projection = _ref2.projection,
|
|
115
203
|
projectionConfig = _ref2.projectionConfig,
|
|
116
|
-
restProps =
|
|
204
|
+
restProps = _objectWithoutProperties(_ref2, _excluded$9);
|
|
117
205
|
|
|
118
206
|
var _ref3 = projectionConfig.center || [],
|
|
119
|
-
_ref4 =
|
|
207
|
+
_ref4 = _slicedToArray(_ref3, 2),
|
|
120
208
|
cx = _ref4[0],
|
|
121
209
|
cy = _ref4[1];
|
|
122
210
|
|
|
123
211
|
var _ref5 = projectionConfig.rotate || [],
|
|
124
|
-
_ref6 =
|
|
212
|
+
_ref6 = _slicedToArray(_ref5, 3),
|
|
125
213
|
rx = _ref6[0],
|
|
126
214
|
ry = _ref6[1],
|
|
127
215
|
rz = _ref6[2];
|
|
128
216
|
|
|
129
217
|
var _ref7 = projectionConfig.parallels || [],
|
|
130
|
-
_ref8 =
|
|
218
|
+
_ref8 = _slicedToArray(_ref7, 2),
|
|
131
219
|
p1 = _ref8[0],
|
|
132
220
|
p2 = _ref8[1];
|
|
133
221
|
|
|
134
222
|
var s = projectionConfig.scale || null;
|
|
135
|
-
|
|
136
|
-
var projMemo = React.useMemo(function () {
|
|
223
|
+
var projMemo = useMemo(function () {
|
|
137
224
|
return makeProjection({
|
|
138
225
|
projectionConfig: {
|
|
139
226
|
center: cx || cx === 0 || cy || cy === 0 ? [cx, cy] : null,
|
|
@@ -146,10 +233,8 @@ var MapProvider = function MapProvider(_ref2) {
|
|
|
146
233
|
height: height
|
|
147
234
|
});
|
|
148
235
|
}, [width, height, projection, cx, cy, rx, ry, rz, p1, p2, s]);
|
|
149
|
-
|
|
150
|
-
var
|
|
151
|
-
|
|
152
|
-
var value = React.useMemo(function () {
|
|
236
|
+
var proj = useCallback(projMemo, [projMemo]);
|
|
237
|
+
var value = useMemo(function () {
|
|
153
238
|
return {
|
|
154
239
|
width: width,
|
|
155
240
|
height: height,
|
|
@@ -157,8 +242,9 @@ var MapProvider = function MapProvider(_ref2) {
|
|
|
157
242
|
path: geoPath().projection(proj)
|
|
158
243
|
};
|
|
159
244
|
}, [width, height, proj]);
|
|
160
|
-
|
|
161
|
-
|
|
245
|
+
return /*#__PURE__*/React.createElement(MapContext.Provider, _extends({
|
|
246
|
+
value: value
|
|
247
|
+
}, restProps));
|
|
162
248
|
};
|
|
163
249
|
|
|
164
250
|
MapProvider.propTypes = {
|
|
@@ -168,32 +254,30 @@ MapProvider.propTypes = {
|
|
|
168
254
|
projectionConfig: PropTypes.object
|
|
169
255
|
};
|
|
170
256
|
|
|
257
|
+
var _excluded$8 = ["width", "height", "projection", "projectionConfig", "className"];
|
|
258
|
+
|
|
171
259
|
var ComposableMap = function ComposableMap(_ref) {
|
|
172
260
|
var _ref$width = _ref.width,
|
|
173
|
-
width = _ref$width ===
|
|
261
|
+
width = _ref$width === void 0 ? 800 : _ref$width,
|
|
174
262
|
_ref$height = _ref.height,
|
|
175
|
-
height = _ref$height ===
|
|
263
|
+
height = _ref$height === void 0 ? 600 : _ref$height,
|
|
176
264
|
_ref$projection = _ref.projection,
|
|
177
|
-
projection = _ref$projection ===
|
|
265
|
+
projection = _ref$projection === void 0 ? "geoEqualEarth" : _ref$projection,
|
|
178
266
|
_ref$projectionConfig = _ref.projectionConfig,
|
|
179
|
-
projectionConfig = _ref$projectionConfig ===
|
|
267
|
+
projectionConfig = _ref$projectionConfig === void 0 ? {} : _ref$projectionConfig,
|
|
180
268
|
_ref$className = _ref.className,
|
|
181
|
-
className = _ref$className ===
|
|
182
|
-
restProps =
|
|
183
|
-
|
|
184
|
-
return
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
viewBox: "0 0 " + width + " " + height,
|
|
194
|
-
className: "rsm-svg " + className
|
|
195
|
-
}, restProps))
|
|
196
|
-
);
|
|
269
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
270
|
+
restProps = _objectWithoutProperties(_ref, _excluded$8);
|
|
271
|
+
|
|
272
|
+
return /*#__PURE__*/React.createElement(MapProvider, {
|
|
273
|
+
width: width,
|
|
274
|
+
height: height,
|
|
275
|
+
projection: projection,
|
|
276
|
+
projectionConfig: projectionConfig
|
|
277
|
+
}, /*#__PURE__*/React.createElement("svg", _extends({
|
|
278
|
+
viewBox: "0 0 ".concat(width, " ").concat(height),
|
|
279
|
+
className: "rsm-svg ".concat(className)
|
|
280
|
+
}, restProps)));
|
|
197
281
|
};
|
|
198
282
|
|
|
199
283
|
ComposableMap.propTypes = {
|
|
@@ -209,66 +293,70 @@ function getCoords(w, h, t) {
|
|
|
209
293
|
var yOffset = (h * t.k - h) / 2;
|
|
210
294
|
return [w / 2 - (xOffset + t.x) / t.k, h / 2 - (yOffset + t.y) / t.k];
|
|
211
295
|
}
|
|
212
|
-
|
|
213
296
|
function fetchGeographies(url) {
|
|
214
297
|
return fetch(url).then(function (res) {
|
|
215
298
|
if (!res.ok) {
|
|
216
299
|
throw Error(res.statusText);
|
|
217
300
|
}
|
|
301
|
+
|
|
218
302
|
return res.json();
|
|
219
|
-
})
|
|
303
|
+
})["catch"](function (error) {
|
|
220
304
|
console.log("There was a problem when fetching the data: ", error);
|
|
221
305
|
});
|
|
222
306
|
}
|
|
223
|
-
|
|
224
307
|
function getFeatures(geographies, parseGeographies) {
|
|
225
308
|
var isTopojson = geographies.type === "Topology";
|
|
309
|
+
|
|
226
310
|
if (!isTopojson) {
|
|
227
311
|
return parseGeographies ? parseGeographies(geographies.features || geographies) : geographies.features || geographies;
|
|
228
312
|
}
|
|
229
|
-
|
|
313
|
+
|
|
314
|
+
var feats = feature(geographies, geographies.objects[Object.keys(geographies.objects)[0]]).features;
|
|
230
315
|
return parseGeographies ? parseGeographies(feats) : feats;
|
|
231
316
|
}
|
|
232
|
-
|
|
233
317
|
function getMesh(geographies) {
|
|
234
318
|
var isTopojson = geographies.type === "Topology";
|
|
235
319
|
if (!isTopojson) return null;
|
|
236
|
-
var outline =
|
|
320
|
+
var outline = mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], function (a, b) {
|
|
237
321
|
return a === b;
|
|
238
322
|
});
|
|
239
|
-
var borders =
|
|
323
|
+
var borders = mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], function (a, b) {
|
|
240
324
|
return a !== b;
|
|
241
325
|
});
|
|
242
|
-
return {
|
|
326
|
+
return {
|
|
327
|
+
outline: outline,
|
|
328
|
+
borders: borders
|
|
329
|
+
};
|
|
243
330
|
}
|
|
244
|
-
|
|
245
331
|
function prepareMesh(outline, borders, path) {
|
|
246
332
|
return outline && borders ? {
|
|
247
|
-
outline:
|
|
248
|
-
|
|
333
|
+
outline: _objectSpread2(_objectSpread2({}, outline), {}, {
|
|
334
|
+
rsmKey: "outline",
|
|
335
|
+
svgPath: path(outline)
|
|
336
|
+
}),
|
|
337
|
+
borders: _objectSpread2(_objectSpread2({}, borders), {}, {
|
|
338
|
+
rsmKey: "borders",
|
|
339
|
+
svgPath: path(borders)
|
|
340
|
+
})
|
|
249
341
|
} : {};
|
|
250
342
|
}
|
|
251
|
-
|
|
252
343
|
function prepareFeatures(geographies, path) {
|
|
253
344
|
return geographies ? geographies.map(function (d, i) {
|
|
254
|
-
return
|
|
255
|
-
rsmKey: "geo-"
|
|
345
|
+
return _objectSpread2(_objectSpread2({}, d), {}, {
|
|
346
|
+
rsmKey: "geo-".concat(i),
|
|
256
347
|
svgPath: path(d)
|
|
257
348
|
});
|
|
258
349
|
}) : [];
|
|
259
350
|
}
|
|
260
|
-
|
|
261
351
|
function createConnectorPath() {
|
|
262
352
|
var dx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 30;
|
|
263
353
|
var dy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 30;
|
|
264
354
|
var curve = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;
|
|
265
|
-
|
|
266
355
|
var curvature = Array.isArray(curve) ? curve : [curve, curve];
|
|
267
356
|
var curveX = dx / 2 * curvature[0];
|
|
268
357
|
var curveY = dy / 2 * curvature[1];
|
|
269
|
-
return "M"
|
|
358
|
+
return "M".concat(0, ",", 0, " Q", -dx / 2 - curveX, ",").concat(-dy / 2 + curveY, " ").concat(-dx, ",").concat(-dy);
|
|
270
359
|
}
|
|
271
|
-
|
|
272
360
|
function isString(geo) {
|
|
273
361
|
return typeof geo === "string";
|
|
274
362
|
}
|
|
@@ -277,17 +365,16 @@ function useGeographies(_ref) {
|
|
|
277
365
|
var geography = _ref.geography,
|
|
278
366
|
parseGeographies = _ref.parseGeographies;
|
|
279
367
|
|
|
280
|
-
var _useContext =
|
|
368
|
+
var _useContext = useContext(MapContext),
|
|
281
369
|
path = _useContext.path;
|
|
282
370
|
|
|
283
|
-
var _useState =
|
|
284
|
-
_useState2 =
|
|
371
|
+
var _useState = useState({}),
|
|
372
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
285
373
|
output = _useState2[0],
|
|
286
374
|
setOutput = _useState2[1];
|
|
287
375
|
|
|
288
|
-
|
|
289
|
-
if (typeof window === "undefined") return;
|
|
290
|
-
|
|
376
|
+
useEffect(function () {
|
|
377
|
+
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "undefined") return;
|
|
291
378
|
if (!geography) return;
|
|
292
379
|
|
|
293
380
|
if (isString(geography)) {
|
|
@@ -307,7 +394,7 @@ function useGeographies(_ref) {
|
|
|
307
394
|
}
|
|
308
395
|
}, [geography, parseGeographies]);
|
|
309
396
|
|
|
310
|
-
var _useMemo =
|
|
397
|
+
var _useMemo = useMemo(function () {
|
|
311
398
|
var mesh = output.mesh || {};
|
|
312
399
|
var preparedMesh = prepareMesh(mesh.outline, mesh.borders, path);
|
|
313
400
|
return {
|
|
@@ -320,31 +407,44 @@ function useGeographies(_ref) {
|
|
|
320
407
|
outline = _useMemo.outline,
|
|
321
408
|
borders = _useMemo.borders;
|
|
322
409
|
|
|
323
|
-
return {
|
|
410
|
+
return {
|
|
411
|
+
geographies: geographies,
|
|
412
|
+
outline: outline,
|
|
413
|
+
borders: borders
|
|
414
|
+
};
|
|
324
415
|
}
|
|
325
416
|
|
|
417
|
+
var _excluded$7 = ["geography", "children", "parseGeographies", "className"];
|
|
418
|
+
|
|
326
419
|
var Geographies = function Geographies(_ref) {
|
|
327
420
|
var geography = _ref.geography,
|
|
328
421
|
children = _ref.children,
|
|
329
422
|
parseGeographies = _ref.parseGeographies,
|
|
330
423
|
_ref$className = _ref.className,
|
|
331
|
-
className = _ref$className ===
|
|
332
|
-
restProps =
|
|
424
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
425
|
+
restProps = _objectWithoutProperties(_ref, _excluded$7);
|
|
333
426
|
|
|
334
|
-
var _useContext =
|
|
427
|
+
var _useContext = useContext(MapContext),
|
|
335
428
|
path = _useContext.path,
|
|
336
429
|
projection = _useContext.projection;
|
|
337
430
|
|
|
338
|
-
var _useGeographies = useGeographies({
|
|
431
|
+
var _useGeographies = useGeographies({
|
|
432
|
+
geography: geography,
|
|
433
|
+
parseGeographies: parseGeographies
|
|
434
|
+
}),
|
|
339
435
|
geographies = _useGeographies.geographies,
|
|
340
436
|
outline = _useGeographies.outline,
|
|
341
437
|
borders = _useGeographies.borders;
|
|
342
438
|
|
|
343
|
-
return
|
|
344
|
-
"
|
|
345
|
-
|
|
346
|
-
geographies
|
|
347
|
-
|
|
439
|
+
return /*#__PURE__*/React.createElement("g", _extends({
|
|
440
|
+
className: "rsm-geographies ".concat(className)
|
|
441
|
+
}, restProps), geographies && geographies.length > 0 && children({
|
|
442
|
+
geographies: geographies,
|
|
443
|
+
outline: outline,
|
|
444
|
+
borders: borders,
|
|
445
|
+
path: path,
|
|
446
|
+
projection: projection
|
|
447
|
+
}));
|
|
348
448
|
};
|
|
349
449
|
|
|
350
450
|
Geographies.propTypes = {
|
|
@@ -354,6 +454,8 @@ Geographies.propTypes = {
|
|
|
354
454
|
className: PropTypes.string
|
|
355
455
|
};
|
|
356
456
|
|
|
457
|
+
var _excluded$6 = ["geography", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"];
|
|
458
|
+
|
|
357
459
|
var Geography = function Geography(_ref) {
|
|
358
460
|
var geography = _ref.geography,
|
|
359
461
|
onMouseEnter = _ref.onMouseEnter,
|
|
@@ -363,18 +465,18 @@ var Geography = function Geography(_ref) {
|
|
|
363
465
|
onFocus = _ref.onFocus,
|
|
364
466
|
onBlur = _ref.onBlur,
|
|
365
467
|
_ref$style = _ref.style,
|
|
366
|
-
style = _ref$style ===
|
|
468
|
+
style = _ref$style === void 0 ? {} : _ref$style,
|
|
367
469
|
_ref$className = _ref.className,
|
|
368
|
-
className = _ref$className ===
|
|
369
|
-
restProps =
|
|
470
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
471
|
+
restProps = _objectWithoutProperties(_ref, _excluded$6);
|
|
370
472
|
|
|
371
|
-
var _useState =
|
|
372
|
-
_useState2 =
|
|
473
|
+
var _useState = useState(false),
|
|
474
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
373
475
|
isPressed = _useState2[0],
|
|
374
476
|
setPressed = _useState2[1];
|
|
375
477
|
|
|
376
|
-
var _useState3 =
|
|
377
|
-
_useState4 =
|
|
478
|
+
var _useState3 = useState(false),
|
|
479
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
378
480
|
isFocused = _useState4[0],
|
|
379
481
|
setFocus = _useState4[1];
|
|
380
482
|
|
|
@@ -410,9 +512,9 @@ var Geography = function Geography(_ref) {
|
|
|
410
512
|
if (onMouseUp) onMouseUp(evt);
|
|
411
513
|
}
|
|
412
514
|
|
|
413
|
-
return
|
|
515
|
+
return /*#__PURE__*/React.createElement("path", _extends({
|
|
414
516
|
tabIndex: "0",
|
|
415
|
-
className: "rsm-geography "
|
|
517
|
+
className: "rsm-geography ".concat(className),
|
|
416
518
|
d: geography.svgPath,
|
|
417
519
|
onMouseEnter: handleMouseEnter,
|
|
418
520
|
onMouseLeave: handleMouseLeave,
|
|
@@ -435,28 +537,29 @@ Geography.propTypes = {
|
|
|
435
537
|
style: PropTypes.object,
|
|
436
538
|
className: PropTypes.string
|
|
437
539
|
};
|
|
540
|
+
var Geography$1 = memo(Geography);
|
|
438
541
|
|
|
439
|
-
var
|
|
542
|
+
var _excluded$5 = ["fill", "stroke", "step", "className"];
|
|
440
543
|
|
|
441
544
|
var Graticule = function Graticule(_ref) {
|
|
442
545
|
var _ref$fill = _ref.fill,
|
|
443
|
-
fill = _ref$fill ===
|
|
546
|
+
fill = _ref$fill === void 0 ? "transparent" : _ref$fill,
|
|
444
547
|
_ref$stroke = _ref.stroke,
|
|
445
|
-
stroke = _ref$stroke ===
|
|
548
|
+
stroke = _ref$stroke === void 0 ? "currentcolor" : _ref$stroke,
|
|
446
549
|
_ref$step = _ref.step,
|
|
447
|
-
step = _ref$step ===
|
|
550
|
+
step = _ref$step === void 0 ? [10, 10] : _ref$step,
|
|
448
551
|
_ref$className = _ref.className,
|
|
449
|
-
className = _ref$className ===
|
|
450
|
-
restProps =
|
|
552
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
553
|
+
restProps = _objectWithoutProperties(_ref, _excluded$5);
|
|
451
554
|
|
|
452
|
-
var _useContext =
|
|
555
|
+
var _useContext = useContext(MapContext),
|
|
453
556
|
path = _useContext.path;
|
|
454
557
|
|
|
455
|
-
return
|
|
456
|
-
d: path(
|
|
558
|
+
return /*#__PURE__*/React.createElement("path", _extends({
|
|
559
|
+
d: path(geoGraticule().step(step)()),
|
|
457
560
|
fill: fill,
|
|
458
561
|
stroke: stroke,
|
|
459
|
-
className: "rsm-graticule "
|
|
562
|
+
className: "rsm-graticule ".concat(className)
|
|
460
563
|
}, restProps));
|
|
461
564
|
};
|
|
462
565
|
|
|
@@ -466,8 +569,7 @@ Graticule.propTypes = {
|
|
|
466
569
|
step: PropTypes.array,
|
|
467
570
|
className: PropTypes.string
|
|
468
571
|
};
|
|
469
|
-
|
|
470
|
-
var Graticule$1 = React.memo(Graticule);
|
|
572
|
+
var Graticule$1 = memo(Graticule);
|
|
471
573
|
|
|
472
574
|
function useZoomPan(_ref) {
|
|
473
575
|
var center = _ref.center,
|
|
@@ -476,63 +578,83 @@ function useZoomPan(_ref) {
|
|
|
476
578
|
onMoveEnd = _ref.onMoveEnd,
|
|
477
579
|
onMove = _ref.onMove,
|
|
478
580
|
_ref$translateExtent = _ref.translateExtent,
|
|
479
|
-
translateExtent = _ref$translateExtent ===
|
|
581
|
+
translateExtent = _ref$translateExtent === void 0 ? [[-Infinity, -Infinity], [Infinity, Infinity]] : _ref$translateExtent,
|
|
480
582
|
_ref$scaleExtent = _ref.scaleExtent,
|
|
481
|
-
scaleExtent = _ref$scaleExtent ===
|
|
583
|
+
scaleExtent = _ref$scaleExtent === void 0 ? [1, 8] : _ref$scaleExtent,
|
|
482
584
|
_ref$zoom = _ref.zoom,
|
|
483
|
-
zoom = _ref$zoom ===
|
|
585
|
+
zoom$1 = _ref$zoom === void 0 ? 1 : _ref$zoom;
|
|
484
586
|
|
|
485
|
-
var _useContext =
|
|
587
|
+
var _useContext = useContext(MapContext),
|
|
486
588
|
width = _useContext.width,
|
|
487
589
|
height = _useContext.height,
|
|
488
590
|
projection = _useContext.projection;
|
|
489
591
|
|
|
490
|
-
var _center =
|
|
592
|
+
var _center = _slicedToArray(center, 2),
|
|
491
593
|
lon = _center[0],
|
|
492
594
|
lat = _center[1];
|
|
493
595
|
|
|
494
|
-
var _useState =
|
|
495
|
-
|
|
596
|
+
var _useState = useState({
|
|
597
|
+
x: 0,
|
|
598
|
+
y: 0,
|
|
599
|
+
k: 1
|
|
600
|
+
}),
|
|
601
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
496
602
|
position = _useState2[0],
|
|
497
603
|
setPosition = _useState2[1];
|
|
498
604
|
|
|
499
|
-
var lastPosition =
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
605
|
+
var lastPosition = useRef({
|
|
606
|
+
x: 0,
|
|
607
|
+
y: 0,
|
|
608
|
+
k: 1
|
|
609
|
+
});
|
|
610
|
+
var mapRef = useRef();
|
|
611
|
+
var zoomRef = useRef();
|
|
612
|
+
var bypassEvents = useRef(false);
|
|
503
613
|
|
|
504
|
-
var _translateExtent =
|
|
614
|
+
var _translateExtent = _slicedToArray(translateExtent, 2),
|
|
505
615
|
a = _translateExtent[0],
|
|
506
616
|
b = _translateExtent[1];
|
|
507
617
|
|
|
508
|
-
var _a =
|
|
618
|
+
var _a = _slicedToArray(a, 2),
|
|
509
619
|
a1 = _a[0],
|
|
510
620
|
a2 = _a[1];
|
|
511
621
|
|
|
512
|
-
var _b =
|
|
622
|
+
var _b = _slicedToArray(b, 2),
|
|
513
623
|
b1 = _b[0],
|
|
514
624
|
b2 = _b[1];
|
|
515
625
|
|
|
516
|
-
var _scaleExtent =
|
|
626
|
+
var _scaleExtent = _slicedToArray(scaleExtent, 2),
|
|
517
627
|
minZoom = _scaleExtent[0],
|
|
518
628
|
maxZoom = _scaleExtent[1];
|
|
519
629
|
|
|
520
|
-
|
|
521
|
-
var svg =
|
|
630
|
+
useEffect(function () {
|
|
631
|
+
var svg = select(mapRef.current);
|
|
522
632
|
|
|
523
633
|
function handleZoomStart(d3Event) {
|
|
524
634
|
if (!onMoveStart || bypassEvents.current) return;
|
|
525
|
-
onMoveStart({
|
|
635
|
+
onMoveStart({
|
|
636
|
+
coordinates: projection.invert(getCoords(width, height, d3Event.transform)),
|
|
637
|
+
zoom: d3Event.transform.k
|
|
638
|
+
}, d3Event);
|
|
526
639
|
}
|
|
527
640
|
|
|
528
641
|
function handleZoom(d3Event) {
|
|
529
642
|
if (bypassEvents.current) return;
|
|
530
643
|
var transform = d3Event.transform,
|
|
531
644
|
sourceEvent = d3Event.sourceEvent;
|
|
532
|
-
|
|
533
|
-
|
|
645
|
+
setPosition({
|
|
646
|
+
x: transform.x,
|
|
647
|
+
y: transform.y,
|
|
648
|
+
k: transform.k,
|
|
649
|
+
dragging: sourceEvent
|
|
650
|
+
});
|
|
534
651
|
if (!onMove) return;
|
|
535
|
-
onMove({
|
|
652
|
+
onMove({
|
|
653
|
+
x: transform.x,
|
|
654
|
+
y: transform.y,
|
|
655
|
+
zoom: transform.k,
|
|
656
|
+
dragging: sourceEvent
|
|
657
|
+
}, d3Event);
|
|
536
658
|
}
|
|
537
659
|
|
|
538
660
|
function handleZoomEnd(d3Event) {
|
|
@@ -542,69 +664,80 @@ function useZoomPan(_ref) {
|
|
|
542
664
|
}
|
|
543
665
|
|
|
544
666
|
var _projection$invert = projection.invert(getCoords(width, height, d3Event.transform)),
|
|
545
|
-
_projection$invert2 =
|
|
667
|
+
_projection$invert2 = _slicedToArray(_projection$invert, 2),
|
|
546
668
|
x = _projection$invert2[0],
|
|
547
669
|
y = _projection$invert2[1];
|
|
548
670
|
|
|
549
|
-
lastPosition.current = {
|
|
671
|
+
lastPosition.current = {
|
|
672
|
+
x: x,
|
|
673
|
+
y: y,
|
|
674
|
+
k: d3Event.transform.k
|
|
675
|
+
};
|
|
550
676
|
if (!onMoveEnd) return;
|
|
551
|
-
onMoveEnd({
|
|
677
|
+
onMoveEnd({
|
|
678
|
+
coordinates: [x, y],
|
|
679
|
+
zoom: d3Event.transform.k
|
|
680
|
+
}, d3Event);
|
|
552
681
|
}
|
|
553
682
|
|
|
554
683
|
function filterFunc(d3Event) {
|
|
555
684
|
if (filterZoomEvent) {
|
|
556
685
|
return filterZoomEvent(d3Event);
|
|
557
686
|
}
|
|
687
|
+
|
|
558
688
|
return d3Event ? !d3Event.ctrlKey && !d3Event.button : false;
|
|
559
689
|
}
|
|
560
690
|
|
|
561
|
-
var zoom =
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
svg.call(zoom);
|
|
691
|
+
var zoom$1 = zoom().filter(filterFunc).scaleExtent([minZoom, maxZoom]).translateExtent([[a1, a2], [b1, b2]]).on("start", handleZoomStart).on("zoom", handleZoom).on("end", handleZoomEnd);
|
|
692
|
+
zoomRef.current = zoom$1;
|
|
693
|
+
svg.call(zoom$1);
|
|
565
694
|
}, [width, height, a1, a2, b1, b2, minZoom, maxZoom, projection, onMoveStart, onMove, onMoveEnd, filterZoomEvent]);
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (lon === lastPosition.current.x && lat === lastPosition.current.y && zoom === lastPosition.current.k) return;
|
|
569
|
-
|
|
695
|
+
useEffect(function () {
|
|
696
|
+
if (lon === lastPosition.current.x && lat === lastPosition.current.y && zoom$1 === lastPosition.current.k) return;
|
|
570
697
|
var coords = projection([lon, lat]);
|
|
571
|
-
var x = coords[0] * zoom;
|
|
572
|
-
var y = coords[1] * zoom;
|
|
573
|
-
var svg =
|
|
574
|
-
|
|
698
|
+
var x = coords[0] * zoom$1;
|
|
699
|
+
var y = coords[1] * zoom$1;
|
|
700
|
+
var svg = select(mapRef.current);
|
|
575
701
|
bypassEvents.current = true;
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
702
|
+
svg.call(zoomRef.current.transform, zoomIdentity.translate(width / 2 - x, height / 2 - y).scale(zoom$1));
|
|
703
|
+
setPosition({
|
|
704
|
+
x: width / 2 - x,
|
|
705
|
+
y: height / 2 - y,
|
|
706
|
+
k: zoom$1
|
|
707
|
+
});
|
|
708
|
+
lastPosition.current = {
|
|
709
|
+
x: lon,
|
|
710
|
+
y: lat,
|
|
711
|
+
k: zoom$1
|
|
712
|
+
};
|
|
713
|
+
}, [lon, lat, zoom$1, width, height, projection]);
|
|
583
714
|
return {
|
|
584
715
|
mapRef: mapRef,
|
|
585
716
|
position: position,
|
|
586
|
-
transformString: "translate("
|
|
717
|
+
transformString: "translate(".concat(position.x, " ").concat(position.y, ") scale(").concat(position.k, ")")
|
|
587
718
|
};
|
|
588
719
|
}
|
|
589
720
|
|
|
721
|
+
var _excluded$4 = ["center", "zoom", "minZoom", "maxZoom", "translateExtent", "filterZoomEvent", "onMoveStart", "onMove", "onMoveEnd", "className"];
|
|
722
|
+
|
|
590
723
|
var ZoomableGroup = function ZoomableGroup(_ref) {
|
|
591
724
|
var _ref$center = _ref.center,
|
|
592
|
-
center = _ref$center ===
|
|
725
|
+
center = _ref$center === void 0 ? [0, 0] : _ref$center,
|
|
593
726
|
_ref$zoom = _ref.zoom,
|
|
594
|
-
zoom = _ref$zoom ===
|
|
727
|
+
zoom = _ref$zoom === void 0 ? 1 : _ref$zoom,
|
|
595
728
|
_ref$minZoom = _ref.minZoom,
|
|
596
|
-
minZoom = _ref$minZoom ===
|
|
729
|
+
minZoom = _ref$minZoom === void 0 ? 1 : _ref$minZoom,
|
|
597
730
|
_ref$maxZoom = _ref.maxZoom,
|
|
598
|
-
maxZoom = _ref$maxZoom ===
|
|
731
|
+
maxZoom = _ref$maxZoom === void 0 ? 8 : _ref$maxZoom,
|
|
599
732
|
translateExtent = _ref.translateExtent,
|
|
600
733
|
filterZoomEvent = _ref.filterZoomEvent,
|
|
601
734
|
onMoveStart = _ref.onMoveStart,
|
|
602
735
|
onMove = _ref.onMove,
|
|
603
736
|
onMoveEnd = _ref.onMoveEnd,
|
|
604
737
|
className = _ref.className,
|
|
605
|
-
restProps =
|
|
738
|
+
restProps = _objectWithoutProperties(_ref, _excluded$4);
|
|
606
739
|
|
|
607
|
-
var _useContext =
|
|
740
|
+
var _useContext = useContext(MapContext),
|
|
608
741
|
width = _useContext.width,
|
|
609
742
|
height = _useContext.height;
|
|
610
743
|
|
|
@@ -621,12 +754,16 @@ var ZoomableGroup = function ZoomableGroup(_ref) {
|
|
|
621
754
|
mapRef = _useZoomPan.mapRef,
|
|
622
755
|
transformString = _useZoomPan.transformString;
|
|
623
756
|
|
|
624
|
-
return
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
757
|
+
return /*#__PURE__*/React.createElement("g", {
|
|
758
|
+
ref: mapRef
|
|
759
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
760
|
+
width: width,
|
|
761
|
+
height: height,
|
|
762
|
+
fill: "transparent"
|
|
763
|
+
}), /*#__PURE__*/React.createElement("g", _extends({
|
|
764
|
+
transform: transformString,
|
|
765
|
+
className: "rsm-zoomable-group ".concat(className)
|
|
766
|
+
}, restProps)));
|
|
630
767
|
};
|
|
631
768
|
|
|
632
769
|
ZoomableGroup.propTypes = {
|
|
@@ -641,46 +778,43 @@ ZoomableGroup.propTypes = {
|
|
|
641
778
|
className: PropTypes.string
|
|
642
779
|
};
|
|
643
780
|
|
|
781
|
+
var _excluded$3 = ["id", "fill", "stroke", "strokeWidth", "className"];
|
|
782
|
+
|
|
644
783
|
var Sphere = function Sphere(_ref) {
|
|
645
784
|
var _ref$id = _ref.id,
|
|
646
|
-
id = _ref$id ===
|
|
785
|
+
id = _ref$id === void 0 ? "rsm-sphere" : _ref$id,
|
|
647
786
|
_ref$fill = _ref.fill,
|
|
648
|
-
fill = _ref$fill ===
|
|
787
|
+
fill = _ref$fill === void 0 ? "transparent" : _ref$fill,
|
|
649
788
|
_ref$stroke = _ref.stroke,
|
|
650
|
-
stroke = _ref$stroke ===
|
|
789
|
+
stroke = _ref$stroke === void 0 ? "currentcolor" : _ref$stroke,
|
|
651
790
|
_ref$strokeWidth = _ref.strokeWidth,
|
|
652
|
-
strokeWidth = _ref$strokeWidth ===
|
|
791
|
+
strokeWidth = _ref$strokeWidth === void 0 ? 0.5 : _ref$strokeWidth,
|
|
653
792
|
_ref$className = _ref.className,
|
|
654
|
-
className = _ref$className ===
|
|
655
|
-
restProps =
|
|
793
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
794
|
+
restProps = _objectWithoutProperties(_ref, _excluded$3);
|
|
656
795
|
|
|
657
|
-
var _useContext =
|
|
796
|
+
var _useContext = useContext(MapContext),
|
|
658
797
|
path = _useContext.path;
|
|
659
798
|
|
|
660
|
-
var spherePath =
|
|
661
|
-
return path({
|
|
799
|
+
var spherePath = useMemo(function () {
|
|
800
|
+
return path({
|
|
801
|
+
type: "Sphere"
|
|
802
|
+
});
|
|
662
803
|
}, [path]);
|
|
663
|
-
return
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
fill: fill,
|
|
678
|
-
stroke: stroke,
|
|
679
|
-
strokeWidth: strokeWidth,
|
|
680
|
-
style: { pointerEvents: "none" },
|
|
681
|
-
className: "rsm-sphere " + className
|
|
682
|
-
}, restProps))
|
|
683
|
-
);
|
|
804
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
|
|
805
|
+
id: id
|
|
806
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
807
|
+
d: spherePath
|
|
808
|
+
}))), /*#__PURE__*/React.createElement("path", _extends({
|
|
809
|
+
d: spherePath,
|
|
810
|
+
fill: fill,
|
|
811
|
+
stroke: stroke,
|
|
812
|
+
strokeWidth: strokeWidth,
|
|
813
|
+
style: {
|
|
814
|
+
pointerEvents: "none"
|
|
815
|
+
},
|
|
816
|
+
className: "rsm-sphere ".concat(className)
|
|
817
|
+
}, restProps)));
|
|
684
818
|
};
|
|
685
819
|
|
|
686
820
|
Sphere.propTypes = {
|
|
@@ -690,8 +824,9 @@ Sphere.propTypes = {
|
|
|
690
824
|
strokeWidth: PropTypes.number,
|
|
691
825
|
className: PropTypes.string
|
|
692
826
|
};
|
|
827
|
+
var Sphere$1 = memo(Sphere);
|
|
693
828
|
|
|
694
|
-
var
|
|
829
|
+
var _excluded$2 = ["coordinates", "children", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"];
|
|
695
830
|
|
|
696
831
|
var Marker = function Marker(_ref) {
|
|
697
832
|
var coordinates = _ref.coordinates,
|
|
@@ -703,26 +838,26 @@ var Marker = function Marker(_ref) {
|
|
|
703
838
|
onFocus = _ref.onFocus,
|
|
704
839
|
onBlur = _ref.onBlur,
|
|
705
840
|
_ref$style = _ref.style,
|
|
706
|
-
style = _ref$style ===
|
|
841
|
+
style = _ref$style === void 0 ? {} : _ref$style,
|
|
707
842
|
_ref$className = _ref.className,
|
|
708
|
-
className = _ref$className ===
|
|
709
|
-
restProps =
|
|
843
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
844
|
+
restProps = _objectWithoutProperties(_ref, _excluded$2);
|
|
710
845
|
|
|
711
|
-
var _useContext =
|
|
846
|
+
var _useContext = useContext(MapContext),
|
|
712
847
|
projection = _useContext.projection;
|
|
713
848
|
|
|
714
|
-
var _useState =
|
|
715
|
-
_useState2 =
|
|
849
|
+
var _useState = useState(false),
|
|
850
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
716
851
|
isPressed = _useState2[0],
|
|
717
852
|
setPressed = _useState2[1];
|
|
718
853
|
|
|
719
|
-
var _useState3 =
|
|
720
|
-
_useState4 =
|
|
854
|
+
var _useState3 = useState(false),
|
|
855
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
721
856
|
isFocused = _useState4[0],
|
|
722
857
|
setFocus = _useState4[1];
|
|
723
858
|
|
|
724
859
|
var _projection = projection(coordinates),
|
|
725
|
-
_projection2 =
|
|
860
|
+
_projection2 = _slicedToArray(_projection, 2),
|
|
726
861
|
x = _projection2[0],
|
|
727
862
|
y = _projection2[1];
|
|
728
863
|
|
|
@@ -758,21 +893,17 @@ var Marker = function Marker(_ref) {
|
|
|
758
893
|
if (onMouseUp) onMouseUp(evt);
|
|
759
894
|
}
|
|
760
895
|
|
|
761
|
-
return
|
|
762
|
-
"
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
style: style[isPressed || isFocused ? isPressed ? "pressed" : "hover" : "default"]
|
|
773
|
-
}, restProps),
|
|
774
|
-
children
|
|
775
|
-
);
|
|
896
|
+
return /*#__PURE__*/React.createElement("g", _extends({
|
|
897
|
+
transform: "translate(".concat(x, ", ").concat(y, ")"),
|
|
898
|
+
className: "rsm-marker ".concat(className),
|
|
899
|
+
onMouseEnter: handleMouseEnter,
|
|
900
|
+
onMouseLeave: handleMouseLeave,
|
|
901
|
+
onFocus: handleFocus,
|
|
902
|
+
onBlur: handleBlur,
|
|
903
|
+
onMouseDown: handleMouseDown,
|
|
904
|
+
onMouseUp: handleMouseUp,
|
|
905
|
+
style: style[isPressed || isFocused ? isPressed ? "pressed" : "hover" : "default"]
|
|
906
|
+
}, restProps), children);
|
|
776
907
|
};
|
|
777
908
|
|
|
778
909
|
Marker.propTypes = {
|
|
@@ -788,33 +919,34 @@ Marker.propTypes = {
|
|
|
788
919
|
className: PropTypes.string
|
|
789
920
|
};
|
|
790
921
|
|
|
922
|
+
var _excluded$1 = ["from", "to", "coordinates", "stroke", "strokeWidth", "fill", "className"];
|
|
923
|
+
|
|
791
924
|
var Line = function Line(_ref) {
|
|
792
925
|
var _ref$from = _ref.from,
|
|
793
|
-
from = _ref$from ===
|
|
926
|
+
from = _ref$from === void 0 ? [0, 0] : _ref$from,
|
|
794
927
|
_ref$to = _ref.to,
|
|
795
|
-
to = _ref$to ===
|
|
928
|
+
to = _ref$to === void 0 ? [0, 0] : _ref$to,
|
|
796
929
|
coordinates = _ref.coordinates,
|
|
797
930
|
_ref$stroke = _ref.stroke,
|
|
798
|
-
stroke = _ref$stroke ===
|
|
931
|
+
stroke = _ref$stroke === void 0 ? "currentcolor" : _ref$stroke,
|
|
799
932
|
_ref$strokeWidth = _ref.strokeWidth,
|
|
800
|
-
strokeWidth = _ref$strokeWidth ===
|
|
933
|
+
strokeWidth = _ref$strokeWidth === void 0 ? 3 : _ref$strokeWidth,
|
|
801
934
|
_ref$fill = _ref.fill,
|
|
802
|
-
fill = _ref$fill ===
|
|
935
|
+
fill = _ref$fill === void 0 ? "transparent" : _ref$fill,
|
|
803
936
|
_ref$className = _ref.className,
|
|
804
|
-
className = _ref$className ===
|
|
805
|
-
restProps =
|
|
937
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
938
|
+
restProps = _objectWithoutProperties(_ref, _excluded$1);
|
|
806
939
|
|
|
807
|
-
var _useContext =
|
|
940
|
+
var _useContext = useContext(MapContext),
|
|
808
941
|
path = _useContext.path;
|
|
809
942
|
|
|
810
943
|
var lineData = {
|
|
811
944
|
type: "LineString",
|
|
812
945
|
coordinates: coordinates || [from, to]
|
|
813
946
|
};
|
|
814
|
-
|
|
815
|
-
return React__default.createElement("path", _extends({
|
|
947
|
+
return /*#__PURE__*/React.createElement("path", _extends({
|
|
816
948
|
d: path(lineData),
|
|
817
|
-
className: "rsm-line "
|
|
949
|
+
className: "rsm-line ".concat(className),
|
|
818
950
|
stroke: stroke,
|
|
819
951
|
strokeWidth: strokeWidth,
|
|
820
952
|
fill: fill
|
|
@@ -831,39 +963,39 @@ Line.propTypes = {
|
|
|
831
963
|
className: PropTypes.string
|
|
832
964
|
};
|
|
833
965
|
|
|
966
|
+
var _excluded = ["subject", "children", "connectorProps", "dx", "dy", "curve", "className"];
|
|
967
|
+
|
|
834
968
|
var Annotation = function Annotation(_ref) {
|
|
835
969
|
var subject = _ref.subject,
|
|
836
970
|
children = _ref.children,
|
|
837
971
|
connectorProps = _ref.connectorProps,
|
|
838
972
|
_ref$dx = _ref.dx,
|
|
839
|
-
dx = _ref$dx ===
|
|
973
|
+
dx = _ref$dx === void 0 ? 30 : _ref$dx,
|
|
840
974
|
_ref$dy = _ref.dy,
|
|
841
|
-
dy = _ref$dy ===
|
|
975
|
+
dy = _ref$dy === void 0 ? 30 : _ref$dy,
|
|
842
976
|
_ref$curve = _ref.curve,
|
|
843
|
-
curve = _ref$curve ===
|
|
977
|
+
curve = _ref$curve === void 0 ? 0 : _ref$curve,
|
|
844
978
|
_ref$className = _ref.className,
|
|
845
|
-
className = _ref$className ===
|
|
846
|
-
restProps =
|
|
979
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
980
|
+
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
847
981
|
|
|
848
|
-
var _useContext =
|
|
982
|
+
var _useContext = useContext(MapContext),
|
|
849
983
|
projection = _useContext.projection;
|
|
850
984
|
|
|
851
985
|
var _projection = projection(subject),
|
|
852
|
-
_projection2 =
|
|
986
|
+
_projection2 = _slicedToArray(_projection, 2),
|
|
853
987
|
x = _projection2[0],
|
|
854
988
|
y = _projection2[1];
|
|
855
989
|
|
|
856
990
|
var connectorPath = createConnectorPath(dx, dy, curve);
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
"
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
children
|
|
866
|
-
);
|
|
991
|
+
return /*#__PURE__*/React.createElement("g", _extends({
|
|
992
|
+
transform: "translate(".concat(x + dx, ", ").concat(y + dy, ")"),
|
|
993
|
+
className: "rsm-annotation ".concat(className)
|
|
994
|
+
}, restProps), /*#__PURE__*/React.createElement("path", _extends({
|
|
995
|
+
d: connectorPath,
|
|
996
|
+
fill: "transparent",
|
|
997
|
+
stroke: "#000"
|
|
998
|
+
}, connectorProps)), children);
|
|
867
999
|
};
|
|
868
1000
|
|
|
869
1001
|
Annotation.propTypes = {
|
|
@@ -876,16 +1008,4 @@ Annotation.propTypes = {
|
|
|
876
1008
|
className: PropTypes.string
|
|
877
1009
|
};
|
|
878
1010
|
|
|
879
|
-
|
|
880
|
-
exports.ComposableMap = ComposableMap;
|
|
881
|
-
exports.Geographies = Geographies;
|
|
882
|
-
exports.Geography = Geography$1;
|
|
883
|
-
exports.Graticule = Graticule$1;
|
|
884
|
-
exports.Line = Line;
|
|
885
|
-
exports.MapContext = MapContext;
|
|
886
|
-
exports.MapProvider = MapProvider;
|
|
887
|
-
exports.Marker = Marker;
|
|
888
|
-
exports.Sphere = Sphere$1;
|
|
889
|
-
exports.ZoomableGroup = ZoomableGroup;
|
|
890
|
-
exports.useGeographies = useGeographies;
|
|
891
|
-
exports.useZoomPan = useZoomPan;
|
|
1011
|
+
export { Annotation, ComposableMap, Geographies, Geography$1 as Geography, Graticule$1 as Graticule, Line, MapContext, MapProvider, Marker, Sphere$1 as Sphere, ZoomableGroup, useGeographies, useZoomPan };
|