@nocobase/plugin-map 0.10.0-alpha.5 → 0.11.0-alpha.1
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/client.d.ts +2 -3
- package/client.js +1 -30
- package/lib/client/block/MapBlock.js +8 -328
- package/lib/client/block/MapBlockDesigner.js +4 -4
- package/lib/client/block/MapBlockInitializer.js +9 -8
- package/lib/client/components/AMap/Block.d.ts +2 -0
- package/lib/client/components/AMap/Block.js +350 -0
- package/lib/client/components/{AMap.d.ts → AMap/Map.d.ts} +3 -3
- package/lib/client/components/{AMap.js → AMap/Map.js} +15 -22
- package/lib/client/components/{Search.d.ts → AMap/Search.d.ts} +2 -2
- package/lib/client/components/{Search.js → AMap/Search.js} +9 -10
- package/lib/client/components/AMap/index.d.ts +2 -0
- package/lib/client/components/AMap/index.js +27 -0
- package/lib/client/components/Configuration.d.ts +1 -2
- package/lib/client/components/Configuration.js +53 -28
- package/lib/client/components/Designer.js +5 -5
- package/lib/client/components/GoogleMaps/Block.d.ts +2 -0
- package/lib/client/components/GoogleMaps/Block.js +370 -0
- package/lib/client/components/GoogleMaps/Map.d.ts +31 -0
- package/lib/client/components/GoogleMaps/Map.js +464 -0
- package/lib/client/components/GoogleMaps/Search.d.ts +8 -0
- package/lib/client/components/GoogleMaps/Search.js +128 -0
- package/lib/client/components/GoogleMaps/index.d.ts +2 -0
- package/lib/client/components/GoogleMaps/index.js +27 -0
- package/lib/client/components/GoogleMaps/utils.d.ts +5 -0
- package/lib/client/components/GoogleMaps/utils.js +44 -0
- package/lib/client/components/Map.d.ts +1 -1
- package/lib/client/components/Map.js +13 -14
- package/lib/client/components/MapBlock.d.ts +2 -0
- package/lib/client/components/MapBlock.js +40 -0
- package/lib/client/components/MapComponent.d.ts +2 -0
- package/lib/client/components/MapComponent.js +42 -0
- package/lib/client/components/ReadPretty.js +5 -13
- package/lib/client/components/index.d.ts +6 -0
- package/lib/client/components/index.js +71 -0
- package/lib/client/constants.d.ts +2 -0
- package/lib/client/constants.js +6 -2
- package/lib/client/index.d.ts +5 -3
- package/lib/client/index.js +16 -7
- package/lib/client/locale/zh-CN.d.ts +1 -0
- package/lib/client/locale/zh-CN.js +2 -1
- package/lib/client/types.d.ts +1 -0
- package/lib/client/types.js +5 -0
- package/lib/client/utils.d.ts +0 -0
- package/lib/client/utils.js +1 -0
- package/lib/server/fields/circle.d.ts +1 -2
- package/lib/server/fields/circle.js +3 -10
- package/lib/server/fields/lineString.d.ts +1 -2
- package/lib/server/fields/lineString.js +4 -11
- package/lib/server/fields/point.d.ts +1 -2
- package/lib/server/fields/point.js +4 -11
- package/lib/server/fields/polygon.d.ts +1 -2
- package/lib/server/fields/polygon.js +4 -11
- package/package.json +38 -9
- package/server.d.ts +2 -3
- package/server.js +1 -30
- package/src/client/block/MapBlock.tsx +7 -311
- package/src/client/block/MapBlockDesigner.tsx +2 -2
- package/src/client/block/MapBlockInitializer.tsx +3 -2
- package/src/client/components/AMap/Block.tsx +314 -0
- package/src/client/components/{AMap.tsx → AMap/Map.tsx} +10 -12
- package/src/client/components/{Search.tsx → AMap/Search.tsx} +4 -6
- package/src/client/components/AMap/index.ts +2 -0
- package/src/client/components/Configuration.tsx +47 -23
- package/src/client/components/Designer.tsx +2 -2
- package/src/client/components/GoogleMaps/Block.tsx +341 -0
- package/src/client/components/GoogleMaps/Map.tsx +469 -0
- package/src/client/components/GoogleMaps/Search.tsx +107 -0
- package/src/client/components/GoogleMaps/index.ts +2 -0
- package/src/client/components/GoogleMaps/utils.ts +33 -0
- package/src/client/components/Map.tsx +6 -5
- package/src/client/components/MapBlock.tsx +24 -0
- package/src/client/components/MapComponent.tsx +23 -0
- package/src/client/components/ReadPretty.tsx +6 -11
- package/src/client/components/index.ts +6 -0
- package/src/client/constants.ts +5 -0
- package/src/client/index.tsx +10 -4
- package/src/client/locale/zh-CN.ts +2 -0
- package/src/client/types.ts +1 -0
- package/src/client/utils.ts +0 -0
- package/src/server/fields/circle.ts +1 -2
- package/src/server/fields/lineString.ts +2 -3
- package/src/server/fields/point.ts +1 -2
- package/src/server/fields/polygon.ts +1 -2
- package/docs/en-US/changelog.md +0 -1
- package/docs/en-US/index.md +0 -1
- package/docs/en-US/installation.md +0 -1
- package/docs/en-US/tabs.json +0 -18
- package/docs/en-US/usage.md +0 -1
- package/docs/zh-CN/changelog.md +0 -1
- package/docs/zh-CN/index.md +0 -1
- package/docs/zh-CN/installation.md +0 -1
- package/docs/zh-CN/tabs.json +0 -18
- package/docs/zh-CN/usage.md +0 -1
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AMapBlock = void 0;
|
|
7
|
+
function _icons() {
|
|
8
|
+
const data = require("@ant-design/icons");
|
|
9
|
+
_icons = function _icons() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _react() {
|
|
15
|
+
const data = require("@formily/react");
|
|
16
|
+
_react = function _react() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _client() {
|
|
22
|
+
const data = require("@nocobase/client");
|
|
23
|
+
_client = function _client() {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _ahooks() {
|
|
29
|
+
const data = require("ahooks");
|
|
30
|
+
_ahooks = function _ahooks() {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _antd() {
|
|
36
|
+
const data = require("antd");
|
|
37
|
+
_antd = function _antd() {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _react2() {
|
|
43
|
+
const data = _interopRequireWildcard(require("react"));
|
|
44
|
+
_react2 = function _react2() {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
var _constants = require("../../constants");
|
|
50
|
+
var _locale = require("../../locale");
|
|
51
|
+
var _Map = require("./Map");
|
|
52
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
53
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
54
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
55
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
56
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
57
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
58
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
59
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
60
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
61
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
62
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
63
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
64
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
65
|
+
const AMapBlock = props => {
|
|
66
|
+
var _mapRef$current, _mapRef$current$aMap, _field$uiSchema;
|
|
67
|
+
const _useProps = (0, _client().useProps)(props),
|
|
68
|
+
fieldNames = _useProps.fieldNames,
|
|
69
|
+
_useProps$dataSource = _useProps.dataSource,
|
|
70
|
+
dataSource = _useProps$dataSource === void 0 ? [] : _useProps$dataSource,
|
|
71
|
+
fixedBlock = _useProps.fixedBlock,
|
|
72
|
+
zoom = _useProps.zoom,
|
|
73
|
+
setSelectedRecordKeys = _useProps.setSelectedRecordKeys;
|
|
74
|
+
const _useCollection = (0, _client().useCollection)(),
|
|
75
|
+
getField = _useCollection.getField,
|
|
76
|
+
getPrimaryKey = _useCollection.getPrimaryKey;
|
|
77
|
+
const field = getField(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.field);
|
|
78
|
+
const _useState = (0, _react2().useState)(false),
|
|
79
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
80
|
+
isMapInitialization = _useState2[0],
|
|
81
|
+
setIsMapInitialization = _useState2[1];
|
|
82
|
+
const mapRef = (0, _react2().useRef)();
|
|
83
|
+
const geometryUtils = (_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : (_mapRef$current$aMap = _mapRef$current.aMap) === null || _mapRef$current$aMap === void 0 ? void 0 : _mapRef$current$aMap.GeometryUtil;
|
|
84
|
+
const _useState3 = (0, _react2().useState)(),
|
|
85
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
86
|
+
record = _useState4[0],
|
|
87
|
+
setRecord = _useState4[1];
|
|
88
|
+
const _useState5 = (0, _react2().useState)(''),
|
|
89
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
90
|
+
selectingMode = _useState6[0],
|
|
91
|
+
setSelecting = _useState6[1];
|
|
92
|
+
const _useMapTranslation = (0, _locale.useMapTranslation)(),
|
|
93
|
+
t = _useMapTranslation.t;
|
|
94
|
+
const compile = (0, _client().useCompile)();
|
|
95
|
+
const _useFilterAPI = (0, _client().useFilterAPI)(),
|
|
96
|
+
isConnected = _useFilterAPI.isConnected,
|
|
97
|
+
doFilter = _useFilterAPI.doFilter;
|
|
98
|
+
const _useState7 = (0, _react2().useState)(null),
|
|
99
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
100
|
+
setPrevSelected = _useState8[1];
|
|
101
|
+
const selectingModeRef = (0, _react2().useRef)(selectingMode);
|
|
102
|
+
selectingModeRef.current = selectingMode;
|
|
103
|
+
const setOverlayOptions = (overlay, state) => {
|
|
104
|
+
const extData = overlay.getExtData();
|
|
105
|
+
const selected = typeof state === 'undefined' ? extData.selected : !state;
|
|
106
|
+
extData.selected = !selected;
|
|
107
|
+
if ('setIcon' in overlay) {
|
|
108
|
+
overlay.setIcon(new mapRef.current.aMap.Icon({
|
|
109
|
+
imageSize: [19, 32],
|
|
110
|
+
image: selected ? _constants.defaultImage : _constants.selectedImage
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
overlay.setOptions(_objectSpread({
|
|
114
|
+
extData
|
|
115
|
+
}, selected ? {
|
|
116
|
+
strokeColor: '#4e9bff',
|
|
117
|
+
fillColor: '#4e9bff'
|
|
118
|
+
} : {
|
|
119
|
+
strokeColor: '#F18b62',
|
|
120
|
+
fillColor: '#F18b62'
|
|
121
|
+
}));
|
|
122
|
+
};
|
|
123
|
+
const removeSelection = () => {
|
|
124
|
+
if (!mapRef.current) return;
|
|
125
|
+
mapRef.current.mouseTool().close(true);
|
|
126
|
+
mapRef.current.editor().setTarget(null);
|
|
127
|
+
mapRef.current.editor().close();
|
|
128
|
+
};
|
|
129
|
+
// selection
|
|
130
|
+
(0, _react2().useEffect)(() => {
|
|
131
|
+
if (selectingMode !== 'selection') {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (!mapRef.current.editor()) {
|
|
135
|
+
mapRef.current.createEditor('polygon');
|
|
136
|
+
mapRef.current.createMouseTool('polygon');
|
|
137
|
+
} else {
|
|
138
|
+
mapRef.current.executeMouseTool('polygon');
|
|
139
|
+
}
|
|
140
|
+
return () => {
|
|
141
|
+
removeSelection();
|
|
142
|
+
};
|
|
143
|
+
}, [selectingMode]);
|
|
144
|
+
(0, _react2().useEffect)(() => {
|
|
145
|
+
if (selectingMode) {
|
|
146
|
+
return () => {
|
|
147
|
+
if (!selectingModeRef.current) {
|
|
148
|
+
mapRef.current.map.getAllOverlays().forEach(o => {
|
|
149
|
+
setOverlayOptions(o, false);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}, [selectingMode]);
|
|
155
|
+
const onSelectingComplete = (0, _ahooks().useMemoizedFn)(() => {
|
|
156
|
+
const selectingOverlay = mapRef.current.editor().getTarget();
|
|
157
|
+
const overlays = mapRef.current.map.getAllOverlays();
|
|
158
|
+
const selectedOverlays = overlays.filter(o => {
|
|
159
|
+
if (o === selectingOverlay || o.getExtData().id === undefined) return;
|
|
160
|
+
if ('getPosition' in o) {
|
|
161
|
+
return geometryUtils.isPointInRing(o.getPosition(), selectingOverlay.getPath());
|
|
162
|
+
}
|
|
163
|
+
return geometryUtils.doesRingRingIntersect(o.getPath(), selectingOverlay.getPath());
|
|
164
|
+
});
|
|
165
|
+
const ids = selectedOverlays.map(o => {
|
|
166
|
+
setOverlayOptions(o, true);
|
|
167
|
+
return o.getExtData().id;
|
|
168
|
+
});
|
|
169
|
+
setSelectedRecordKeys(lastIds => ids.concat(lastIds));
|
|
170
|
+
selectingOverlay.remove();
|
|
171
|
+
mapRef.current.editor().close();
|
|
172
|
+
});
|
|
173
|
+
(0, _react2().useEffect)(() => {
|
|
174
|
+
var _mapRef$current$map;
|
|
175
|
+
if (!field || !mapRef.current) return;
|
|
176
|
+
const overlays = dataSource.map(item => {
|
|
177
|
+
const data = item[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.field];
|
|
178
|
+
if (!data) return;
|
|
179
|
+
const overlay = mapRef.current.setOverlay(field.type, data, {
|
|
180
|
+
strokeColor: '#4e9bff',
|
|
181
|
+
fillColor: '#4e9bff',
|
|
182
|
+
cursor: 'pointer',
|
|
183
|
+
label: {
|
|
184
|
+
direction: 'bottom',
|
|
185
|
+
offset: [0, 5],
|
|
186
|
+
content: fieldNames !== null && fieldNames !== void 0 && fieldNames.marker ? compile(item[fieldNames.marker]) : undefined
|
|
187
|
+
},
|
|
188
|
+
extData: {
|
|
189
|
+
id: item[getPrimaryKey()]
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
return overlay;
|
|
193
|
+
}).filter(Boolean);
|
|
194
|
+
(_mapRef$current$map = mapRef.current.map) === null || _mapRef$current$map === void 0 ? void 0 : _mapRef$current$map.setFitView(overlays);
|
|
195
|
+
const events = overlays.map(o => {
|
|
196
|
+
const onClick = e => {
|
|
197
|
+
const overlay = e.target;
|
|
198
|
+
const extData = overlay.getExtData();
|
|
199
|
+
if (!extData) return;
|
|
200
|
+
if (selectingModeRef.current) {
|
|
201
|
+
if (selectingModeRef.current === 'click') {
|
|
202
|
+
setSelectedRecordKeys(keys => extData.selected ? keys.filter(key => key !== extData.id) : [...keys, extData.id]);
|
|
203
|
+
setOverlayOptions(overlay);
|
|
204
|
+
}
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const data = dataSource === null || dataSource === void 0 ? void 0 : dataSource.find(item => {
|
|
208
|
+
return extData.id === item[getPrimaryKey()];
|
|
209
|
+
});
|
|
210
|
+
// 筛选区块模式
|
|
211
|
+
if (isConnected) {
|
|
212
|
+
setPrevSelected(prev => {
|
|
213
|
+
prev && clearSelected(prev);
|
|
214
|
+
if (prev === o) {
|
|
215
|
+
clearSelected(o);
|
|
216
|
+
// 删除过滤参数
|
|
217
|
+
doFilter(null);
|
|
218
|
+
return null;
|
|
219
|
+
} else {
|
|
220
|
+
selectMarker(o);
|
|
221
|
+
doFilter(data[getPrimaryKey()], target => target.field || getPrimaryKey(), '$eq');
|
|
222
|
+
}
|
|
223
|
+
return o;
|
|
224
|
+
});
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (data) {
|
|
228
|
+
setRecord(data);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
o.on('click', onClick);
|
|
232
|
+
return () => o.off('click', onClick);
|
|
233
|
+
});
|
|
234
|
+
return () => {
|
|
235
|
+
overlays.forEach(ov => {
|
|
236
|
+
ov.remove();
|
|
237
|
+
});
|
|
238
|
+
events.forEach(e => e());
|
|
239
|
+
};
|
|
240
|
+
}, [dataSource, isMapInitialization, fieldNames, field.type, isConnected]);
|
|
241
|
+
(0, _react2().useEffect)(() => {
|
|
242
|
+
setTimeout(() => {
|
|
243
|
+
setSelectedRecordKeys([]);
|
|
244
|
+
});
|
|
245
|
+
}, [dataSource]);
|
|
246
|
+
const mapRefCallback = instance => {
|
|
247
|
+
mapRef.current = instance;
|
|
248
|
+
setIsMapInitialization(!!(instance !== null && instance !== void 0 && instance.map) && !instance.errMessage);
|
|
249
|
+
};
|
|
250
|
+
return _react2().default.createElement("div", {
|
|
251
|
+
className: (0, _client().css)`
|
|
252
|
+
position: relative;
|
|
253
|
+
height: 100%;
|
|
254
|
+
`
|
|
255
|
+
}, _react2().default.createElement("div", {
|
|
256
|
+
className: (0, _client().css)`
|
|
257
|
+
position: absolute;
|
|
258
|
+
left: 10px;
|
|
259
|
+
top: 10px;
|
|
260
|
+
z-index: 999;
|
|
261
|
+
`
|
|
262
|
+
}, isMapInitialization && !mapRef.current.errMessage ? _react2().default.createElement(_antd().Space, {
|
|
263
|
+
direction: "vertical"
|
|
264
|
+
}, _react2().default.createElement(_antd().Button, {
|
|
265
|
+
style: {
|
|
266
|
+
color: !selectingMode ? '#F18b62' : undefined,
|
|
267
|
+
borderColor: 'currentcolor'
|
|
268
|
+
},
|
|
269
|
+
onClick: e => {
|
|
270
|
+
e.stopPropagation();
|
|
271
|
+
setSelecting('');
|
|
272
|
+
},
|
|
273
|
+
icon: _react2().default.createElement(_icons().EnvironmentOutlined, null)
|
|
274
|
+
}), _react2().default.createElement(_antd().Button, {
|
|
275
|
+
style: {
|
|
276
|
+
color: selectingMode === 'selection' ? '#F18b62' : undefined,
|
|
277
|
+
borderColor: 'currentcolor'
|
|
278
|
+
},
|
|
279
|
+
onClick: e => {
|
|
280
|
+
e.stopPropagation();
|
|
281
|
+
setSelecting('selection');
|
|
282
|
+
},
|
|
283
|
+
icon: _react2().default.createElement(_icons().ExpandOutlined, null)
|
|
284
|
+
}), selectingMode === 'selection' ? _react2().default.createElement(_antd().Button, {
|
|
285
|
+
type: "primary",
|
|
286
|
+
icon: _react2().default.createElement(_icons().CheckOutlined, null),
|
|
287
|
+
title: t('Confirm selection'),
|
|
288
|
+
onClick: onSelectingComplete
|
|
289
|
+
}) : null) : null), _react2().default.createElement(MapBlockDrawer, {
|
|
290
|
+
record: record,
|
|
291
|
+
setVisible: setRecord
|
|
292
|
+
}), _react2().default.createElement(_Map.AMapComponent, _objectSpread(_objectSpread({}, field === null || field === void 0 ? void 0 : (_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema['x-component-props']), {}, {
|
|
293
|
+
ref: mapRefCallback,
|
|
294
|
+
style: {
|
|
295
|
+
height: fixedBlock ? '100%' : null
|
|
296
|
+
},
|
|
297
|
+
zoom: zoom,
|
|
298
|
+
disabled: true,
|
|
299
|
+
block: true,
|
|
300
|
+
overlayCommonOptions: {
|
|
301
|
+
strokeColor: '#F18b62',
|
|
302
|
+
fillColor: '#F18b62'
|
|
303
|
+
}
|
|
304
|
+
})));
|
|
305
|
+
};
|
|
306
|
+
exports.AMapBlock = AMapBlock;
|
|
307
|
+
const MapBlockDrawer = props => {
|
|
308
|
+
const setVisible = props.setVisible,
|
|
309
|
+
record = props.record;
|
|
310
|
+
const fieldSchema = (0, _react().useFieldSchema)();
|
|
311
|
+
const schema = (0, _react2().useMemo)(() => fieldSchema.reduceProperties((buf, current) => {
|
|
312
|
+
if (current.name === 'drawer') {
|
|
313
|
+
return current;
|
|
314
|
+
}
|
|
315
|
+
return buf;
|
|
316
|
+
}, null), [fieldSchema]);
|
|
317
|
+
return schema && _react2().default.createElement(_client().ActionContextProvider, {
|
|
318
|
+
value: {
|
|
319
|
+
visible: !!record,
|
|
320
|
+
setVisible
|
|
321
|
+
}
|
|
322
|
+
}, _react2().default.createElement(_client().RecordProvider, {
|
|
323
|
+
record: record
|
|
324
|
+
}, _react2().default.createElement(_react().RecursionField, {
|
|
325
|
+
schema: schema,
|
|
326
|
+
name: schema.name
|
|
327
|
+
})));
|
|
328
|
+
};
|
|
329
|
+
function clearSelected(marker) {
|
|
330
|
+
if (marker.dom) {
|
|
331
|
+
marker.dom.style.filter = 'none';
|
|
332
|
+
// AMap.Polygon | AMap.Polyline | AMap.Circle 都有 setOptions 方法
|
|
333
|
+
} else if (marker.setOptions) {
|
|
334
|
+
marker.setOptions({
|
|
335
|
+
strokeColor: '#4e9bff',
|
|
336
|
+
fillColor: '#4e9bff'
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function selectMarker(marker) {
|
|
341
|
+
if (marker.dom) {
|
|
342
|
+
marker.dom.style.filter = 'brightness(1.2) contrast(1.2) hue-rotate(180deg)';
|
|
343
|
+
// AMap.Polygon | AMap.Polyline | AMap.Circle 都有 setOptions 方法
|
|
344
|
+
} else if (marker.setOptions) {
|
|
345
|
+
marker.setOptions({
|
|
346
|
+
strokeColor: '#F18b62',
|
|
347
|
+
fillColor: '#F18b62'
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@amap/amap-jsapi-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
|
|
3
|
+
import { MapEditorType } from '../../types';
|
|
4
4
|
export interface AMapComponentProps {
|
|
5
5
|
value?: any;
|
|
6
6
|
onChange?: (value: number[]) => void;
|
|
@@ -34,6 +34,6 @@ export interface AMapForwardedRefProps {
|
|
|
34
34
|
close: (clear?: boolean) => void;
|
|
35
35
|
};
|
|
36
36
|
overlay: AMap.Polygon;
|
|
37
|
+
errMessage?: string;
|
|
37
38
|
}
|
|
38
|
-
declare const AMapComponent: React.ForwardRefExoticComponent<AMapComponentProps & React.RefAttributes<AMapForwardedRefProps>>;
|
|
39
|
-
export default AMapComponent;
|
|
39
|
+
export declare const AMapComponent: React.ForwardRefExoticComponent<AMapComponentProps & React.RefAttributes<AMapForwardedRefProps>>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.AMapComponent = void 0;
|
|
7
7
|
function _amapJsapiLoader() {
|
|
8
8
|
const data = _interopRequireDefault(require("@amap/amap-jsapi-loader"));
|
|
9
9
|
_amapJsapiLoader = function _amapJsapiLoader() {
|
|
@@ -19,13 +19,6 @@ function _icons() {
|
|
|
19
19
|
};
|
|
20
20
|
return data;
|
|
21
21
|
}
|
|
22
|
-
function _css() {
|
|
23
|
-
const data = require("@emotion/css");
|
|
24
|
-
_css = function _css() {
|
|
25
|
-
return data;
|
|
26
|
-
};
|
|
27
|
-
return data;
|
|
28
|
-
}
|
|
29
22
|
function _react() {
|
|
30
23
|
const data = require("@formily/react");
|
|
31
24
|
_react = function _react() {
|
|
@@ -68,9 +61,9 @@ function _reactRouterDom() {
|
|
|
68
61
|
};
|
|
69
62
|
return data;
|
|
70
63
|
}
|
|
71
|
-
var _hooks = require("
|
|
72
|
-
var _locale = require("
|
|
73
|
-
var _Search =
|
|
64
|
+
var _hooks = require("../../hooks");
|
|
65
|
+
var _locale = require("../../locale");
|
|
66
|
+
var _Search = require("./Search");
|
|
74
67
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
75
68
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
76
69
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -226,7 +219,7 @@ const AMapComponent = _react2().default.forwardRef((props, ref) => {
|
|
|
226
219
|
});
|
|
227
220
|
const executeMouseTool = (0, _ahooks().useMemoizedFn)((curType = type) => {
|
|
228
221
|
var _editor$current;
|
|
229
|
-
if (!_mouseTool.current || (
|
|
222
|
+
if (!_mouseTool.current || (_editor$current = _editor.current) !== null && _editor$current !== void 0 && _editor$current.getTarget()) return;
|
|
230
223
|
const mapping = methodMapping[curType];
|
|
231
224
|
if (!mapping) {
|
|
232
225
|
return;
|
|
@@ -387,38 +380,39 @@ const AMapComponent = _react2().default.forwardRef((props, ref) => {
|
|
|
387
380
|
map: map.current,
|
|
388
381
|
overlay: overlay.current,
|
|
389
382
|
mouseTool: () => _mouseTool.current,
|
|
390
|
-
editor: () => _editor.current
|
|
383
|
+
editor: () => _editor.current,
|
|
384
|
+
errMessage
|
|
391
385
|
}));
|
|
392
386
|
if (!accessKey || errMessage) {
|
|
393
387
|
return _react2().default.createElement(_antd().Alert, {
|
|
394
388
|
action: _react2().default.createElement(_antd().Button, {
|
|
395
389
|
type: "primary",
|
|
396
|
-
onClick: () => navigate('/admin/settings/map
|
|
390
|
+
onClick: () => navigate('/admin/settings/map/configuration')
|
|
397
391
|
}, t('Go to the configuration page')),
|
|
398
392
|
message: errMessage || t('Please configure the AccessKey and SecurityJsCode first'),
|
|
399
393
|
type: "error"
|
|
400
394
|
});
|
|
401
395
|
}
|
|
402
396
|
return _react2().default.createElement("div", {
|
|
403
|
-
className: (0,
|
|
397
|
+
className: (0, _client().css)`
|
|
404
398
|
position: relative;
|
|
405
399
|
height: 500px;
|
|
406
400
|
`,
|
|
407
401
|
id: id.current,
|
|
408
402
|
style: props === null || props === void 0 ? void 0 : props.style
|
|
409
403
|
}, !aMap.current && _react2().default.createElement("div", {
|
|
410
|
-
className: (0,
|
|
404
|
+
className: (0, _client().css)`
|
|
411
405
|
position: absolute;
|
|
412
406
|
inset: 0;
|
|
413
407
|
display: flex;
|
|
414
408
|
align-items: center;
|
|
415
409
|
justify-content: center;
|
|
416
410
|
`
|
|
417
|
-
}, _react2().default.createElement(_antd().Spin, null)), !disabled ? _react2().default.createElement(_react2().default.Fragment, null, _react2().default.createElement(_Search.
|
|
411
|
+
}, _react2().default.createElement(_antd().Spin, null)), !disabled ? _react2().default.createElement(_react2().default.Fragment, null, _react2().default.createElement(_Search.Search, {
|
|
418
412
|
toCenter: toCenter,
|
|
419
413
|
aMap: aMap.current
|
|
420
414
|
}), _react2().default.createElement("div", {
|
|
421
|
-
className: (0,
|
|
415
|
+
className: (0, _client().css)`
|
|
422
416
|
position: absolute;
|
|
423
417
|
bottom: 80px;
|
|
424
418
|
right: 20px;
|
|
@@ -432,7 +426,7 @@ const AMapComponent = _react2().default.forwardRef((props, ref) => {
|
|
|
432
426
|
size: "large",
|
|
433
427
|
icon: _react2().default.createElement(_icons().SyncOutlined, null)
|
|
434
428
|
})), type !== 'point' ? _react2().default.createElement("div", {
|
|
435
|
-
className: (0,
|
|
429
|
+
className: (0, _client().css)`
|
|
436
430
|
position: absolute;
|
|
437
431
|
bottom: 20px;
|
|
438
432
|
left: 10px;
|
|
@@ -443,7 +437,7 @@ const AMapComponent = _react2().default.forwardRef((props, ref) => {
|
|
|
443
437
|
message: t('Click to select the starting point and double-click to end the drawing'),
|
|
444
438
|
type: "info"
|
|
445
439
|
})) : null, _react2().default.createElement("div", {
|
|
446
|
-
className: (0,
|
|
440
|
+
className: (0, _client().css)`
|
|
447
441
|
position: absolute;
|
|
448
442
|
bottom: 20px;
|
|
449
443
|
right: 20px;
|
|
@@ -459,5 +453,4 @@ const AMapComponent = _react2().default.forwardRef((props, ref) => {
|
|
|
459
453
|
danger: true
|
|
460
454
|
}, t('Clear')))) : null);
|
|
461
455
|
});
|
|
462
|
-
|
|
463
|
-
exports.default = _default;
|
|
456
|
+
exports.AMapComponent = AMapComponent;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
function
|
|
8
|
-
const data = require("@
|
|
9
|
-
|
|
6
|
+
exports.Search = void 0;
|
|
7
|
+
function _client() {
|
|
8
|
+
const data = require("@nocobase/client");
|
|
9
|
+
_client = function _client() {
|
|
10
10
|
return data;
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
@@ -32,7 +32,7 @@ function _react() {
|
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
34
34
|
}
|
|
35
|
-
var _locale = require("
|
|
35
|
+
var _locale = require("../../locale");
|
|
36
36
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
37
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
38
38
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -92,12 +92,12 @@ const Search = props => {
|
|
|
92
92
|
const place = options.find(o => {
|
|
93
93
|
return o.value === value;
|
|
94
94
|
});
|
|
95
|
-
if (place
|
|
95
|
+
if (place !== null && place !== void 0 && place.location) {
|
|
96
96
|
toCenter(place.location);
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
return _react().default.createElement("div", {
|
|
100
|
-
className: (0,
|
|
100
|
+
className: (0, _client().css)`
|
|
101
101
|
position: absolute;
|
|
102
102
|
top: 10px;
|
|
103
103
|
left: 10px;
|
|
@@ -115,8 +115,7 @@ const Search = props => {
|
|
|
115
115
|
onSearch: onSearch,
|
|
116
116
|
onSelect: onSelect,
|
|
117
117
|
options: options,
|
|
118
|
-
|
|
118
|
+
popupMatchSelectWidth: false
|
|
119
119
|
}));
|
|
120
120
|
};
|
|
121
|
-
|
|
122
|
-
exports.default = _default;
|
|
121
|
+
exports.Search = Search;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Block = require("./Block");
|
|
7
|
+
Object.keys(_Block).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _Block[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _Block[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _Map = require("./Map");
|
|
18
|
+
Object.keys(_Map).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _Map[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return _Map[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|