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