@vtx/ol-map 1.0.102 → 1.0.104
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/_util/stringToFun.js +25 -0
- package/lib/_util/stringToFun.js.map +1 -0
- package/lib/convertCamelToCSS.js +24 -0
- package/lib/convertCamelToCSS.js.map +1 -0
- package/lib/feature-layer/FeatureLayer.js +175 -69
- package/lib/feature-layer/FeatureLayer.js.map +1 -1
- package/lib/feature-layer/MyCluster.js +5 -0
- package/lib/feature-layer/MyCluster.js.map +1 -1
- package/lib/map/getBaseLayers/imagery/amap/AmapImageryProvider.js +1 -1
- package/lib/map/getBaseLayers/imagery/amap/AmapImageryProvider.js.map +1 -1
- package/lib/map/getBaseLayers/imagery/baidu/BaiduImageryProvider.js +1 -1
- package/lib/map/getBaseLayers/imagery/baidu/BaiduImageryProvider.js.map +1 -1
- package/lib/map/style/index.css +62 -0
- package/lib/map/style/index.less +53 -0
- package/lib/path-play-back/PathPlayBack.js +18 -9
- package/lib/path-play-back/PathPlayBack.js.map +1 -1
- package/lib/poi-search/PoiList.js +3 -0
- package/lib/poi-search/PoiList.js.map +1 -1
- package/lib/poi-search/Search.js +4 -1
- package/lib/poi-search/Search.js.map +1 -1
- package/package.json +1 -1
- package/lib/assets/people.gif +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = stringToFun;
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
// 将字符函数转化为可执行的函数
|
|
14
|
+
function stringToFun(str) {
|
|
15
|
+
if (str && typeof str === 'string' && str.indexOf('=>') !== -1) {
|
|
16
|
+
str = str.replaceAll(' ', '');
|
|
17
|
+
var _str$split = str.split('=>'),
|
|
18
|
+
_str$split2 = _slicedToArray(_str$split, 2),
|
|
19
|
+
a = _str$split2[0],
|
|
20
|
+
c = _str$split2[1];
|
|
21
|
+
str = new Function(a, "return ".concat(c));
|
|
22
|
+
}
|
|
23
|
+
return str;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=stringToFun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringToFun.js","names":["stringToFun","str","indexOf","replaceAll","_str$split","split","_str$split2","_slicedToArray","a","c","Function","concat"],"sources":["_util/stringToFun.js"],"sourcesContent":["// 将字符函数转化为可执行的函数\nexport default function stringToFun(str) {\n if (str && typeof str === 'string' && str.indexOf('=>') !== -1) {\n str = str.replaceAll(' ', '');\n const [a, c] = str.split('=>');\n str = new Function(a, `return ${c}`);\n }\n\n return str\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AACe,SAASA,WAAWA,CAACC,GAAG,EAAE;EACrC,IAAIA,GAAG,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,CAACC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;IAC5DD,GAAG,GAAGA,GAAG,CAACE,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;IAC7B,IAAAC,UAAA,GAAeH,GAAG,CAACI,KAAK,CAAC,IAAI,CAAC;MAAAC,WAAA,GAAAC,cAAA,CAAAH,UAAA;MAAvBI,CAAC,GAAAF,WAAA;MAAEG,CAAC,GAAAH,WAAA;IACXL,GAAG,GAAG,IAAIS,QAAQ,CAACF,CAAC,YAAAG,MAAA,CAAYF,CAAC,CAAE,CAAC;EACxC;EAEA,OAAOR,GAAG;AACd"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
// 将 jsx 的 style 小驼峰的 key 属性,转化为 cssText 的 -
|
|
8
|
+
var convertCamelToCSS = function convertCamelToCSS(style) {
|
|
9
|
+
var cssText = '';
|
|
10
|
+
for (var property in style) {
|
|
11
|
+
if (style.hasOwnProperty(property)) {
|
|
12
|
+
var value = style[property];
|
|
13
|
+
if (value && typeof value === 'number' && !isNaN(value)) {
|
|
14
|
+
value = value + 'px';
|
|
15
|
+
}
|
|
16
|
+
var cssProperty = property.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
17
|
+
cssText += "".concat(cssProperty, ": ").concat(value, "; ");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return cssText;
|
|
21
|
+
};
|
|
22
|
+
var _default = convertCamelToCSS;
|
|
23
|
+
exports["default"] = _default;
|
|
24
|
+
//# sourceMappingURL=convertCamelToCSS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertCamelToCSS.js","names":["convertCamelToCSS","style","cssText","property","hasOwnProperty","value","isNaN","cssProperty","replace","toLowerCase","concat","_default","exports"],"sources":["convertCamelToCSS.js"],"sourcesContent":["// 将 jsx 的 style 小驼峰的 key 属性,转化为 cssText 的 -\nconst convertCamelToCSS = (style) => {\n let cssText = '';\n for (let property in style) {\n if (style.hasOwnProperty(property)) {\n let value = style[property];\n if (value && typeof value === 'number' && !isNaN(value)) {\n value = value + 'px';\n }\n let cssProperty = property.replace(/([A-Z])/g, '-$1').toLowerCase();\n cssText += `${cssProperty}: ${value}; `;\n }\n }\n\n return cssText;\n}\n\nexport default convertCamelToCSS;\n"],"mappings":";;;;;;AAAA;AACA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,KAAK,EAAK;EACjC,IAAIC,OAAO,GAAG,EAAE;EAChB,KAAK,IAAIC,QAAQ,IAAIF,KAAK,EAAE;IACxB,IAAIA,KAAK,CAACG,cAAc,CAACD,QAAQ,CAAC,EAAE;MAChC,IAAIE,KAAK,GAAGJ,KAAK,CAACE,QAAQ,CAAC;MAC3B,IAAIE,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,CAACC,KAAK,CAACD,KAAK,CAAC,EAAE;QACrDA,KAAK,GAAGA,KAAK,GAAG,IAAI;MACxB;MACA,IAAIE,WAAW,GAAGJ,QAAQ,CAACK,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAACC,WAAW,CAAC,CAAC;MACnEP,OAAO,OAAAQ,MAAA,CAAOH,WAAW,QAAAG,MAAA,CAAKL,KAAK,OAAI;IAC3C;EACJ;EAEA,OAAOH,OAAO;AAClB,CAAC;AAAA,IAAAS,QAAA,GAEcX,iBAAiB;AAAAY,OAAA,cAAAD,QAAA"}
|
|
@@ -13,22 +13,20 @@ var _isFunction = _interopRequireDefault(require("../_util/isFunction"));
|
|
|
13
13
|
var _createFeatureCollection = require("./createFeatureCollection");
|
|
14
14
|
var _isObject = _interopRequireDefault(require("../_util/isObject"));
|
|
15
15
|
var _encryptParams = _interopRequireDefault(require("../_util/encryptParams"));
|
|
16
|
+
var _stringToFun = _interopRequireDefault(require("../_util/stringToFun"));
|
|
17
|
+
var _convertCamelToCSS = _interopRequireDefault(require("../convertCamelToCSS"));
|
|
16
18
|
var _MyCluster = _interopRequireDefault(require("./MyCluster"));
|
|
17
|
-
var _excluded = ["url", "params", "data", "dataField", "features", "sourceOptions", "key", "name", "label", "labelField", "point", "cluster", "template", "autoRefresh", "method", "layerControl", "show", "style", "group", "iconOptions", "afterGetData", "legend", "viewOnly", "encrypt", "valueField", "map", "tipTemplate"],
|
|
19
|
+
var _excluded = ["url", "params", "data", "dataField", "features", "sourceOptions", "key", "name", "label", "labelField", "point", "cluster", "template", "autoRefresh", "method", "layerControl", "show", "style", "group", "iconOptions", "afterGetData", "legend", "viewOnly", "encrypt", "valueField", "map", "tipTemplate", "alarmBg"],
|
|
18
20
|
_excluded2 = ["color", "background", "backgroundStroke", "backgroundStrokeWidth"],
|
|
19
21
|
_excluded3 = ["numberStyle", "iconOptions"];
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
23
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
22
24
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
25
|
+
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); }
|
|
23
26
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
24
27
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
25
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
26
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
27
|
-
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."); }
|
|
28
|
-
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); }
|
|
29
28
|
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; }
|
|
30
|
-
function
|
|
31
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
32
30
|
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; }
|
|
33
31
|
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; }
|
|
34
32
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
@@ -50,6 +48,37 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
50
48
|
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; }
|
|
51
49
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
52
50
|
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); }
|
|
51
|
+
var addOverlay = function addOverlay(feature, map, alarmBg) {
|
|
52
|
+
if (alarmBg) {
|
|
53
|
+
var itemVal = alarmBg.find(function (v) {
|
|
54
|
+
return v.filter(feature.values_);
|
|
55
|
+
});
|
|
56
|
+
if (itemVal) {
|
|
57
|
+
var image = itemVal.image,
|
|
58
|
+
style = itemVal.style;
|
|
59
|
+
var dom;
|
|
60
|
+
if (image) {
|
|
61
|
+
dom = document.createElement('img');
|
|
62
|
+
dom.src = image;
|
|
63
|
+
} else {
|
|
64
|
+
dom = document.createElement('div');
|
|
65
|
+
dom.className = "ol-map-icon-alarm";
|
|
66
|
+
}
|
|
67
|
+
if (style) {
|
|
68
|
+
dom.style.cssText = style;
|
|
69
|
+
}
|
|
70
|
+
var overlay = new _ol.Overlay({
|
|
71
|
+
element: dom,
|
|
72
|
+
positioning: 'bottom-center',
|
|
73
|
+
stopEvent: true,
|
|
74
|
+
className: 'ol-overlay_container-stop_event'
|
|
75
|
+
});
|
|
76
|
+
map.addOverlay(overlay);
|
|
77
|
+
overlay.setPosition(feature.getGeometry().getCoordinates());
|
|
78
|
+
return overlay;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
53
82
|
var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
54
83
|
_inherits(FeatureLayer, _Vector);
|
|
55
84
|
var _super = _createSuper(FeatureLayer);
|
|
@@ -83,6 +112,7 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
83
112
|
valueField = _options.valueField,
|
|
84
113
|
map = _options.map,
|
|
85
114
|
tipTemplate = _options.tipTemplate,
|
|
115
|
+
alarmBg = _options.alarmBg,
|
|
86
116
|
other = _objectWithoutProperties(_options, _excluded);
|
|
87
117
|
var props = _objectSpread({}, other);
|
|
88
118
|
props.source = props.source || new _source.Vector(_objectSpread({
|
|
@@ -98,14 +128,7 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
98
128
|
}
|
|
99
129
|
|
|
100
130
|
// 将字符函数转化为可执行的函数
|
|
101
|
-
|
|
102
|
-
f.filter = f.filter.replaceAll(' ', '');
|
|
103
|
-
var _f$filter$split = f.filter.split('=>'),
|
|
104
|
-
_f$filter$split2 = _slicedToArray(_f$filter$split, 2),
|
|
105
|
-
a = _f$filter$split2[0],
|
|
106
|
-
c = _f$filter$split2[1];
|
|
107
|
-
f.filter = new Function(a, "return ".concat(c));
|
|
108
|
-
}
|
|
131
|
+
f.filter = (0, _stringToFun["default"])(f.filter);
|
|
109
132
|
});
|
|
110
133
|
}
|
|
111
134
|
}
|
|
@@ -254,6 +277,25 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
254
277
|
// 气泡模板
|
|
255
278
|
_this2.tipTemplate = tipTemplate;
|
|
256
279
|
|
|
280
|
+
// 报警背景
|
|
281
|
+
if (alarmBg) {
|
|
282
|
+
_this2.alarmBg = (Array.isArray(alarmBg) ? alarmBg : [alarmBg]).map(function (item) {
|
|
283
|
+
var filter = item.filter,
|
|
284
|
+
style = item.style;
|
|
285
|
+
filter = (0, _stringToFun["default"])(filter);
|
|
286
|
+
if (style) {
|
|
287
|
+
style = item.style && _typeof(item.style) === 'object' ? style : {
|
|
288
|
+
color: style
|
|
289
|
+
};
|
|
290
|
+
style = (0, _convertCamelToCSS["default"])(style);
|
|
291
|
+
}
|
|
292
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
293
|
+
filter: filter,
|
|
294
|
+
style: style
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
257
299
|
// 临时数据
|
|
258
300
|
_this2._features = [];
|
|
259
301
|
|
|
@@ -314,39 +356,34 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
314
356
|
this.show = value;
|
|
315
357
|
this.setVisible(value);
|
|
316
358
|
}
|
|
317
|
-
}, {
|
|
318
|
-
key: "destroy",
|
|
319
|
-
value: function destroy() {
|
|
320
|
-
var map = this.map;
|
|
321
|
-
if (this.moveEnd) {
|
|
322
|
-
map.un("moveend", this.moveEnd);
|
|
323
|
-
this.moveEnd = null;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
359
|
}, {
|
|
327
360
|
key: "setClusterMode",
|
|
328
361
|
value: function setClusterMode(val) {
|
|
329
362
|
var _this3 = this;
|
|
330
|
-
this._options.cluster = val
|
|
363
|
+
this._options.cluster = (0, _isObject["default"])(val) ? val : {
|
|
364
|
+
show: val
|
|
365
|
+
};
|
|
331
366
|
this.setClusterSource(val);
|
|
332
367
|
this.setStyle(this.getStyleByMode());
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
_this3.
|
|
345
|
-
|
|
346
|
-
|
|
368
|
+
if (this.map && this._options.cluster.show) {
|
|
369
|
+
var map = this.map;
|
|
370
|
+
this.destroy();
|
|
371
|
+
|
|
372
|
+
// 监听地图缩放大于阈值时取消聚合
|
|
373
|
+
var oldZoom = map.getView().getZoom();
|
|
374
|
+
this.moveEnd = map.on("moveend", function () {
|
|
375
|
+
var zoom = map.getView().getZoom(); //获取当前地图的缩放级别
|
|
376
|
+
if (oldZoom !== zoom) {
|
|
377
|
+
var _this3$_options$clust;
|
|
378
|
+
oldZoom = zoom;
|
|
379
|
+
if (zoom >= (((_this3$_options$clust = _this3._options.cluster) === null || _this3$_options$clust === void 0 ? void 0 : _this3$_options$clust.zoomThreshold) || 14)) {
|
|
380
|
+
_this3.setClusterSource();
|
|
381
|
+
} else {
|
|
382
|
+
_this3.setClusterSource(val);
|
|
383
|
+
}
|
|
347
384
|
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
385
|
+
});
|
|
386
|
+
}
|
|
350
387
|
}
|
|
351
388
|
}, {
|
|
352
389
|
key: "getStyleByMode",
|
|
@@ -577,13 +614,14 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
577
614
|
var _this$_features,
|
|
578
615
|
_this6 = this;
|
|
579
616
|
var _this = this;
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
617
|
+
cluster = (0, _isObject["default"])(cluster) ? cluster : {
|
|
618
|
+
show: cluster
|
|
619
|
+
};
|
|
620
|
+
var _cluster = cluster,
|
|
621
|
+
show = _cluster.show,
|
|
622
|
+
minDistance = _cluster.minDistance,
|
|
623
|
+
distance = _cluster.distance,
|
|
624
|
+
group = _cluster.group;
|
|
587
625
|
var source = new _source.Vector({
|
|
588
626
|
features: (_this$_features = this._features) === null || _this$_features === void 0 ? void 0 : _this$_features.filter(function (v) {
|
|
589
627
|
return !v.hasOwnProperty('show') || v.show;
|
|
@@ -596,6 +634,9 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
596
634
|
minDistance: minDistance || 50,
|
|
597
635
|
source: source,
|
|
598
636
|
group: group,
|
|
637
|
+
clusterChange: function clusterChange(features) {
|
|
638
|
+
_this6.setAlarmBgByFeatures(features);
|
|
639
|
+
},
|
|
599
640
|
createCluster: function createCluster(point, features) {
|
|
600
641
|
var _group;
|
|
601
642
|
var feature = new _ol.Feature({
|
|
@@ -618,7 +659,7 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
618
659
|
});
|
|
619
660
|
var markerStyle = _objectSpread({}, style.style);
|
|
620
661
|
if (size > 1) {
|
|
621
|
-
var _style4, _markerStyle2;
|
|
662
|
+
var _style4, _markerStyle2, _cluster2;
|
|
622
663
|
if ((_style4 = style) !== null && _style4 !== void 0 && _style4.clusterStyle) {
|
|
623
664
|
markerStyle = _objectSpread({}, style.clusterStyle);
|
|
624
665
|
}
|
|
@@ -634,7 +675,7 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
634
675
|
text: size,
|
|
635
676
|
fontSize: 18
|
|
636
677
|
}
|
|
637
|
-
}, iconOptions || (cluster === null ||
|
|
678
|
+
}, iconOptions || ((_cluster2 = cluster) === null || _cluster2 === void 0 ? void 0 : _cluster2.iconOptions) || {})
|
|
638
679
|
});
|
|
639
680
|
}
|
|
640
681
|
var _style = new _renderer["default"].Marker(markerStyle);
|
|
@@ -654,10 +695,48 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
654
695
|
this.setSource(source);
|
|
655
696
|
}
|
|
656
697
|
}
|
|
698
|
+
|
|
699
|
+
// 清除报警背景
|
|
700
|
+
}, {
|
|
701
|
+
key: "clearAlarmBg",
|
|
702
|
+
value: function clearAlarmBg() {
|
|
703
|
+
var _this$overlays,
|
|
704
|
+
_this7 = this;
|
|
705
|
+
if (this.map && (_this$overlays = this.overlays) !== null && _this$overlays !== void 0 && _this$overlays.length) {
|
|
706
|
+
this.overlays.map(function (overlay) {
|
|
707
|
+
return _this7.map.removeOverlay(overlay);
|
|
708
|
+
});
|
|
709
|
+
this.overlays = null;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// 设置报警背景
|
|
714
|
+
}, {
|
|
715
|
+
key: "setAlarmBgByFeatures",
|
|
716
|
+
value: function setAlarmBgByFeatures(features) {
|
|
717
|
+
var _this8 = this;
|
|
718
|
+
this.clearAlarmBg();
|
|
719
|
+
this.overlays = [];
|
|
720
|
+
if (this.map && this.alarmBg && features !== null && features !== void 0 && features.length) {
|
|
721
|
+
features.map(function (feature) {
|
|
722
|
+
var _feature = feature;
|
|
723
|
+
var cluster = feature.get('features');
|
|
724
|
+
if (cluster) {
|
|
725
|
+
_feature = cluster.length < 2 ? cluster[0] : null;
|
|
726
|
+
}
|
|
727
|
+
if (_feature && (_feature.hasOwnProperty('show') ? _feature.show : true)) {
|
|
728
|
+
var overlay = addOverlay(_feature, _this8.map, _this8.alarmBg);
|
|
729
|
+
if (overlay) {
|
|
730
|
+
_this8.overlays.push(overlay);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
}
|
|
657
736
|
}, {
|
|
658
737
|
key: "refresh",
|
|
659
738
|
value: function refresh() {
|
|
660
|
-
var
|
|
739
|
+
var _this9 = this;
|
|
661
740
|
(0, _createFeatureCollection.getDataByHttpByParams)({
|
|
662
741
|
url: this.url,
|
|
663
742
|
params: this.params,
|
|
@@ -667,10 +746,10 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
667
746
|
}).then(function (features) {
|
|
668
747
|
if (features) {
|
|
669
748
|
var new_features = features;
|
|
670
|
-
|
|
749
|
+
_this9._features = new_features;
|
|
671
750
|
var newFeatures = [];
|
|
672
751
|
new_features.map(function (v) {
|
|
673
|
-
var f =
|
|
752
|
+
var f = _this9.getFeatureByFieldValue('id', v.values_.id);
|
|
674
753
|
if (f) {
|
|
675
754
|
f.values_ = v.values_;
|
|
676
755
|
} else {
|
|
@@ -678,9 +757,10 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
678
757
|
}
|
|
679
758
|
});
|
|
680
759
|
if (newFeatures.length) {
|
|
681
|
-
|
|
760
|
+
_this9.getSource().addFeatures(newFeatures);
|
|
761
|
+
_this9.setAlarmBgByFeatures(_this9.getSource().getFeatures());
|
|
682
762
|
}
|
|
683
|
-
|
|
763
|
+
_this9.getSource().changed();
|
|
684
764
|
}
|
|
685
765
|
});
|
|
686
766
|
}
|
|
@@ -690,6 +770,7 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
690
770
|
this.getSource().clear();
|
|
691
771
|
var features = (0, _createFeatureCollection.createGeoJson)(data);
|
|
692
772
|
this.getSource().addFeatures(features);
|
|
773
|
+
this.setAlarmBgByFeatures(this.getSource().getFeatures());
|
|
693
774
|
this._features = features;
|
|
694
775
|
if (this._options.cluster) {
|
|
695
776
|
this.setClusterMode(this._options.cluster);
|
|
@@ -698,7 +779,7 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
698
779
|
}, {
|
|
699
780
|
key: "loadUrlData",
|
|
700
781
|
value: function loadUrlData(url, params, method) {
|
|
701
|
-
var
|
|
782
|
+
var _this10 = this;
|
|
702
783
|
var afterGetData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.afterGetData;
|
|
703
784
|
this.getSource().clear();
|
|
704
785
|
this._features = [];
|
|
@@ -712,12 +793,15 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
712
793
|
afterGetData: afterGetData,
|
|
713
794
|
field: this.dataField
|
|
714
795
|
}).then(function (features) {
|
|
796
|
+
_this10.getSource().clear();
|
|
797
|
+
_this10._features = [];
|
|
715
798
|
if (features !== null && features !== void 0 && features.length) {
|
|
716
|
-
|
|
717
|
-
|
|
799
|
+
_this10._features = features;
|
|
800
|
+
_this10.getSource().addFeatures(features);
|
|
801
|
+
_this10.setAlarmBgByFeatures(_this10.getSource().getFeatures());
|
|
718
802
|
}
|
|
719
|
-
if (
|
|
720
|
-
|
|
803
|
+
if (_this10._options.cluster) {
|
|
804
|
+
_this10.setClusterMode(_this10._options.cluster);
|
|
721
805
|
}
|
|
722
806
|
});
|
|
723
807
|
}
|
|
@@ -726,6 +810,7 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
726
810
|
value: function loadFeatures(features) {
|
|
727
811
|
this.getSource().clear();
|
|
728
812
|
this.getSource().addFeatures(features);
|
|
813
|
+
this.setAlarmBgByFeatures(this.getSource().getFeatures());
|
|
729
814
|
this._features = features;
|
|
730
815
|
if (this._options.cluster) {
|
|
731
816
|
this.setClusterMode(this._options.cluster);
|
|
@@ -746,16 +831,16 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
746
831
|
}
|
|
747
832
|
}, {
|
|
748
833
|
key: "getFeaturesByFieldValueOpera",
|
|
749
|
-
value: function getFeaturesByFieldValueOpera(
|
|
750
|
-
var
|
|
751
|
-
var field =
|
|
752
|
-
value =
|
|
753
|
-
|
|
754
|
-
operation =
|
|
755
|
-
features =
|
|
756
|
-
filter =
|
|
834
|
+
value: function getFeaturesByFieldValueOpera(_ref2) {
|
|
835
|
+
var _this11 = this;
|
|
836
|
+
var field = _ref2.field,
|
|
837
|
+
value = _ref2.value,
|
|
838
|
+
_ref2$operation = _ref2.operation,
|
|
839
|
+
operation = _ref2$operation === void 0 ? '===' : _ref2$operation,
|
|
840
|
+
features = _ref2.features,
|
|
841
|
+
filter = _ref2.filter;
|
|
757
842
|
return new Promise(function (resolve, reject) {
|
|
758
|
-
var _features = features ||
|
|
843
|
+
var _features = features || _this11.getFeatures();
|
|
759
844
|
if (filter) {
|
|
760
845
|
_features = _features.filter(function (feature) {
|
|
761
846
|
return filter(feature.values_);
|
|
@@ -828,6 +913,7 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
828
913
|
} else {
|
|
829
914
|
this.setStyle(this.getStyleByMode());
|
|
830
915
|
}
|
|
916
|
+
this.setAlarmBgByFeatures(this._features);
|
|
831
917
|
}
|
|
832
918
|
}
|
|
833
919
|
|
|
@@ -862,6 +948,26 @@ var FeatureLayer = /*#__PURE__*/function (_Vector) {
|
|
|
862
948
|
if (!this.inited) {
|
|
863
949
|
this.init();
|
|
864
950
|
}
|
|
951
|
+
if (!visible) {
|
|
952
|
+
this.clearAlarmBg();
|
|
953
|
+
} else {
|
|
954
|
+
this.setAlarmBgByFeatures(this.getSource().getFeatures());
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}, {
|
|
958
|
+
key: "clearMoveEnd",
|
|
959
|
+
value: function clearMoveEnd() {
|
|
960
|
+
var map = this.map;
|
|
961
|
+
if (map && this.moveEnd) {
|
|
962
|
+
map.un("moveend", this.moveEnd);
|
|
963
|
+
this.moveEnd = null;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
}, {
|
|
967
|
+
key: "destroy",
|
|
968
|
+
value: function destroy() {
|
|
969
|
+
this.clearMoveEnd();
|
|
970
|
+
this.clearAlarmBg();
|
|
865
971
|
}
|
|
866
972
|
}]);
|
|
867
973
|
return FeatureLayer;
|