@nocobase/plugin-map 0.10.0-alpha.4 → 0.10.1-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/lib/client/block/MapBlock.js +8 -328
- package/lib/client/block/MapBlockInitializer.js +7 -6
- package/lib/client/components/AMap/Block.d.ts +2 -0
- package/lib/client/components/AMap/Block.js +357 -0
- package/lib/client/components/{AMap.d.ts → AMap/Map.d.ts} +3 -3
- package/lib/client/components/{AMap.js → AMap/Map.js} +13 -13
- package/lib/client/components/{Search.d.ts → AMap/Search.d.ts} +2 -2
- package/lib/client/components/{Search.js → AMap/Search.js} +5 -5
- 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 +54 -28
- package/lib/client/components/GoogleMaps/Block.d.ts +2 -0
- package/lib/client/components/GoogleMaps/Block.js +377 -0
- package/lib/client/components/GoogleMaps/Map.d.ts +31 -0
- package/lib/client/components/GoogleMaps/Map.js +471 -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.js +3 -5
- 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 +1 -0
- package/lib/client/utils.js +1 -0
- package/package.json +16 -5
- package/src/client/block/MapBlock.tsx +7 -311
- 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 -11
- package/src/client/components/{Search.tsx → AMap/Search.tsx} +3 -4
- package/src/client/components/AMap/index.ts +2 -0
- package/src/client/components/Configuration.tsx +49 -25
- package/src/client/components/GoogleMaps/Block.tsx +341 -0
- package/src/client/components/GoogleMaps/Map.tsx +470 -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 +2 -3
- package/src/client/locale/zh-CN.ts +2 -0
- package/src/client/types.ts +1 -0
- package/src/client/utils.ts +0 -0
|
@@ -4,27 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.MapBlock = 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 _css() {
|
|
15
|
-
const data = require("@emotion/css");
|
|
16
|
-
_css = function _css() {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
7
|
function _react() {
|
|
22
|
-
const data = require("
|
|
8
|
+
const data = _interopRequireDefault(require("react"));
|
|
23
9
|
_react = function _react() {
|
|
24
10
|
return data;
|
|
25
11
|
};
|
|
26
12
|
return data;
|
|
27
13
|
}
|
|
14
|
+
var _components = require("../components");
|
|
28
15
|
function _client() {
|
|
29
16
|
const data = require("@nocobase/client");
|
|
30
17
|
_client = function _client() {
|
|
@@ -32,327 +19,20 @@ function _client() {
|
|
|
32
19
|
};
|
|
33
20
|
return data;
|
|
34
21
|
}
|
|
35
|
-
function _ahooks() {
|
|
36
|
-
const data = require("ahooks");
|
|
37
|
-
_ahooks = function _ahooks() {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
|
-
function _antd() {
|
|
43
|
-
const data = require("antd");
|
|
44
|
-
_antd = function _antd() {
|
|
45
|
-
return data;
|
|
46
|
-
};
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
function _react2() {
|
|
50
|
-
const data = _interopRequireWildcard(require("react"));
|
|
51
|
-
_react2 = function _react2() {
|
|
52
|
-
return data;
|
|
53
|
-
};
|
|
54
|
-
return data;
|
|
55
|
-
}
|
|
56
|
-
var _AMap = _interopRequireDefault(require("../components/AMap"));
|
|
57
|
-
var _locale = require("../locale");
|
|
58
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
59
|
-
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); }
|
|
60
|
-
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; }
|
|
61
23
|
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; }
|
|
62
24
|
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; }
|
|
63
25
|
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; }
|
|
64
26
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
65
27
|
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); }
|
|
66
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
67
|
-
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."); }
|
|
68
|
-
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); }
|
|
69
|
-
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; }
|
|
70
|
-
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; } }
|
|
71
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
72
|
-
const selectedImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi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mMa3qPkLdh/wKOL8SpLbnYFgAAAABJRU5ErkJggg==';
|
|
74
28
|
const MapBlock = props => {
|
|
75
|
-
var
|
|
29
|
+
var _field$uiSchema;
|
|
76
30
|
const _useProps = (0, _client().useProps)(props),
|
|
77
|
-
fieldNames = _useProps.fieldNames
|
|
78
|
-
_useProps$dataSource = _useProps.dataSource,
|
|
79
|
-
dataSource = _useProps$dataSource === void 0 ? [] : _useProps$dataSource,
|
|
80
|
-
fixedBlock = _useProps.fixedBlock,
|
|
81
|
-
zoom = _useProps.zoom,
|
|
82
|
-
setSelectedRecordKeys = _useProps.setSelectedRecordKeys;
|
|
31
|
+
fieldNames = _useProps.fieldNames;
|
|
83
32
|
const _useCollection = (0, _client().useCollection)(),
|
|
84
|
-
getField = _useCollection.getField
|
|
85
|
-
getPrimaryKey = _useCollection.getPrimaryKey;
|
|
33
|
+
getField = _useCollection.getField;
|
|
86
34
|
const field = getField(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.field);
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
isMapInitialization = _useState2[0],
|
|
90
|
-
setIsMapInitialization = _useState2[1];
|
|
91
|
-
const mapRef = (0, _react2().useRef)();
|
|
92
|
-
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;
|
|
93
|
-
const _useState3 = (0, _react2().useState)(),
|
|
94
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
95
|
-
record = _useState4[0],
|
|
96
|
-
setRecord = _useState4[1];
|
|
97
|
-
const _useState5 = (0, _react2().useState)(''),
|
|
98
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
99
|
-
selectingMode = _useState6[0],
|
|
100
|
-
setSelecting = _useState6[1];
|
|
101
|
-
const _useMapTranslation = (0, _locale.useMapTranslation)(),
|
|
102
|
-
t = _useMapTranslation.t;
|
|
103
|
-
const compile = (0, _client().useCompile)();
|
|
104
|
-
const _useFilterAPI = (0, _client().useFilterAPI)(),
|
|
105
|
-
isConnected = _useFilterAPI.isConnected,
|
|
106
|
-
doFilter = _useFilterAPI.doFilter;
|
|
107
|
-
const _useState7 = (0, _react2().useState)(null),
|
|
108
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
109
|
-
setPrevSelected = _useState8[1];
|
|
110
|
-
const selectingModeRef = (0, _react2().useRef)(selectingMode);
|
|
111
|
-
selectingModeRef.current = selectingMode;
|
|
112
|
-
const setOverlayOptions = (overlay, state) => {
|
|
113
|
-
const extData = overlay.getExtData();
|
|
114
|
-
const selected = typeof state === 'undefined' ? extData.selected : !state;
|
|
115
|
-
extData.selected = !selected;
|
|
116
|
-
if ('setIcon' in overlay) {
|
|
117
|
-
overlay.setIcon(new mapRef.current.aMap.Icon({
|
|
118
|
-
imageSize: [19, 32],
|
|
119
|
-
image: selected ? defaultImage : selectedImage
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
overlay.setOptions(_objectSpread({
|
|
123
|
-
extData
|
|
124
|
-
}, selected ? {
|
|
125
|
-
strokeColor: '#4e9bff',
|
|
126
|
-
fillColor: '#4e9bff'
|
|
127
|
-
} : {
|
|
128
|
-
strokeColor: '#F18b62',
|
|
129
|
-
fillColor: '#F18b62'
|
|
130
|
-
}));
|
|
131
|
-
};
|
|
132
|
-
const removeSelection = () => {
|
|
133
|
-
mapRef.current.mouseTool().close(true);
|
|
134
|
-
mapRef.current.editor().setTarget(null);
|
|
135
|
-
mapRef.current.editor().close();
|
|
136
|
-
};
|
|
137
|
-
// selection
|
|
138
|
-
(0, _react2().useEffect)(() => {
|
|
139
|
-
if (selectingMode !== 'selection') {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
if (!mapRef.current.editor()) {
|
|
143
|
-
mapRef.current.createEditor('polygon');
|
|
144
|
-
mapRef.current.createMouseTool('polygon');
|
|
145
|
-
} else {
|
|
146
|
-
mapRef.current.executeMouseTool('polygon');
|
|
147
|
-
}
|
|
148
|
-
return () => {
|
|
149
|
-
removeSelection();
|
|
150
|
-
};
|
|
151
|
-
}, [selectingMode]);
|
|
152
|
-
(0, _react2().useEffect)(() => {
|
|
153
|
-
if (selectingMode) {
|
|
154
|
-
return () => {
|
|
155
|
-
if (!selectingModeRef.current) {
|
|
156
|
-
mapRef.current.map.getAllOverlays().forEach(o => {
|
|
157
|
-
setOverlayOptions(o, false);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
}, [selectingMode]);
|
|
163
|
-
const onSelectingComplete = (0, _ahooks().useMemoizedFn)(() => {
|
|
164
|
-
const selectingOverlay = mapRef.current.editor().getTarget();
|
|
165
|
-
const overlays = mapRef.current.map.getAllOverlays();
|
|
166
|
-
const selectedOverlays = overlays.filter(o => {
|
|
167
|
-
if (o === selectingOverlay || o.getExtData().id === undefined) return;
|
|
168
|
-
if ('getPosition' in o) {
|
|
169
|
-
return geometryUtils.isPointInRing(o.getPosition(), selectingOverlay.getPath());
|
|
170
|
-
}
|
|
171
|
-
return geometryUtils.doesRingRingIntersect(o.getPath(), selectingOverlay.getPath());
|
|
172
|
-
});
|
|
173
|
-
const ids = selectedOverlays.map(o => {
|
|
174
|
-
setOverlayOptions(o, true);
|
|
175
|
-
return o.getExtData().id;
|
|
176
|
-
});
|
|
177
|
-
setSelectedRecordKeys(lastIds => ids.concat(lastIds));
|
|
178
|
-
selectingOverlay.remove();
|
|
179
|
-
mapRef.current.editor().close();
|
|
180
|
-
});
|
|
181
|
-
(0, _react2().useEffect)(() => {
|
|
182
|
-
var _mapRef$current$map;
|
|
183
|
-
if (!field || !mapRef.current) return;
|
|
184
|
-
const overlays = dataSource.map(item => {
|
|
185
|
-
const data = item[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.field];
|
|
186
|
-
if (!data) return;
|
|
187
|
-
const overlay = mapRef.current.setOverlay(field.type, data, {
|
|
188
|
-
strokeColor: '#4e9bff',
|
|
189
|
-
fillColor: '#4e9bff',
|
|
190
|
-
cursor: 'pointer',
|
|
191
|
-
label: {
|
|
192
|
-
direction: 'bottom',
|
|
193
|
-
offset: [0, 5],
|
|
194
|
-
content: (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.marker) ? compile(item[fieldNames.marker]) : undefined
|
|
195
|
-
},
|
|
196
|
-
extData: {
|
|
197
|
-
id: item[getPrimaryKey()]
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
return overlay;
|
|
201
|
-
}).filter(Boolean);
|
|
202
|
-
(_mapRef$current$map = mapRef.current.map) === null || _mapRef$current$map === void 0 ? void 0 : _mapRef$current$map.setFitView(overlays);
|
|
203
|
-
const events = overlays.map(o => {
|
|
204
|
-
const onClick = e => {
|
|
205
|
-
const overlay = e.target;
|
|
206
|
-
const extData = overlay.getExtData();
|
|
207
|
-
if (!extData) return;
|
|
208
|
-
if (selectingModeRef.current) {
|
|
209
|
-
if (selectingModeRef.current === 'click') {
|
|
210
|
-
setSelectedRecordKeys(keys => extData.selected ? keys.filter(key => key !== extData.id) : [...keys, extData.id]);
|
|
211
|
-
setOverlayOptions(overlay);
|
|
212
|
-
}
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
const data = dataSource === null || dataSource === void 0 ? void 0 : dataSource.find(item => {
|
|
216
|
-
return extData.id === item[getPrimaryKey()];
|
|
217
|
-
});
|
|
218
|
-
// 筛选区块模式
|
|
219
|
-
if (isConnected) {
|
|
220
|
-
setPrevSelected(prev => {
|
|
221
|
-
prev && clearSelected(prev);
|
|
222
|
-
if (prev === o) {
|
|
223
|
-
clearSelected(o);
|
|
224
|
-
// 删除过滤参数
|
|
225
|
-
doFilter(null);
|
|
226
|
-
return null;
|
|
227
|
-
} else {
|
|
228
|
-
selectMarker(o);
|
|
229
|
-
doFilter(data[getPrimaryKey()], target => target.field || getPrimaryKey(), '$eq');
|
|
230
|
-
}
|
|
231
|
-
return o;
|
|
232
|
-
});
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
if (data) {
|
|
236
|
-
setRecord(data);
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
o.on('click', onClick);
|
|
240
|
-
return () => o.off('click', onClick);
|
|
241
|
-
});
|
|
242
|
-
return () => {
|
|
243
|
-
overlays.forEach(ov => {
|
|
244
|
-
ov.remove();
|
|
245
|
-
});
|
|
246
|
-
events.forEach(e => e());
|
|
247
|
-
};
|
|
248
|
-
}, [dataSource, isMapInitialization, fieldNames, field.type, isConnected]);
|
|
249
|
-
(0, _react2().useEffect)(() => {
|
|
250
|
-
setTimeout(() => {
|
|
251
|
-
setSelectedRecordKeys([]);
|
|
252
|
-
});
|
|
253
|
-
}, [dataSource]);
|
|
254
|
-
const mapRefCallback = instance => {
|
|
255
|
-
mapRef.current = instance;
|
|
256
|
-
setIsMapInitialization(!!(instance === null || instance === void 0 ? void 0 : instance.aMap));
|
|
257
|
-
};
|
|
258
|
-
return _react2().default.createElement("div", {
|
|
259
|
-
className: (0, _css().css)`
|
|
260
|
-
position: relative;
|
|
261
|
-
height: 100%;
|
|
262
|
-
`
|
|
263
|
-
}, _react2().default.createElement("div", {
|
|
264
|
-
className: (0, _css().css)`
|
|
265
|
-
position: absolute;
|
|
266
|
-
left: 10px;
|
|
267
|
-
top: 10px;
|
|
268
|
-
z-index: 999;
|
|
269
|
-
`
|
|
270
|
-
}, _react2().default.createElement(_antd().Space, {
|
|
271
|
-
direction: "vertical"
|
|
272
|
-
}, _react2().default.createElement(_antd().Button, {
|
|
273
|
-
style: {
|
|
274
|
-
color: !selectingMode ? '#F18b62' : undefined,
|
|
275
|
-
borderColor: 'currentcolor'
|
|
276
|
-
},
|
|
277
|
-
onClick: e => {
|
|
278
|
-
e.stopPropagation();
|
|
279
|
-
setSelecting('');
|
|
280
|
-
},
|
|
281
|
-
icon: _react2().default.createElement(_icons().EnvironmentOutlined, null)
|
|
282
|
-
}), _react2().default.createElement(_antd().Button, {
|
|
283
|
-
style: {
|
|
284
|
-
color: selectingMode === 'selection' ? '#F18b62' : undefined,
|
|
285
|
-
borderColor: 'currentcolor'
|
|
286
|
-
},
|
|
287
|
-
onClick: e => {
|
|
288
|
-
e.stopPropagation();
|
|
289
|
-
setSelecting('selection');
|
|
290
|
-
},
|
|
291
|
-
icon: _react2().default.createElement(_icons().ExpandOutlined, null)
|
|
292
|
-
}), selectingMode === 'selection' ? _react2().default.createElement(_antd().Button, {
|
|
293
|
-
type: "primary",
|
|
294
|
-
icon: _react2().default.createElement(_icons().CheckOutlined, null),
|
|
295
|
-
title: t('Confirm selection'),
|
|
296
|
-
onClick: onSelectingComplete
|
|
297
|
-
}) : null)), _react2().default.createElement(MapBlockDrawer, {
|
|
298
|
-
record: record,
|
|
299
|
-
setVisible: setRecord
|
|
300
|
-
}), _react2().default.createElement(_AMap.default, _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']), {}, {
|
|
301
|
-
ref: mapRefCallback,
|
|
302
|
-
style: {
|
|
303
|
-
height: fixedBlock ? '100%' : null
|
|
304
|
-
},
|
|
305
|
-
zoom: zoom,
|
|
306
|
-
disabled: true,
|
|
307
|
-
block: true,
|
|
308
|
-
overlayCommonOptions: {
|
|
309
|
-
strokeColor: '#F18b62',
|
|
310
|
-
fillColor: '#F18b62'
|
|
311
|
-
}
|
|
312
|
-
})));
|
|
313
|
-
};
|
|
314
|
-
exports.MapBlock = MapBlock;
|
|
315
|
-
const MapBlockDrawer = props => {
|
|
316
|
-
const setVisible = props.setVisible,
|
|
317
|
-
record = props.record;
|
|
318
|
-
const fieldSchema = (0, _react().useFieldSchema)();
|
|
319
|
-
const schema = (0, _react2().useMemo)(() => fieldSchema.reduceProperties((buf, current) => {
|
|
320
|
-
if (current.name === 'drawer') {
|
|
321
|
-
return current;
|
|
322
|
-
}
|
|
323
|
-
return buf;
|
|
324
|
-
}, null), [fieldSchema]);
|
|
325
|
-
return schema && _react2().default.createElement(_client().ActionContextProvider, {
|
|
326
|
-
value: {
|
|
327
|
-
visible: !!record,
|
|
328
|
-
setVisible
|
|
329
|
-
}
|
|
330
|
-
}, _react2().default.createElement(_client().RecordProvider, {
|
|
331
|
-
record: record
|
|
332
|
-
}, _react2().default.createElement(_react().RecursionField, {
|
|
333
|
-
schema: schema,
|
|
334
|
-
name: schema.name
|
|
335
|
-
})));
|
|
35
|
+
const fieldComponentProps = field === null || field === void 0 ? void 0 : (_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema['x-component-props'];
|
|
36
|
+
return _react().default.createElement(_components.MapBlockComponent, _objectSpread(_objectSpread({}, fieldComponentProps), props));
|
|
336
37
|
};
|
|
337
|
-
|
|
338
|
-
if (marker.dom) {
|
|
339
|
-
marker.dom.style.filter = 'none';
|
|
340
|
-
// AMap.Polygon | AMap.Polyline | AMap.Circle 都有 setOptions 方法
|
|
341
|
-
} else if (marker.setOptions) {
|
|
342
|
-
marker.setOptions({
|
|
343
|
-
strokeColor: '#4e9bff',
|
|
344
|
-
fillColor: '#4e9bff'
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
function selectMarker(marker) {
|
|
349
|
-
if (marker.dom) {
|
|
350
|
-
marker.dom.style.filter = 'brightness(1.2) contrast(1.2) hue-rotate(180deg)';
|
|
351
|
-
// AMap.Polygon | AMap.Polyline | AMap.Circle 都有 setOptions 方法
|
|
352
|
-
} else if (marker.setOptions) {
|
|
353
|
-
marker.setOptions({
|
|
354
|
-
strokeColor: '#F18b62',
|
|
355
|
-
fillColor: '#F18b62'
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
}
|
|
38
|
+
exports.MapBlock = MapBlock;
|
|
@@ -11,9 +11,9 @@ function _icons() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const data = require("@
|
|
16
|
-
|
|
14
|
+
function _antd() {
|
|
15
|
+
const data = require("@formily/antd");
|
|
16
|
+
_antd = function _antd() {
|
|
17
17
|
return data;
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
@@ -25,9 +25,9 @@ function _react() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const data = require("@
|
|
30
|
-
|
|
28
|
+
function _client() {
|
|
29
|
+
const data = require("@nocobase/client");
|
|
30
|
+
_client = function _client() {
|
|
31
31
|
return data;
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
@@ -53,6 +53,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
53
53
|
const MapBlockInitializer = props => {
|
|
54
54
|
const insert = props.insert;
|
|
55
55
|
const options = (0, _react2().useContext)(_react().SchemaOptionsContext);
|
|
56
|
+
console.log('🚀 ~ file: MapBlockInitializer.tsx:12 ~ MapBlockInitializer ~ options:', options);
|
|
56
57
|
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
57
58
|
getCollectionFieldsOptions = _useCollectionManager.getCollectionFieldsOptions;
|
|
58
59
|
const _useMapTranslation = (0, _locale.useMapTranslation)(),
|