@vtx/map 1.1.36 → 1.1.38

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.
Files changed (63) hide show
  1. package/lib/VtxMap/AMap/AMap.js +1014 -624
  2. package/lib/VtxMap/AMap/AMap.js.map +1 -1
  3. package/lib/VtxMap/BMap/Map.js +1207 -746
  4. package/lib/VtxMap/BMap/Map.js.map +1 -1
  5. package/lib/VtxMap/GMap/Map.js +1564 -1046
  6. package/lib/VtxMap/GMap/Map.js.map +1 -1
  7. package/lib/VtxMap/Map.js +42 -8
  8. package/lib/VtxMap/Map.js.map +1 -1
  9. package/lib/VtxMap/MapToolFunction.js +63 -26
  10. package/lib/VtxMap/MapToolFunction.js.map +1 -1
  11. package/lib/VtxMap/OMap/Map.js +1361 -867
  12. package/lib/VtxMap/OMap/Map.js.map +1 -1
  13. package/lib/VtxMap/OlMap/Map.js +1276 -746
  14. package/lib/VtxMap/OlMap/Map.js.map +1 -1
  15. package/lib/VtxMap/TMap/TMap.js +1072 -645
  16. package/lib/VtxMap/TMap/TMap.js.map +1 -1
  17. package/lib/VtxMap/index.js +8 -1
  18. package/lib/VtxMap/index.js.map +1 -1
  19. package/lib/VtxMap/mapPlayer.js +123 -67
  20. package/lib/VtxMap/mapPlayer.js.map +1 -1
  21. package/lib/VtxMap/optimizingPointMap.js +77 -21
  22. package/lib/VtxMap/optimizingPointMap.js.map +1 -1
  23. package/lib/VtxMap/style/css.js +6 -0
  24. package/lib/VtxMap/style/css.js.map +1 -1
  25. package/lib/VtxMap/style/index.js +6 -0
  26. package/lib/VtxMap/style/index.js.map +1 -1
  27. package/lib/VtxMap/zoomMap.js +41 -12
  28. package/lib/VtxMap/zoomMap.js.map +1 -1
  29. package/lib/VtxModal/VtxModal.js +63 -19
  30. package/lib/VtxModal/VtxModal.js.map +1 -1
  31. package/lib/VtxModal/draggableModal.js +48 -12
  32. package/lib/VtxModal/draggableModal.js.map +1 -1
  33. package/lib/VtxModal/index.js +6 -1
  34. package/lib/VtxModal/index.js.map +1 -1
  35. package/lib/VtxModal/style/css.js +6 -0
  36. package/lib/VtxModal/style/css.js.map +1 -1
  37. package/lib/VtxModal/style/index.js +6 -0
  38. package/lib/VtxModal/style/index.js.map +1 -1
  39. package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js +238 -105
  40. package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js.map +1 -1
  41. package/lib/VtxSearchCheckMap/index.js +2 -0
  42. package/lib/VtxSearchCheckMap/index.js.map +1 -1
  43. package/lib/VtxSearchCheckMap/mapping.js +2 -1
  44. package/lib/VtxSearchCheckMap/mapping.js.map +1 -1
  45. package/lib/VtxSearchCheckMap/style/css.js +19 -0
  46. package/lib/VtxSearchCheckMap/style/css.js.map +1 -1
  47. package/lib/VtxSearchCheckMap/style/index.js +19 -0
  48. package/lib/VtxSearchCheckMap/style/index.js.map +1 -1
  49. package/lib/VtxSearchMap/VtxSearchMap.js +221 -91
  50. package/lib/VtxSearchMap/VtxSearchMap.js.map +1 -1
  51. package/lib/VtxSearchMap/index.js +2 -0
  52. package/lib/VtxSearchMap/index.js.map +1 -1
  53. package/lib/VtxSearchMap/mapping.js +2 -1
  54. package/lib/VtxSearchMap/mapping.js.map +1 -1
  55. package/lib/VtxSearchMap/style/css.js +19 -0
  56. package/lib/VtxSearchMap/style/css.js.map +1 -1
  57. package/lib/VtxSearchMap/style/index.js +19 -0
  58. package/lib/VtxSearchMap/style/index.js.map +1 -1
  59. package/lib/default.js +13 -4
  60. package/lib/default.js.map +1 -1
  61. package/lib/index.js +3 -0
  62. package/lib/index.js.map +1 -1
  63. package/package.json +1 -1
@@ -1,57 +1,94 @@
1
1
  "use strict";
2
2
 
3
+ 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); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports["default"] = void 0;
9
+
7
10
  var _react = _interopRequireDefault(require("react"));
11
+
8
12
  var _default2 = _interopRequireDefault(require("../../default"));
13
+
9
14
  var _MapToolFunction = require("../MapToolFunction");
15
+
10
16
  var _immutable = _interopRequireDefault(require("immutable"));
17
+
11
18
  var _lodash = require("lodash");
19
+
12
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
14
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
21
+
22
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
23
+
15
24
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
25
+
16
26
  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."); }
27
+
17
28
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
29
+
18
30
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
31
+
19
32
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
33
+
20
34
  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."); }
35
+
21
36
  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); }
22
- 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; }
23
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
37
+
38
+ 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; }
39
+
40
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
41
+
24
42
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
26
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
43
+
44
+ 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; }
45
+
46
+ 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; }
47
+
27
48
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
49
+
50
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
51
+
29
52
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
53
+
30
54
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
55
+
31
56
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
57
+
32
58
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
59
+
33
60
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
61
+
34
62
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
63
+
35
64
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
65
+
36
66
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
37
- 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; }
38
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
39
- 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); } //公共地址配置
67
+
68
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
69
+
40
70
  var Set = _immutable["default"].Set;
71
+
41
72
  var OlMap = /*#__PURE__*/function (_React$Component) {
42
73
  _inherits(OlMap, _React$Component);
74
+
43
75
  var _super = _createSuper(OlMap);
76
+
44
77
  function OlMap(props) {
45
78
  var _this;
79
+
46
80
  _classCallCheck(this, OlMap);
81
+
47
82
  _this = _super.call(this, props);
48
- // 加载图层
83
+
49
84
  _defineProperty(_assertThisInitialized(_this), "loadLayers", function () {
50
85
  var nextLayers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
51
86
  var currentLayers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
52
87
  var first = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
53
- var t = _assertThisInitialized(_this);
54
- // 对比图层的变化,找出需要新增和需要删除的。
88
+
89
+ var t = _assertThisInitialized(_this); // 对比图层的变化,找出需要新增和需要删除的。
90
+
91
+
55
92
  var addLayers = nextLayers.filter(function (item) {
56
93
  return !currentLayers.map(function (e) {
57
94
  return e.coverage;
@@ -62,6 +99,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
62
99
  return e.coverage;
63
100
  }).includes(item.coverage);
64
101
  });
102
+
65
103
  if (removeLayers.length > 0) {
66
104
  removeLayers.forEach(function (item) {
67
105
  var exist = t.olLayers.find(function (e) {
@@ -70,6 +108,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
70
108
  exist && exist.layer.setVisible(false);
71
109
  });
72
110
  }
111
+
73
112
  if (addLayers.length > 0) {
74
113
  addLayers.map(function (item) {
75
114
  if (item.coverage.startsWith("http") || item.coverage.startsWith('/')) {
@@ -79,17 +118,21 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
79
118
  t.addSuperMapLayer(item.coverage);
80
119
  break;
81
120
  // geoServer_geoJSON
121
+
82
122
  case 'geoServer':
83
123
  t.addGeoServerLayer(item.coverage);
84
124
  // geoServer_image
125
+
85
126
  case 'geoServer_image':
86
127
  t.addGeoServerImageLayer(item);
128
+
87
129
  default:
88
130
  break;
89
131
  }
90
132
  } else if (OL_SCREEN[item.coverage]) {
91
133
  if (first) {
92
134
  var layers = eval(OL_SCREEN[item.coverage].initLayer);
135
+
93
136
  if ((0, _lodash.isArray)(layers)) {
94
137
  layers.map(function (layer) {
95
138
  t.state.gis.addLayer(layer);
@@ -103,33 +146,50 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
103
146
  } else {
104
147
  if (first) {
105
148
  var _layer = eval(OL_SCREEN["default"].initLayer);
149
+
106
150
  t.state.gis.addLayer(_layer);
107
151
  }
108
152
  }
109
153
  });
154
+
110
155
  _this.zIndexGraphics = []; //需要放在最后的图元,zoom和pan时刷新dom到最后
156
+
111
157
  _this.htmlPointsId = 'vtx_gmap_html_points'; //html点位容器id class管理
158
+
112
159
  _this.pointCollectionId = 'vtx_gmap_html_pointCollection'; //海量点canvas点位容器id class管理
160
+
113
161
  _this.Label = {}; //所有label 集合
162
+
114
163
  _this.labelLayer = {
115
164
  x: 0,
116
165
  y: 0
117
166
  }; //label图层 位置管理
167
+
118
168
  _this.viewer = null;
119
169
  _this.GM = new _MapToolFunction.graphicManage(); //初始化 图元管理方法
170
+
120
171
  _this.getPolygonArea = _MapToolFunction.getPolygonArea;
121
172
  _this.layer = null; //保存地图图层数据
173
+
122
174
  _this.loadTimer = null; //初始化地图 load时延缓数据处理
175
+
123
176
  _this.animTimer = {}; //点位跳动动画 定时集合
177
+
124
178
  _this.animCount = {}; //点位跳动动画 定时计数
179
+
125
180
  _this.moveToTimer = null; //moveTo时间对象
181
+
126
182
  _this.drawToolbar = null; //地图绘制对象即interaction
183
+
127
184
  _this.drawParam = {}; //缓存 绘制的数据
185
+
128
186
  _this.editToolbar = null; //编辑对象
187
+
129
188
  _this.editId = ''; //当前编辑的图元id
189
+
130
190
  _this.drawSource = null;
131
- _this.drawVector = null;
132
- // 图元绘制保存
191
+ _this.drawVector = null; // 图元绘制保存
192
+
133
193
  _this.drawInfo = {
134
194
  sketch: null,
135
195
  listener: null
@@ -144,15 +204,23 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
144
204
  isCount: false
145
205
  };
146
206
  _this.heatmap = null; //热力图对象
207
+
147
208
  _this.clusterMarkers = []; //聚合点位id数组
209
+
148
210
  _this.clusterPs = []; //聚合集合点
211
+
149
212
  _this.clusterPt = []; //地图中聚合点集合
213
+
150
214
  _this.morepoints = []; //海量点集合
215
+
151
216
  _this.areaRestriction = null; //区域限制数据
217
+
152
218
  _this.movePoints = [];
153
219
  _this.olLayers = []; // ol图层集合 {address:'', layer: ''}
220
+
154
221
  _this.baseLayer = null; // 地图图层
155
222
  //是否绘制测距
223
+
156
224
  _this.rangingTool = {
157
225
  isRanging: false,
158
226
  //是否开启状态
@@ -163,8 +231,10 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
163
231
  distance: 0,
164
232
  //测距长度
165
233
  mapRangingTool: null //测距回调
234
+
166
235
  };
167
236
  _this.rangingTools = {}; //测距点线缓存
237
+
168
238
  _this.rangingInfo = {
169
239
  sketch: null,
170
240
  helpTooltipElement: null,
@@ -217,10 +287,13 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
217
287
  }
218
288
  };
219
289
  _this.frameSelectProps = {};
290
+
220
291
  _this.loadMapJs();
292
+
221
293
  return _this;
222
- }
223
- // 引入ol样式
294
+ } // 引入ol样式
295
+
296
+
224
297
  _createClass(OlMap, [{
225
298
  key: "loadMapJs",
226
299
  value: function loadMapJs() {
@@ -252,13 +325,13 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
252
325
  }).appendTo('head');
253
326
  }
254
327
  });
255
- }
256
- // 初始化地圖
328
+ } // 初始化地圖
329
+
257
330
  }, {
258
331
  key: "init",
259
332
  value: function init() {
260
- var t = this;
261
- // 创建地图
333
+ var t = this; // 创建地图
334
+
262
335
  t.createMap();
263
336
  t.drawSource = new ol.source.Vector({
264
337
  wrapX: false
@@ -266,100 +339,117 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
266
339
  t.drawVector = new ol.layer.Vector({
267
340
  source: t.drawSource
268
341
  });
342
+
269
343
  var initData = function initData() {
270
344
  var _t$props = t.props,
271
- mapPoints = _t$props.mapPoints,
272
- mapLines = _t$props.mapLines,
273
- mapPolygons = _t$props.mapPolygons,
274
- mapCircles = _t$props.mapCircles,
275
- mapVisiblePoints = _t$props.mapVisiblePoints,
276
- mapCluster = _t$props.mapCluster,
277
- mapPointCollection = _t$props.mapPointCollection,
278
- areaRestriction = _t$props.areaRestriction,
279
- heatMapData = _t$props.heatMapData;
280
- // 初始化中心点
281
- t.setCenter();
282
- // 添加点
345
+ mapPoints = _t$props.mapPoints,
346
+ mapLines = _t$props.mapLines,
347
+ mapPolygons = _t$props.mapPolygons,
348
+ mapCircles = _t$props.mapCircles,
349
+ mapVisiblePoints = _t$props.mapVisiblePoints,
350
+ mapCluster = _t$props.mapCluster,
351
+ mapPointCollection = _t$props.mapPointCollection,
352
+ areaRestriction = _t$props.areaRestriction,
353
+ heatMapData = _t$props.heatMapData; // 初始化中心点
354
+
355
+ t.setCenter(); // 添加点
356
+
283
357
  if (mapPoints instanceof Array) {
284
358
  t.addPoint(mapPoints);
285
- }
286
- //添加线
359
+ } //添加线
360
+
361
+
287
362
  if (mapLines instanceof Array) {
288
363
  t.addLine(mapLines);
289
- }
290
- //添加面
364
+ } //添加面
365
+
366
+
291
367
  if (mapPolygons instanceof Array) {
292
368
  t.addPolygon(mapPolygons);
293
- }
294
- //添加圆
369
+ } //添加圆
370
+
371
+
295
372
  if (mapCircles instanceof Array) {
296
373
  t.addCircle(mapCircles);
297
- }
298
- //是否设置比例尺
374
+ } //是否设置比例尺
375
+
376
+
299
377
  if (t.props.showControl) {
300
378
  t.showControl(t.props);
301
- }
302
- // 画热力图
379
+ } // 画热力图
380
+
381
+
303
382
  if (heatMapData) {
304
383
  t.heatMapOverlay(heatMapData);
305
- }
306
- //设置点聚合
384
+ } //设置点聚合
385
+
386
+
307
387
  if (mapCluster instanceof Array) {
308
388
  t.cluster(mapCluster);
309
389
  }
310
390
  /*设置指定图元展示*/
391
+
392
+
311
393
  if (mapVisiblePoints) {
312
394
  t.setVisiblePoints(mapVisiblePoints);
313
- }
314
- //添加海量点
395
+ } //添加海量点
396
+
397
+
315
398
  if (mapPointCollection instanceof Array) {
316
399
  t.addPointCollection(mapPointCollection);
317
- }
318
- //设置区域限制
400
+ } //设置区域限制
401
+
402
+
319
403
  if (areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
320
404
  t.setAreaRestriction(areaRestriction);
321
405
  }
406
+
322
407
  t.setState({
323
408
  mapCreated: true
324
409
  });
325
410
  };
411
+
326
412
  var event = function event(e, status) {
327
413
  var gis = t.state.gis;
328
414
  var overall_feature = null; //鼠标移入事件时记录当前的feature,为鼠标移出要素时保存操作的要素对象
415
+
329
416
  var dragAddMoveFlag = false; //记录地图拖拽和移动事件
330
417
  // 地图开始加载时
418
+
331
419
  gis.on('loadstart', function () {
332
420
  gis.getTargetElement().classList.add('spinner');
333
- });
334
- // 地图加载结束时
421
+ }); // 地图加载结束时
422
+
335
423
  gis.on('loadend', function () {
336
424
  gis.getTargetElement().classList.remove('spinner');
337
- });
338
- // 地图双击事件
339
- gis.on('dbclick', function (evt) {});
340
- // 地图点击事件
425
+ }); // 地图双击事件
426
+
427
+ gis.on('dbclick', function (evt) {}); // 地图点击事件
428
+
341
429
  gis.on('singleclick', function (evt) {
342
430
  var feature = gis.forEachFeatureAtPixel(evt.pixel, function (feature) {
343
431
  return feature;
344
432
  });
433
+
345
434
  if (feature) {
346
- var target = feature.getProperties();
347
- // top: e.clientY,//当前点所在的位置(屏幕)
435
+ var target = feature.getProperties(); // top: e.clientY,//当前点所在的位置(屏幕)
348
436
  // left: e.clientX,
437
+
349
438
  t.clickGraphic(target.id || target.elementId, evt, target);
350
439
  } else {
351
440
  t.clickMap(evt);
352
441
  }
353
- });
354
- // 鼠标移动事件 - 当鼠标指向要素时改变光标状态
442
+ }); // 鼠标移动事件 - 当鼠标指向要素时改变光标状态
443
+
355
444
  gis.on('pointermove', function (evt) {
356
445
  var pixel = gis.getEventPixel(evt.originalEvent);
357
446
  var hit = gis.hasFeatureAtPixel(pixel);
358
- gis.getTargetElement().style.cursor = hit ? 'pointer' : 'default';
359
- // 获取到当前鼠标移动下的feature
447
+ gis.getTargetElement().style.cursor = hit ? 'pointer' : 'default'; // 获取到当前鼠标移动下的feature
448
+
360
449
  var feature = gis.forEachFeatureAtPixel(pixel, function (feature, layer) {
361
450
  return feature;
362
451
  });
452
+
363
453
  if (feature) {
364
454
  overall_feature = feature;
365
455
  var values = feature.getProperties();
@@ -370,20 +460,22 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
370
460
  type: 'mousein',
371
461
  event: evt
372
462
  });
463
+
373
464
  var _values = overall_feature.getProperties();
465
+
374
466
  t.mouseOutGraphic(_values.id, evt);
375
467
  overall_feature = null;
376
468
  }
377
469
  }
378
- });
379
- // 鼠标拖拽事件 - 拖拽开始即是地图移动开始
470
+ }); // 鼠标拖拽事件 - 拖拽开始即是地图移动开始
471
+
380
472
  gis.on('pointerdrag', function (evt) {
381
473
  dragAddMoveFlag = true;
382
474
  t.dragMapStart(evt);
383
475
  t.moveStart(evt);
384
476
  });
385
- var zoom = 0;
386
- // 地图移动事件 - 移动结束即是拖拽事件结束 也是地图缩放事件(无开始和结束事件)的监听
477
+ var zoom = 0; // 地图移动事件 - 移动结束即是拖拽事件结束 也是地图缩放事件(无开始和结束事件)的监听
478
+
387
479
  gis.on('moveend', function (evt) {
388
480
  t.dragMapEnd(evt);
389
481
  t.moveEnd(evt);
@@ -392,46 +484,51 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
392
484
  t.zoomEnd(evt);
393
485
  }, 300);
394
486
  dragAddMoveFlag = false;
395
- });
396
- // gis.getViewport().addEventListener('mouseout', function () {
487
+ }); // gis.getViewport().addEventListener('mouseout', function () {
397
488
  // helpTooltipElement.classList.add('hidden');
398
489
  // });
399
490
  };
491
+
400
492
  event();
401
493
  t.setCenter(t.props.center);
402
494
  initData();
403
- }
404
- // 创建地图
495
+ } // 创建地图
496
+
405
497
  }, {
406
498
  key: "createMap",
407
499
  value: function createMap() {
408
500
  var t = this;
409
501
  var _t$props2 = t.props,
410
- _t$props2$olProps = _t$props2.olProps,
411
- olProps = _t$props2$olProps === void 0 ? {} : _t$props2$olProps,
412
- _t$props2$mapCenter = _t$props2.mapCenter,
413
- mapCenter = _t$props2$mapCenter === void 0 ? [] : _t$props2$mapCenter,
414
- mapId = _t$props2.mapId,
415
- mapZoomLevel = _t$props2.mapZoomLevel,
416
- minZoom = _t$props2.minZoom,
417
- maxZoom = _t$props2.maxZoom;
502
+ _t$props2$olProps = _t$props2.olProps,
503
+ olProps = _t$props2$olProps === void 0 ? {} : _t$props2$olProps,
504
+ _t$props2$mapCenter = _t$props2.mapCenter,
505
+ mapCenter = _t$props2$mapCenter === void 0 ? [] : _t$props2$mapCenter,
506
+ mapId = _t$props2.mapId,
507
+ mapZoomLevel = _t$props2.mapZoomLevel,
508
+ minZoom = _t$props2.minZoom,
509
+ maxZoom = _t$props2.maxZoom;
418
510
  var projection = olProps.projection,
419
- olCoverage = olProps.olCoverage;
511
+ olCoverage = olProps.olCoverage;
512
+
420
513
  if (window.VtxMap) {
421
514
  window.VtxMap[mapId] = null;
422
515
  } else {
423
516
  window.VtxMap = {};
424
517
  }
518
+
425
519
  if (!minZoom) {
426
520
  minZoom = 2;
427
521
  }
522
+
428
523
  if (!maxZoom) {
429
524
  maxZoom = 19;
430
525
  }
526
+
431
527
  if (!projection) {
432
528
  projection = 'EPSG:4326';
433
- }
434
- //中心点
529
+ } //中心点
530
+
531
+
435
532
  var center = mapCenter && mapCenter instanceof Array && mapCenter.length == 2 ? mapCenter : [116.400433, 39.906705];
436
533
  center = [parseFloat(center[0]), parseFloat(center[1])];
437
534
  window.VtxMap[mapId] = t.state.gis = new ol.Map({
@@ -448,8 +545,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
448
545
  rotate: false,
449
546
  attribution: false
450
547
  })
451
- });
452
- // 基本地图视图
548
+ }); // 基本地图视图
549
+
453
550
  t.viewer = new ol.View({
454
551
  center: center,
455
552
  zoom: mapZoomLevel || 10,
@@ -459,44 +556,47 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
459
556
  });
460
557
  t.loadLayers(olCoverage, [], true);
461
558
  t.initPropsForUser();
462
- }
559
+ } // 加载图层
560
+
463
561
  }, {
464
562
  key: "addSuperMapLayer",
465
- value:
466
- // 添加超图图层
563
+ value: // 添加超图图层
467
564
  function addSuperMapLayer(url) {
468
565
  var exist = this.olLayers.find(function (item) {
469
566
  return item.address === url;
470
567
  });
568
+
471
569
  if (exist) {
472
570
  exist.layer.setVisible(true);
473
571
  return;
474
572
  }
573
+
475
574
  var layer = new ol.layer.Tile({
476
575
  source: new ol.source.TileSuperMapRest({
477
576
  url: url
478
577
  })
479
- });
480
- // 将图层添加到地图上
578
+ }); // 将图层添加到地图上
579
+
481
580
  this.state.gis.addLayer(layer);
482
581
  this.olLayers.push({
483
582
  address: url,
484
583
  layer: layer
485
584
  });
486
- }
487
- // 添加geoServer_geoJSON图层
585
+ } // 添加geoServer_geoJSON图层
586
+
488
587
  }, {
489
588
  key: "addGeoServerLayer",
490
589
  value: function addGeoServerLayer(_url) {
491
590
  var exist = this.olLayers.find(function (item) {
492
591
  return item.address === _url;
493
592
  });
593
+
494
594
  if (exist) {
495
595
  exist.layer.setVisible(true);
496
596
  return;
497
- }
597
+ } // 矢量数据源
598
+
498
599
 
499
- // 矢量数据源
500
600
  var vectorSource = new ol.source.Vector({
501
601
  // 设置格式化类型
502
602
  format: new ol.format.GeoJSON(),
@@ -505,15 +605,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
505
605
  return "".concat(_url, "&bbox=").concat(extent.join(','));
506
606
  },
507
607
  strategy: ol.loadingstrategy.bbox
508
- });
608
+ }); // 矢量图层
509
609
 
510
- // 矢量图层
511
610
  var layer = new ol.layer.Vector({
512
611
  // 设置数据源
513
612
  source: vectorSource,
514
613
  // 设置图层样式也可以 function (feature) { /** 根据内容动态加载样式 **/ return Style}
515
614
  style: function style(feature) {
516
615
  var _icon$;
616
+
517
617
  var el = feature.A || {};
518
618
  var icon = JSON.parse(el.icon || '[]');
519
619
  var mapIcon = (_icon$ = icon[0]) !== null && _icon$ !== void 0 && _icon$.id ? "/cloudFile/common/downloadFile?id=".concat(icon[0].id) : require("../images/defaultMarker.png");
@@ -534,8 +634,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
534
634
  })
535
635
  });
536
636
  }
537
- });
538
- // 将图层添加到地图上
637
+ }); // 将图层添加到地图上
638
+
539
639
  this.state.gis.addLayer(layer);
540
640
  this.olLayers.push({
541
641
  address: _url,
@@ -546,7 +646,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
546
646
  key: "formatUrl",
547
647
  value: function formatUrl(url) {
548
648
  var param = {},
549
- address = url.split("?")[0];
649
+ address = url.split("?")[0];
550
650
  url.split("?")[1].split("&").map(function (item) {
551
651
  var json = item.split("=");
552
652
  param[json[0].toUpperCase()] = json[1] ? decodeURIComponent(json[1]) : '';
@@ -555,8 +655,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
555
655
  param: param,
556
656
  address: address
557
657
  };
558
- }
559
- // 添加geoServer_image图层
658
+ } // 添加geoServer_image图层
659
+
560
660
  }, {
561
661
  key: "addGeoServerImageLayer",
562
662
  value: function addGeoServerImageLayer(item) {
@@ -564,15 +664,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
564
664
  var exist = this.olLayers.find(function (item) {
565
665
  return item.address === url;
566
666
  });
667
+
567
668
  if (exist) {
568
669
  exist.layer.setVisible(true);
569
670
  return;
570
671
  }
672
+
571
673
  var _this$formatUrl = this.formatUrl(url),
572
- _this$formatUrl$param = _this$formatUrl.param,
573
- param = _this$formatUrl$param === void 0 ? {} : _this$formatUrl$param,
574
- address = _this$formatUrl.address;
575
- // 矢量数据源
674
+ _this$formatUrl$param = _this$formatUrl.param,
675
+ param = _this$formatUrl$param === void 0 ? {} : _this$formatUrl$param,
676
+ address = _this$formatUrl.address; // 矢量数据源
677
+
678
+
576
679
  var vectorSource = new ol.source.ImageWMS({
577
680
  url: address,
578
681
  serverType: 'geoserver',
@@ -581,144 +684,169 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
581
684
  params: _objectSpread(_objectSpread({
582
685
  VERSION: '1.1.0'
583
686
  }, item.param || {}), param)
584
- });
687
+ }); // 矢量图层
585
688
 
586
- // 矢量图层
587
689
  var layer = new ol.layer.Image({
588
690
  // 设置数据源
589
691
  source: vectorSource
590
- });
591
- // 将图层添加到地图上
692
+ }); // 将图层添加到地图上
693
+
592
694
  this.state.gis.addLayer(layer);
593
695
  this.olLayers.push({
594
696
  address: url,
595
697
  layer: layer,
596
698
  source: vectorSource
597
699
  });
598
- }
599
- // 初始化对外方法
700
+ } // 初始化对外方法
701
+
600
702
  }, {
601
703
  key: "initPropsForUser",
602
704
  value: function initPropsForUser() {
603
705
  var t = this;
706
+
604
707
  t.state.gis["getCenter"] = function () {
605
708
  return t.getCenter();
606
709
  };
710
+
607
711
  t.state.gis["setCenter"] = function (gt) {
608
712
  t.setCenter(gt);
609
713
  };
714
+
610
715
  t.state.gis["getZoomLevel"] = function () {
611
716
  return t.getZoomLevel();
612
717
  };
718
+
613
719
  t.state.gis["showInfoWindow"] = function (obj) {
614
720
  return t.showInfoWindow(obj);
615
721
  };
722
+
616
723
  t.state.gis["hideInfoWindow"] = function () {
617
724
  return t.hideInfoWindow();
618
725
  };
726
+
619
727
  t.state.gis["frameSelect"] = function () {
620
728
  var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
621
729
  var callback = arguments.length > 1 ? arguments[1] : undefined;
622
730
  return t.frameSelect(obj, callback);
623
731
  };
732
+
624
733
  t.state.gis["clearFrameSelect"] = function () {
625
734
  return t.clearFrameSelect();
626
735
  };
736
+
627
737
  t.state.gis["clearFrameSelectById"] = function (id) {
628
738
  return t.clearFrameSelectById(id);
629
739
  };
740
+
630
741
  t.state.gis["refresh"] = function () {
631
742
  t.refresh();
632
743
  };
633
- }
634
- // 设置中心点
744
+ } // 设置中心点
745
+
635
746
  }, {
636
747
  key: "setCenter",
637
748
  value: function setCenter(gt) {
638
749
  var t = this;
750
+
751
+ if (!t.state.gis) {
752
+ return;
753
+ }
754
+
639
755
  if (gt) {
640
756
  //经纬度 必须存在 否则不操作
641
757
  if (!gt[0] || !gt[1]) {
642
758
  return false;
643
- }
644
- //如果设置的经纬度 与当前中心点一样 不操作
759
+ } //如果设置的经纬度 与当前中心点一样 不操作
760
+
761
+
645
762
  var c = t.getCenter();
763
+
646
764
  if (c.lng == gt[0] && c.lat == gt[1]) {
647
765
  return false;
648
766
  }
767
+
649
768
  t.state.gis.getView().setCenter(gt);
650
769
  t.viewer.animate({
651
770
  center: gt,
652
771
  duration: 2000
653
772
  });
654
773
  }
655
- }
656
- //设置地图缩放层级
774
+ } //设置地图缩放层级
775
+
657
776
  }, {
658
777
  key: "setZoomLevel",
659
778
  value: function setZoomLevel(zoom) {
660
779
  var t = this;
661
780
  var z = t.state.gis.getView().getZoom();
781
+
662
782
  if (z == zoom) {
663
783
  return false;
664
784
  }
785
+
665
786
  t.state.gis.getView().setZoom(zoom);
666
- }
667
- //获取当前中心点
787
+ } //获取当前中心点
788
+
668
789
  }, {
669
790
  key: "getCenter",
670
791
  value: function getCenter() {
671
792
  var t = this;
672
793
  var gis = t.state.gis;
794
+
673
795
  var _gis$getView$calculat = gis.getView().calculateExtent(gis.getSize()),
674
- _gis$getView$calculat2 = _slicedToArray(_gis$getView$calculat, 4),
675
- xmin = _gis$getView$calculat2[0],
676
- ymin = _gis$getView$calculat2[1],
677
- xmax = _gis$getView$calculat2[2],
678
- ymax = _gis$getView$calculat2[3];
796
+ _gis$getView$calculat2 = _slicedToArray(_gis$getView$calculat, 4),
797
+ xmin = _gis$getView$calculat2[0],
798
+ ymin = _gis$getView$calculat2[1],
799
+ xmax = _gis$getView$calculat2[2],
800
+ ymax = _gis$getView$calculat2[3];
801
+
679
802
  return {
680
803
  lng: (xmin + xmax) / 2,
681
804
  lat: (ymin + ymax) / 2
682
805
  };
683
- }
684
- //编辑图元
806
+ } //编辑图元
807
+
685
808
  }, {
686
809
  key: "doEdit",
687
810
  value: function doEdit(id) {
688
- var t = this;
689
- //获取图元对象
811
+ var t = this; //获取图元对象
812
+
690
813
  var gc = t.GM.getGraphic(id);
691
814
  var gp = t.GM.getGraphicParam(id);
692
- if (!gc) return false;
693
- //关闭先前编辑的图元
815
+ if (!gc) return false; //关闭先前编辑的图元
816
+
694
817
  if (!!t.state.editId) {
695
818
  t.endEdit();
696
819
  }
820
+
697
821
  if (!t.editToolbar) {
698
822
  t.editToolbar = new ol.interaction.Modify({
699
- source: gp.source
823
+ source: gp.source,
824
+ hitDetection: true
700
825
  });
701
826
  t.state.gis.addInteraction(t.editToolbar);
702
827
  } else {
703
828
  t.state.gis.addInteraction(t.editToolbar);
704
829
  }
830
+
705
831
  t.editToolbar.on('modifyend', function (e) {
706
832
  var feature = gc;
707
833
  e.features.forEach(function (feature) {
708
834
  feature = feature;
709
- });
710
- //返回参数
835
+ }); //返回参数
836
+
711
837
  var param = {
712
838
  id: id,
713
839
  e: e
714
- };
715
- // 绘制内部管理的图元
840
+ }; // 绘制内部管理的图元
841
+
716
842
  if (gp.geometry.type == 'point') {
717
843
  var cur = feature.getProperties().geometry;
844
+
718
845
  var _cur$flatCoordinates = _slicedToArray(cur.flatCoordinates, 2),
719
- lng = _cur$flatCoordinates[0],
720
- lat = _cur$flatCoordinates[1];
721
- //处理点返回参数
846
+ lng = _cur$flatCoordinates[0],
847
+ lat = _cur$flatCoordinates[1]; //处理点返回参数
848
+
849
+
722
850
  param = _objectSpread(_objectSpread({}, param), {}, {
723
851
  attributes: _objectSpread(_objectSpread({}, gp.attributes), {}, {
724
852
  longitude: lng,
@@ -747,12 +875,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
747
875
  y: lat
748
876
  }
749
877
  });
750
- }
751
- //线
878
+ } //线
879
+
880
+
752
881
  if (gp.geometry.type == 'polyline') {
753
882
  var _cur = feature.getProperties().geometry;
754
883
  var oddList = [],
755
- evenList = [];
884
+ evenList = [];
885
+
756
886
  _cur.flatCoordinates.map(function (item, index) {
757
887
  // 判断下标奇偶数
758
888
  if (index % 2 === 0) {
@@ -761,13 +891,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
761
891
  oddList.push(item);
762
892
  }
763
893
  });
894
+
764
895
  var path = oddList.map(function (item, index) {
765
896
  return [evenList[index], oddList[index]];
766
- });
767
- //处理线返回参数
897
+ }); //处理线返回参数
898
+
768
899
  var _t$dealData = t.dealData(path),
769
- lnglatAry = _t$dealData.lnglatAry,
770
- _extent = _t$dealData._extent;
900
+ lnglatAry = _t$dealData.lnglatAry,
901
+ _extent = _t$dealData._extent;
902
+
771
903
  param = _objectSpread(_objectSpread({}, param), {}, {
772
904
  attributes: _objectSpread(_objectSpread({}, gp.attributes), {}, {
773
905
  paths: path,
@@ -799,12 +931,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
799
931
  },
800
932
  distance: t.calculateDistance(path)
801
933
  });
802
- }
803
- //面
934
+ } //面
935
+
936
+
804
937
  if (gp.geometry.type == 'polygon') {
805
938
  var _cur2 = feature.getProperties().geometry;
806
939
  var _oddList = [],
807
- _evenList = [];
940
+ _evenList = [];
941
+
808
942
  _cur2.flatCoordinates.map(function (item, index) {
809
943
  // 判断下标奇偶数
810
944
  if (index % 2 === 0) {
@@ -813,13 +947,16 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
813
947
  _oddList.push(item);
814
948
  }
815
949
  });
950
+
816
951
  var _path = _oddList.map(function (item, index) {
817
952
  return [_evenList[index], _oddList[index]];
818
- });
819
- //处理线返回参数
953
+ }); //处理线返回参数
954
+
955
+
820
956
  var _t$dealData2 = t.dealData(_path),
821
- _lnglatAry = _t$dealData2.lnglatAry,
822
- _extent2 = _t$dealData2._extent;
957
+ _lnglatAry = _t$dealData2.lnglatAry,
958
+ _extent2 = _t$dealData2._extent;
959
+
823
960
  param = _objectSpread(_objectSpread({}, param), {}, {
824
961
  attributes: _objectSpread(_objectSpread({}, gp.attributes), {}, {
825
962
  rings: _path,
@@ -852,9 +989,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
852
989
  area: (0, _MapToolFunction.getPolygonArea)(_path)
853
990
  });
854
991
  }
992
+
855
993
  if (gp.geometry.type == 'circle') {
856
994
  var _cur3 = feature.getProperties().geometry;
995
+
857
996
  var center = _cur3.getCenter();
997
+
858
998
  var sketchCoords_ = [_cur3.flatCoordinates[0], _cur3.flatCoordinates[1]];
859
999
  var sketchCoords_2 = [_cur3.flatCoordinates[2], _cur3.flatCoordinates[3]];
860
1000
  var radius = ol.sphere.getDistance(sketchCoords_, sketchCoords_2);
@@ -899,27 +1039,31 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
899
1039
  }
900
1040
  });
901
1041
  }
1042
+
902
1043
  if ('editGraphicChange' in t.props && typeof t.props.editGraphicChange == 'function') {
903
1044
  t.props.editGraphicChange(param);
904
1045
  }
1046
+
905
1047
  t.GM.setGraphic(id, feature).setGraphicParam(id, _objectSpread(_objectSpread({}, param), {}, {
906
1048
  source: gp.source
907
1049
  }));
908
1050
  });
909
1051
  t.editId = id;
910
- }
911
- //关闭编辑
1052
+ } //关闭编辑
1053
+
912
1054
  }, {
913
1055
  key: "endEdit",
914
1056
  value: function endEdit() {
915
1057
  var t = this;
1058
+
916
1059
  if (t.editToolbar) {
917
1060
  t.state.gis.removeInteraction(t.editToolbar);
918
1061
  t.editToolbar = null;
919
1062
  }
1063
+
920
1064
  t.editId = '';
921
- }
922
- // 绘制图元
1065
+ } // 绘制图元
1066
+
923
1067
  }, {
924
1068
  key: "draw",
925
1069
  value: function draw(obj) {
@@ -927,35 +1071,38 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
927
1071
  var drawInfo = t.drawInfo;
928
1072
  var gis = t.state.gis;
929
1073
  var drawParam = {},
930
- image,
931
- stroke,
932
- fill;
933
- //初始化参数
1074
+ image,
1075
+ stroke,
1076
+ fill; //初始化参数
1077
+
934
1078
  drawParam.geometryType = obj.geometryType || 'point';
935
1079
  drawParam.parameter = obj.parameter ? _objectSpread({}, obj.parameter) : {};
936
1080
  drawParam.data = obj.data ? _objectSpread({}, obj.data) : {};
937
- drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime());
938
- //缓存 绘制的数据
939
- t.drawParam = drawParam;
940
- //判断id是否存在
1081
+ drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime()); //缓存 绘制的数据
1082
+
1083
+ t.drawParam = drawParam; //判断id是否存在
1084
+
941
1085
  var len = t.state.drawIds[drawParam.geometryType].indexOf(drawParam.data.id);
1086
+
942
1087
  if (len > -1) {
943
1088
  //如果id存在 删除存在的图元,清除drawId中的id数据
944
1089
  t.removeGraphic(drawParam.data.id);
945
1090
  t.state.drawIds[drawParam.geometryType].splice(len, 1);
946
1091
  }
1092
+
947
1093
  var type = 'Point',
948
- style = new ol.style.Style({
949
- image: new ol.style.Icon({
950
- anchor: [-drawParam.parameter.markerContentX || -15, -drawParam.parameter.markerContentY || -15],
951
- anchorXUnits: 'pixels',
952
- anchorYUnits: 'pixels',
953
- src: drawParam.parameter.url || require("../images/defaultMarker.png"),
954
- opacity: 1,
955
- scale: drawParam.parameter.scale || 1
956
- })
957
- });
1094
+ style = new ol.style.Style({
1095
+ image: new ol.style.Icon({
1096
+ anchor: [-drawParam.parameter.markerContentX || -15, -drawParam.parameter.markerContentY || -15],
1097
+ anchorXUnits: 'pixels',
1098
+ anchorYUnits: 'pixels',
1099
+ src: drawParam.parameter.url || require("../images/defaultMarker.png"),
1100
+ opacity: 1,
1101
+ scale: drawParam.parameter.scale || 1
1102
+ })
1103
+ });
958
1104
  var geometryFunction;
1105
+
959
1106
  switch (drawParam.geometryType) {
960
1107
  case 'point':
961
1108
  type = 'Point';
@@ -970,6 +1117,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
970
1117
  })
971
1118
  });
972
1119
  break;
1120
+
973
1121
  case 'polyline':
974
1122
  type = 'LineString';
975
1123
  style = new ol.style.Style({
@@ -980,6 +1128,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
980
1128
  })
981
1129
  });
982
1130
  break;
1131
+
983
1132
  case 'polygon':
984
1133
  type = 'Polygon';
985
1134
  style = new ol.style.Style({
@@ -993,10 +1142,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
993
1142
  })
994
1143
  });
995
1144
  break;
1145
+
996
1146
  case 'rectangle':
997
1147
  type = 'Circle';
998
1148
  geometryFunction = ol.interaction.Draw.createBox();
999
1149
  break;
1150
+
1000
1151
  case 'circle':
1001
1152
  type = 'Circle';
1002
1153
  style = new ol.style.Style({
@@ -1011,33 +1162,38 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1011
1162
  });
1012
1163
  break;
1013
1164
  }
1165
+
1014
1166
  if (!t.drawToolbar) {
1015
1167
  t.drawToolbar = new ol.interaction.Draw({
1016
1168
  source: t.drawSource,
1017
1169
  type: type,
1018
- geometryFunction: geometryFunction
1019
- // style: style
1170
+ geometryFunction: geometryFunction // style: style
1171
+
1020
1172
  });
1021
1173
  gis.addInteraction(t.drawToolbar);
1022
1174
  } else {
1023
1175
  gis.addInteraction(t.drawToolbar);
1024
1176
  }
1177
+
1025
1178
  t.drawToolbar.on('drawend', function (e) {
1026
1179
  var _t$frameSelectProps$p;
1180
+
1027
1181
  // 关闭绘制事件
1028
- t.drawToolbar.finishDrawing();
1029
- // 移除
1182
+ t.drawToolbar.finishDrawing(); // 移除
1183
+
1030
1184
  gis.removeInteraction(t.drawToolbar);
1031
- var gc = e.feature.getGeometry();
1032
- //返回参数
1033
- var param = {};
1034
- // 绘制内部管理的图元
1185
+ var gc = e.feature.getGeometry(); //返回参数
1186
+
1187
+ var param = {}; // 绘制内部管理的图元
1188
+
1035
1189
  if (t.drawParam.geometryType == 'point') {
1036
1190
  var _gc$flatCoordinates = _slicedToArray(gc.flatCoordinates, 2),
1037
- lng = _gc$flatCoordinates[0],
1038
- lat = _gc$flatCoordinates[1];
1191
+ lng = _gc$flatCoordinates[0],
1192
+ lat = _gc$flatCoordinates[1];
1193
+
1039
1194
  gc.x = lng;
1040
1195
  gc.y = lat;
1196
+
1041
1197
  if (t.GM.isRepetition(t.drawParam.data.id)) {
1042
1198
  t.updatePoint([{
1043
1199
  id: t.drawParam.data.id,
@@ -1054,9 +1210,9 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1054
1210
  url: t.drawParam.parameter.url || require("../images/defaultMarker.png"),
1055
1211
  config: _objectSpread({}, t.drawParam.parameter)
1056
1212
  }], 'point');
1057
- }
1213
+ } //处理点返回参数
1214
+
1058
1215
 
1059
- //处理点返回参数
1060
1216
  param = {
1061
1217
  id: t.drawParam.data.id,
1062
1218
  attributes: {
@@ -1071,11 +1227,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1071
1227
  geometryType: 'point',
1072
1228
  mapLayer: t.GM.getGraphic(t.drawParam.data.id)
1073
1229
  };
1074
- }
1075
- //线
1230
+ } //线
1231
+
1232
+
1076
1233
  if (t.drawParam.geometryType == 'polyline') {
1077
1234
  var oddList = [],
1078
- evenList = [];
1235
+ evenList = [];
1079
1236
  gc.flatCoordinates.map(function (item, index) {
1080
1237
  // 判断下标奇偶数
1081
1238
  if (index % 2 === 0) {
@@ -1087,6 +1244,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1087
1244
  var path = oddList.map(function (item, index) {
1088
1245
  return [evenList[index], oddList[index]];
1089
1246
  });
1247
+
1090
1248
  if (t.GM.isRepetition(t.drawParam.data.id)) {
1091
1249
  t.updateLine([{
1092
1250
  id: t.drawParam.data.id,
@@ -1099,11 +1257,13 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1099
1257
  paths: path,
1100
1258
  config: _objectSpread({}, t.drawParam.parameter)
1101
1259
  }], 'polyline');
1102
- }
1103
- //处理线返回参数
1260
+ } //处理线返回参数
1261
+
1262
+
1104
1263
  var _t$dealData3 = t.dealData(path),
1105
- lnglatAry = _t$dealData3.lnglatAry,
1106
- _extent = _t$dealData3._extent;
1264
+ lnglatAry = _t$dealData3.lnglatAry,
1265
+ _extent = _t$dealData3._extent;
1266
+
1107
1267
  param = {
1108
1268
  lnglatAry: lnglatAry,
1109
1269
  id: t.drawParam.data.id,
@@ -1119,11 +1279,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1119
1279
  geometryType: 'polyline',
1120
1280
  mapLayer: t.GM.getGraphic(t.drawParam.data.id)
1121
1281
  };
1122
- }
1123
- //面
1282
+ } //面
1283
+
1284
+
1124
1285
  if (t.drawParam.geometryType == 'polygon') {
1125
1286
  var _oddList2 = [],
1126
- _evenList2 = [];
1287
+ _evenList2 = [];
1127
1288
  gc.flatCoordinates.map(function (item, index) {
1128
1289
  // 判断下标奇偶数
1129
1290
  if (index % 2 === 0) {
@@ -1132,9 +1293,11 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1132
1293
  _oddList2.push(item);
1133
1294
  }
1134
1295
  });
1296
+
1135
1297
  var _path2 = _oddList2.map(function (item, index) {
1136
1298
  return [_evenList2[index], _oddList2[index]];
1137
1299
  });
1300
+
1138
1301
  if (t.GM.isRepetition(t.drawParam.data.id)) {
1139
1302
  t.updatePolygon([{
1140
1303
  id: t.drawParam.data.id,
@@ -1147,11 +1310,13 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1147
1310
  rings: _path2,
1148
1311
  config: _objectSpread({}, t.drawParam.parameter)
1149
1312
  }], t.drawParam.geometryType);
1150
- }
1151
- //处理线返回参数
1313
+ } //处理线返回参数
1314
+
1315
+
1152
1316
  var _t$dealData4 = t.dealData(_path2),
1153
- _lnglatAry2 = _t$dealData4.lnglatAry,
1154
- _extent3 = _t$dealData4._extent;
1317
+ _lnglatAry2 = _t$dealData4.lnglatAry,
1318
+ _extent3 = _t$dealData4._extent;
1319
+
1155
1320
  param = {
1156
1321
  lnglatAry: _lnglatAry2,
1157
1322
  id: t.drawParam.data.id,
@@ -1169,8 +1334,10 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1169
1334
  mapLayer: t.GM.getGraphic(t.drawParam.data.id)
1170
1335
  };
1171
1336
  }
1337
+
1172
1338
  if (t.drawParam.geometryType == 'rectangle') {
1173
1339
  var _path3 = e.feature.getGeometry().getCoordinates()[0];
1340
+
1174
1341
  if (t.GM.isRepetition(t.drawParam.data.id)) {
1175
1342
  t.updatePolygon([{
1176
1343
  id: t.drawParam.data.id,
@@ -1183,11 +1350,13 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1183
1350
  rings: _path3,
1184
1351
  config: _objectSpread({}, t.drawParam.parameter)
1185
1352
  }], t.drawParam.geometryType);
1186
- }
1187
- //处理线返回参数
1353
+ } //处理线返回参数
1354
+
1355
+
1188
1356
  var _t$dealData5 = t.dealData(_path3),
1189
- _lnglatAry3 = _t$dealData5.lnglatAry,
1190
- _extent4 = _t$dealData5._extent;
1357
+ _lnglatAry3 = _t$dealData5.lnglatAry,
1358
+ _extent4 = _t$dealData5._extent;
1359
+
1191
1360
  param = {
1192
1361
  lnglatAry: _lnglatAry3,
1193
1362
  id: t.drawParam.data.id,
@@ -1205,12 +1374,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1205
1374
  mapLayer: t.GM.getGraphic(t.drawParam.data.id)
1206
1375
  };
1207
1376
  }
1377
+
1208
1378
  if (t.drawParam.geometryType == 'circle') {
1209
1379
  var center = e.feature.getGeometry().getCenter();
1210
1380
  var cur = e.feature.getProperties().geometry;
1211
1381
  var sketchCoords_ = [cur.flatCoordinates[0], cur.flatCoordinates[1]];
1212
1382
  var sketchCoords_2 = [cur.flatCoordinates[2], cur.flatCoordinates[3]];
1213
1383
  var radius = ol.sphere.getDistance(sketchCoords_, sketchCoords_2);
1384
+
1214
1385
  if (t.GM.isRepetition(t.drawParam.data.id)) {
1215
1386
  t.updateCircle([{
1216
1387
  id: t.drawParam.data.id,
@@ -1228,6 +1399,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1228
1399
  config: _objectSpread({}, t.drawParam.parameter)
1229
1400
  }], t.drawParam.geometryType);
1230
1401
  }
1402
+
1231
1403
  param = {
1232
1404
  area: Math.PI * Math.pow(radius, 2),
1233
1405
  attributes: {
@@ -1244,26 +1416,29 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1244
1416
  mapLayer: t.GM.getGraphic(t.drawParam.data.id)
1245
1417
  };
1246
1418
  }
1419
+
1247
1420
  if ('drawEnd' in t.props && typeof t.props.drawEnd == 'function') {
1248
1421
  t.props.drawEnd(param);
1249
1422
  }
1423
+
1250
1424
  if (((_t$frameSelectProps$p = t.frameSelectProps[param.attributes.id]) === null || _t$frameSelectProps$p === void 0 ? void 0 : _t$frameSelectProps$p.callback) instanceof Function) {
1251
1425
  t.frameSelectProps[param.attributes.id].callback(param);
1252
1426
  }
1253
- });
1254
- //保存绘制图元的id便于后期比对
1427
+ }); //保存绘制图元的id便于后期比对
1428
+
1255
1429
  t.state.drawIds[drawParam.geometryType].push(drawParam.data.id);
1256
- }
1257
- // 关闭绘制
1430
+ } // 关闭绘制
1431
+
1258
1432
  }, {
1259
1433
  key: "closeDraw",
1260
1434
  value: function closeDraw() {
1261
1435
  var t = this;
1262
1436
  var gis = t.state.gis;
1437
+
1263
1438
  if (t.drawToolbar) {
1264
1439
  // 关闭绘制事件
1265
- t.drawToolbar.finishDrawing();
1266
- // 移除
1440
+ t.drawToolbar.finishDrawing(); // 移除
1441
+
1267
1442
  gis.removeInteraction(t.drawToolbar);
1268
1443
  t.drawToolbar = null;
1269
1444
  t.drawInfo = {
@@ -1273,6 +1448,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1273
1448
  }
1274
1449
  }
1275
1450
  /*工具方法*/
1451
+
1276
1452
  }, {
1277
1453
  key: "vtxRangingTool",
1278
1454
  value: function vtxRangingTool() {
@@ -1324,8 +1500,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1324
1500
  t.createMeasureTooltip();
1325
1501
  t.createDeleteTooltip();
1326
1502
  t.state.gis.addLayer(t.rangingInfo.drawLayer);
1327
- t.state.gis.addInteraction(t.rangingInfo.draw);
1328
- // 开始监听绘制
1503
+ t.state.gis.addInteraction(t.rangingInfo.draw); // 开始监听绘制
1504
+
1329
1505
  t.rangingInfo.draw.on('drawstart', function (evt) {
1330
1506
  t.rangingInfo.feature = evt.feature;
1331
1507
  var tooltipCoord = evt.coordinate;
@@ -1344,29 +1520,32 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1344
1520
  t.rangingInfo.deleteToolTip.setPosition(tooltipCoord);
1345
1521
  t.rangingInfo.deleteToolTip.setOffset([20, 10]);
1346
1522
  });
1347
- });
1348
- // 双击绘制完成
1523
+ }); // 双击绘制完成
1524
+
1349
1525
  t.rangingInfo.draw.on('drawend', function () {
1350
1526
  t.rangingInfo.measureTooltipElement.className = 'ol-tooltip ol-tooltip-static';
1351
1527
  t.rangingInfo.measureTooltip.setOffset([0, -7]);
1352
1528
  t.rangingInfo.feature = null;
1353
- t.rangingInfo.measureTooltipElement = null;
1354
- // t.createMeasureTooltip();
1529
+ t.rangingInfo.measureTooltipElement = null; // t.createMeasureTooltip();
1530
+
1355
1531
  new ol.Observable.unByKey(t.rangingInfo.listener);
1356
1532
  t.state.gis.removeInteraction(t.rangingInfo.draw);
1533
+
1357
1534
  if ('mapRangingTool' in t.props) {
1358
1535
  t.props.mapRangingTool(obj);
1359
1536
  }
1360
1537
  });
1361
- }
1362
- // 绘图时创建提示
1538
+ } // 绘图时创建提示
1539
+
1363
1540
  }, {
1364
1541
  key: "createHelpTooltip",
1365
1542
  value: function createHelpTooltip() {
1366
1543
  var t = this;
1544
+
1367
1545
  if (t.rangingTool.helpTooltipElement) {
1368
1546
  t.rangingTool.helpTooltipElement.parentNode.removeChild(t.rangingTool.helpTooltipElement);
1369
1547
  }
1548
+
1370
1549
  t.rangingTool.helpTooltipElement = document.createElement('div');
1371
1550
  t.rangingTool.helpTooltipElement.className = 'ol-tooltip hidden';
1372
1551
  t.rangingTool.helpTooltip = new ol.Overlay({
@@ -1375,15 +1554,17 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1375
1554
  positioning: 'center-left'
1376
1555
  });
1377
1556
  t.state.gis.addOverlay(t.rangingTool.helpTooltip);
1378
- }
1379
- // 工具画图提示
1557
+ } // 工具画图提示
1558
+
1380
1559
  }, {
1381
1560
  key: "createMeasureTooltip",
1382
1561
  value: function createMeasureTooltip() {
1383
1562
  var t = this;
1563
+
1384
1564
  if (t.rangingInfo.measureTooltipElement) {
1385
1565
  t.rangingInfo.measureTooltipElement.parentNode.removeChild(t.rangingInfo.measureTooltipElement);
1386
1566
  }
1567
+
1387
1568
  t.rangingInfo.measureTooltipElement = document.createElement('div');
1388
1569
  t.rangingInfo.measureTooltipElement.className = 'ol-tooltip ol-tooltip-measure';
1389
1570
  t.rangingInfo.measureTooltip = new ol.Overlay({
@@ -1394,15 +1575,17 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1394
1575
  insertFirst: false
1395
1576
  });
1396
1577
  t.state.gis.addOverlay(t.rangingInfo.measureTooltip);
1397
- }
1398
- // 创建删除提示
1578
+ } // 创建删除提示
1579
+
1399
1580
  }, {
1400
1581
  key: "createDeleteTooltip",
1401
1582
  value: function createDeleteTooltip() {
1402
1583
  var t = this;
1584
+
1403
1585
  if (t.rangingInfo.deleteToolTipElement) {
1404
1586
  t.rangingInfo.deleteToolTipElement.parentNode.removeChild(t.rangingInfo.deleteToolTipElement);
1405
1587
  }
1588
+
1406
1589
  t.rangingInfo.deleteToolTipElement = document.createElement('div');
1407
1590
  t.rangingInfo.deleteToolTipElement.className = 'ol-tooltip-delete';
1408
1591
  t.rangingInfo.deleteToolTipElement.innerHTML = 'X';
@@ -1429,12 +1612,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1429
1612
  }, {
1430
1613
  key: "formatLength",
1431
1614
  value: function formatLength(line) {
1432
- var flatCoordinates = line.flatCoordinates;
1433
- // const length = new ol.sphere.getDistance([flatCoordinates[0], flatCoordinates[1]],[flatCoordinates[2], flatCoordinates[3]]);
1615
+ var flatCoordinates = line.flatCoordinates; // const length = new ol.sphere.getDistance([flatCoordinates[0], flatCoordinates[1]],[flatCoordinates[2], flatCoordinates[3]]);
1616
+
1434
1617
  var paths = [];
1618
+
1435
1619
  for (var n = 0; n < flatCoordinates.length; n += 2) {
1436
1620
  paths.push([flatCoordinates[n], flatCoordinates[n + 1]]);
1437
1621
  }
1622
+
1438
1623
  var length = 0;
1439
1624
  if (paths.length >= 2) paths.map(function (item, index) {
1440
1625
  if (index <= paths.length - 2) {
@@ -1442,21 +1627,23 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1442
1627
  }
1443
1628
  });
1444
1629
  var output = '';
1630
+
1445
1631
  if (length > 100) {
1446
1632
  output = Math.round(length / 1000 * 100) / 100 + ' ' + 'km';
1447
1633
  } else {
1448
1634
  output = Math.round(length * 100) / 100 + ' ' + 'm';
1449
1635
  }
1636
+
1450
1637
  return output;
1451
1638
  }
1452
1639
  }, {
1453
1640
  key: "getMapExtent",
1454
- value:
1455
- // 获取地图的当前位置状态信息
1641
+ value: // 获取地图的当前位置状态信息
1456
1642
  function getMapExtent() {
1457
1643
  var t = this;
1458
1644
  var gis = t.state.gis;
1459
1645
  var obj = {};
1646
+
1460
1647
  if (gis) {
1461
1648
  var nowBounds = gis.getView().calculateExtent(gis.getSize());
1462
1649
  obj.southWest = {
@@ -1469,10 +1656,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1469
1656
  };
1470
1657
  obj.nowCenter = t.getCenter();
1471
1658
  obj.zoom = t.getZoomLevel();
1659
+
1472
1660
  var _gis$getSize = gis.getSize(),
1473
- _gis$getSize2 = _slicedToArray(_gis$getSize, 2),
1474
- width = _gis$getSize2[0],
1475
- height = _gis$getSize2[1];
1661
+ _gis$getSize2 = _slicedToArray(_gis$getSize, 2),
1662
+ width = _gis$getSize2[0],
1663
+ height = _gis$getSize2[1];
1664
+
1476
1665
  obj.mapSize = {
1477
1666
  width: width,
1478
1667
  height: height
@@ -1480,13 +1669,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1480
1669
  obj.radius = ol.sphere.getDistance([obj.nowCenter.lng, obj.nowCenter.lat], [obj.northEast.lng, obj.northEast.lat]);
1481
1670
  return obj;
1482
1671
  }
1483
- }
1484
- //将制定图元展示在视野内 (强制改变地图中心位置)
1672
+ } //将制定图元展示在视野内 (强制改变地图中心位置)
1673
+
1485
1674
  /*
1486
1675
  参数arg格式如下1,2
1487
1676
  1.string 格式如:'1,a,2,3,4'
1488
1677
  2.数组 ['1','2']
1489
1678
  */
1679
+
1490
1680
  }, {
1491
1681
  key: "setVisiblePoints",
1492
1682
  value: function setVisiblePoints(mapVisiblePoints) {
@@ -1495,50 +1685,64 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1495
1685
  var arg = null;
1496
1686
  var type = mapVisiblePoints.type;
1497
1687
  var ary = []; //图元id集合
1688
+
1498
1689
  var obj = []; //经纬度集合
1690
+
1499
1691
  switch (mapVisiblePoints.fitView) {
1500
1692
  case 'point':
1501
1693
  arg = this.state.pointIds;
1502
1694
  break;
1695
+
1503
1696
  case 'line':
1504
1697
  arg = this.state.lineIds;
1505
1698
  break;
1699
+
1506
1700
  case 'polygon':
1507
1701
  arg = this.state.polygonIds;
1508
1702
  break;
1703
+
1509
1704
  case 'circle':
1510
1705
  arg = this.state.circleIds;
1511
1706
  break;
1707
+
1512
1708
  case 'all':
1513
1709
  arg = this.state.pointIds.concat(this.state.lineIds).concat(this.state.polygonIds).concat(this.state.circleIds);
1514
1710
  break;
1711
+
1515
1712
  default:
1516
1713
  arg = mapVisiblePoints.fitView;
1517
1714
  break;
1518
1715
  }
1716
+
1519
1717
  if (typeof arg === 'string') {
1520
1718
  ary = arg.split(',');
1521
1719
  } else if (arg instanceof Array) {
1522
1720
  ary = arg;
1523
1721
  }
1722
+
1524
1723
  for (var i = 0; i < ary.length; i++) {
1525
1724
  var g = t.GM.getGraphicParam(ary[i]);
1725
+
1526
1726
  if (g) {
1527
1727
  switch (g.geometry.type) {
1528
1728
  case 'point':
1529
1729
  obj.push([g.geometry.x, g.geometry.y]);
1730
+
1530
1731
  case 'circle':
1531
1732
  obj.push([g.geometry.x, g.geometry.y]);
1532
1733
  break;
1734
+
1533
1735
  case 'polyline':
1534
1736
  obj = [].concat(_toConsumableArray(obj), _toConsumableArray(g.geometry.paths));
1535
1737
  break;
1738
+
1536
1739
  case 'polygon':
1537
1740
  obj = [].concat(_toConsumableArray(obj), _toConsumableArray(g.geometry.rings));
1538
1741
  break;
1539
1742
  }
1540
1743
  }
1541
1744
  }
1745
+
1542
1746
  if (obj.length > 0) {
1543
1747
  var displayRange = new ol.extent.boundingExtent(obj);
1544
1748
  gis.getView().fit(displayRange, gis.getSize());
@@ -1548,14 +1752,17 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1548
1752
  key: "getFitView",
1549
1753
  value: function getFitView(ids) {
1550
1754
  var t = this;
1755
+
1551
1756
  if (ids.length > 0) {
1552
1757
  var maxX = null,
1553
- maxY = null,
1554
- minX = null,
1555
- minY = null;
1758
+ maxY = null,
1759
+ minX = null,
1760
+ minY = null;
1761
+
1556
1762
  for (var i = 0; i < ids.length; i++) {
1557
1763
  var coord = t.GM.getGraphic(ids[i]);
1558
1764
  var boundsArry = coord.getGeometry().getExtent();
1765
+
1559
1766
  if (minX === null) {
1560
1767
  minX = boundsArry[0];
1561
1768
  minY = boundsArry[1];
@@ -1568,12 +1775,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1568
1775
  maxY = Math.max(boundsArry[3], maxY);
1569
1776
  }
1570
1777
  }
1778
+
1571
1779
  var bounds = [minX, minY, maxX, maxY];
1572
1780
  return bounds;
1573
1781
  }
1574
1782
  }
1575
1783
  /*功能方法*/
1576
1784
  //获取当前地图的中心位置
1785
+
1577
1786
  }, {
1578
1787
  key: "getCurrentCenter",
1579
1788
  value: function getCurrentCenter() {
@@ -1581,31 +1790,36 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1581
1790
  var gis = t.state.gis;
1582
1791
  var extent = gis.getView().calculateExtent(gis.getSize());
1583
1792
  return [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];
1584
- }
1585
- //获取当前比例尺
1793
+ } //获取当前比例尺
1794
+
1586
1795
  }, {
1587
1796
  key: "getZoomLevel",
1588
1797
  value: function getZoomLevel() {
1589
1798
  var t = this;
1590
1799
  return t.state.gis.getView().getZoom();
1591
- }
1592
- //获取图元数据
1800
+ } //获取图元数据
1801
+
1593
1802
  }, {
1594
1803
  key: "getGraphic",
1595
1804
  value: function getGraphic(id) {
1596
1805
  var t = this;
1806
+
1597
1807
  if (!id) {
1598
1808
  return false;
1599
1809
  }
1810
+
1600
1811
  var gp = t.GM.getGraphicParam(id);
1601
1812
  var gg = t.GM.getGraphic(id);
1813
+
1602
1814
  if (!gg) {
1603
1815
  return false;
1604
1816
  }
1817
+
1605
1818
  var p = {},
1606
- pts = [],
1607
- lng = 0,
1608
- lat = 0;
1819
+ pts = [],
1820
+ lng = 0,
1821
+ lat = 0;
1822
+
1609
1823
  switch (gp.geometryType) {
1610
1824
  case 'point':
1611
1825
  lng = gp.geometry.x;
@@ -1626,6 +1840,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1626
1840
  })
1627
1841
  });
1628
1842
  break;
1843
+
1629
1844
  case 'polyline':
1630
1845
  pts = gp.geometry.paths;
1631
1846
  p = _objectSpread(_objectSpread({}, gp), {}, {
@@ -1641,6 +1856,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1641
1856
  })
1642
1857
  });
1643
1858
  break;
1859
+
1644
1860
  case 'polygon':
1645
1861
  pts = gp.geometry.rings;
1646
1862
  p = _objectSpread(_objectSpread({}, gp), {}, {
@@ -1657,6 +1873,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1657
1873
  area: (0, _MapToolFunction.getPolygonArea)(pts)
1658
1874
  });
1659
1875
  break;
1876
+
1660
1877
  case 'circle':
1661
1878
  lng = gp.geometry.x;
1662
1879
  lat = gp.geometry.y;
@@ -1681,17 +1898,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1681
1898
  });
1682
1899
  break;
1683
1900
  }
1901
+
1684
1902
  return p;
1685
- }
1686
- // 转换dom节点
1903
+ } // 转换dom节点
1904
+
1687
1905
  }, {
1688
1906
  key: "parseDom",
1689
1907
  value: function parseDom(domStr) {
1690
1908
  var domObj = document.createElement('div');
1691
1909
  domObj.innerHTML = domStr;
1692
1910
  return domObj.childNodes;
1693
- }
1694
- //添加海量点
1911
+ } //添加海量点
1912
+
1695
1913
  }, {
1696
1914
  key: "addPointCollection",
1697
1915
  value: function addPointCollection() {
@@ -1703,10 +1921,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1703
1921
  var p = t.state.gis.getPixelFromCoordinate([d.lng, d.lat]);
1704
1922
  return [p[0], p[1]];
1705
1923
  });
1924
+
1706
1925
  var _t$state$gis$getSize = t.state.gis.getSize(),
1707
- _t$state$gis$getSize2 = _slicedToArray(_t$state$gis$getSize, 2),
1708
- width = _t$state$gis$getSize2[0],
1709
- height = _t$state$gis$getSize2[1];
1926
+ _t$state$gis$getSize2 = _slicedToArray(_t$state$gis$getSize, 2),
1927
+ width = _t$state$gis$getSize2[0],
1928
+ height = _t$state$gis$getSize2[1];
1929
+
1710
1930
  var options = {
1711
1931
  size: d.size,
1712
1932
  shape: d.shape,
@@ -1722,8 +1942,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1722
1942
  });
1723
1943
  VotexpointCollection.draw();
1724
1944
  });
1725
- }
1726
- //更新海量点
1945
+ } //更新海量点
1946
+
1727
1947
  }, {
1728
1948
  key: "updatePointCollection",
1729
1949
  value: function updatePointCollection() {
@@ -1736,10 +1956,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1736
1956
  var p = t.state.gis.getPixelFromCoordinate([d.lng, d.lat]);
1737
1957
  return [p[0], p[1]];
1738
1958
  });
1959
+
1739
1960
  var _t$state$gis$getSize3 = t.state.gis.getSize(),
1740
- _t$state$gis$getSize4 = _slicedToArray(_t$state$gis$getSize3, 2),
1741
- width = _t$state$gis$getSize4[0],
1742
- height = _t$state$gis$getSize4[1];
1961
+ _t$state$gis$getSize4 = _slicedToArray(_t$state$gis$getSize3, 2),
1962
+ width = _t$state$gis$getSize4[0],
1963
+ height = _t$state$gis$getSize4[1];
1964
+
1743
1965
  var options = {
1744
1966
  size: ds.size,
1745
1967
  shape: ds.shape,
@@ -1751,8 +1973,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1751
1973
  }
1752
1974
  });
1753
1975
  });
1754
- }
1755
- //删除海量点
1976
+ } //删除海量点
1977
+
1756
1978
  }, {
1757
1979
  key: "clearPointCollection",
1758
1980
  value: function clearPointCollection() {
@@ -1765,9 +1987,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1765
1987
  }
1766
1988
  });
1767
1989
  });
1768
- }
1990
+ } //删除全部海量点
1769
1991
 
1770
- //删除全部海量点
1771
1992
  }, {
1772
1993
  key: "clearAllPointCollection",
1773
1994
  value: function clearAllPointCollection() {
@@ -1775,24 +1996,26 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1775
1996
  t.morepoints.map(function (item, index) {
1776
1997
  item.value.clear();
1777
1998
  });
1778
- }
1779
- // 框选
1999
+ } // 框选
2000
+
1780
2001
  }, {
1781
2002
  key: "frameSelect",
1782
2003
  value: function frameSelect(_ref, callback) {
1783
2004
  var geometryType = _ref.geometryType,
1784
- _ref$parameter = _ref.parameter,
1785
- parameter = _ref$parameter === void 0 ? {} : _ref$parameter,
1786
- _ref$data = _ref.data,
1787
- data = _ref$data === void 0 ? {} : _ref$data;
2005
+ _ref$parameter = _ref.parameter,
2006
+ parameter = _ref$parameter === void 0 ? {} : _ref$parameter,
2007
+ _ref$data = _ref.data,
2008
+ data = _ref$data === void 0 ? {} : _ref$data;
2009
+
1788
2010
  if (!['polygon', 'circle', 'rectangle'].includes(geometryType)) {
1789
2011
  message.warn("传入的类型不支持框选!");
1790
2012
  return false;
1791
2013
  }
2014
+
1792
2015
  var t = this;
1793
2016
  var params = {},
1794
- type = geometryType || 'polygon',
1795
- id = data.id || "frameSelectFeature_".concat(Math.random());
2017
+ type = geometryType || 'polygon',
2018
+ id = data.id || "frameSelectFeature_".concat(Math.random());
1796
2019
  params.color = parameter.color || '#FF0000';
1797
2020
  params.lineColor = parameter.lineColor || '#FF0000';
1798
2021
  params.lineOpacity = parameter.lineOpacity || 1;
@@ -1811,17 +2034,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1811
2034
  id: id,
1812
2035
  type: geometryType
1813
2036
  };
1814
- }
1815
- // 清除框选
2037
+ } // 清除框选
2038
+
1816
2039
  }, {
1817
2040
  key: "clearFrameSelect",
1818
2041
  value: function clearFrameSelect() {
1819
2042
  for (var key in this.frameSelectProps) {
1820
2043
  this.removeGraphic(this.frameSelectProps[key].id, this.frameSelectProps[key].type);
1821
2044
  }
2045
+
1822
2046
  this.frameSelectProps = {};
1823
- }
1824
- // 清除框选ById
2047
+ } // 清除框选ById
2048
+
1825
2049
  }, {
1826
2050
  key: "clearFrameSelectById",
1827
2051
  value: function clearFrameSelectById(id) {
@@ -1836,14 +2060,17 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1836
2060
  * @content: String|HTML
1837
2061
  * @close: boolean
1838
2062
  */
2063
+
1839
2064
  }, {
1840
2065
  key: "showInfoWindow",
1841
2066
  value: function showInfoWindow() {
1842
2067
  var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1843
2068
  var t = this;
2069
+
1844
2070
  if (t.popupWindow) {
1845
2071
  t.hideInfoWindow();
1846
2072
  }
2073
+
1847
2074
  t.popupWindow = new Popup({
1848
2075
  map: t.state.gis,
1849
2076
  position: params.position,
@@ -1856,31 +2083,38 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1856
2083
  key: "hideInfoWindow",
1857
2084
  value: function hideInfoWindow() {
1858
2085
  var t = this;
2086
+
1859
2087
  if (t.popupWindow) {
1860
2088
  t.popupWindow.removePopup();
1861
2089
  }
2090
+
1862
2091
  t.popupWindow = null;
1863
- }
1864
- // 添加点
2092
+ } // 添加点
2093
+
1865
2094
  }, {
1866
2095
  key: "addPoint",
1867
2096
  value: function addPoint(mapPoints, type) {
1868
2097
  var _this2 = this;
2098
+
1869
2099
  var t = this;
1870
2100
  var ps = [];
2101
+
1871
2102
  var psids = _toConsumableArray(t.state.pointIds);
2103
+
1872
2104
  mapPoints.map(function (item, index) {
1873
2105
  //如果id重复,直接跳过不执行.
1874
2106
  if (_this2.GM.isRepetition(item.id)) {
1875
2107
  console.warn("\u52A0\u70B9id: ".concat(item.id, " \u91CD\u590D"));
1876
2108
  return false;
1877
- }
1878
- //点位数据不符合,直接跳过
2109
+ } //点位数据不符合,直接跳过
2110
+
2111
+
1879
2112
  if (!item.longitude || !item.latitude) {
1880
2113
  console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
1881
2114
  return false;
1882
- }
1883
- // 创建点位图元要素
2115
+ } // 创建点位图元要素
2116
+
2117
+
1884
2118
  var feature = new ol.Feature({
1885
2119
  geometry: new ol.geom.Point([parseFloat(item.longitude), parseFloat(item.latitude)]),
1886
2120
  name: item.name,
@@ -1898,23 +2132,25 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1898
2132
  zIndex: 100,
1899
2133
  deg: 0,
1900
2134
  scale: 1
1901
- };
1902
- //初始化默认数据
2135
+ }; //初始化默认数据
2136
+
1903
2137
  if (item.config) {
1904
2138
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1905
- }
1906
- // 覆盖物样式参数
2139
+ } // 覆盖物样式参数
2140
+
2141
+
1907
2142
  var style, icon, txt;
1908
2143
  var myImage = new Image(cg.width, cg.height);
2144
+
1909
2145
  if (!!item.markerContent) {
1910
- var nodes = t.parseDom(item.markerContent)[0];
1911
- // 自定义图层需要把事件加在dom上
2146
+ var nodes = t.parseDom(item.markerContent)[0]; // 自定义图层需要把事件加在dom上
2147
+
1912
2148
  nodes.addEventListener("click", function (e) {
1913
2149
  t.clickGraphic(item.id, _objectSpread(_objectSpread({}, e), {}, {
1914
2150
  pixel: [e.clientX, e.clientY]
1915
2151
  }));
1916
- });
1917
- // 创建地图自定义覆盖物
2152
+ }); // 创建地图自定义覆盖物
2153
+
1918
2154
  var pop = new ol.Overlay({
1919
2155
  id: item.id,
1920
2156
  position: [parseFloat(item.longitude), parseFloat(item.latitude)],
@@ -1933,8 +2169,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1933
2169
  height: cg.height
1934
2170
  }, function (base64) {
1935
2171
  myImage.src = base64;
1936
- });
1937
- // 创建地图要素图标样式
2172
+ }); // 创建地图要素图标样式
2173
+
1938
2174
  style = new ol.style.Style({
1939
2175
  image: new ol.style.Icon({
1940
2176
  anchor: [-cg.markerContentX, -cg.markerContentY],
@@ -1947,6 +2183,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1947
2183
  })
1948
2184
  });
1949
2185
  }
2186
+
1950
2187
  if (!!item.canShowLabel && item.canShowLabel) {
1951
2188
  var textStyle = _objectSpread({
1952
2189
  textAlign: 'center',
@@ -1971,17 +2208,20 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1971
2208
  }),
1972
2209
  padding: [2, 5, 2, 5]
1973
2210
  }, cg.labelStyle || {});
2211
+
1974
2212
  if (cg.labelStyle && cg.labelStyle.fill) {
1975
2213
  textStyle['fill'] = new ol.style.Fill({
1976
2214
  color: cg.labelStyle.fill
1977
2215
  });
1978
2216
  }
2217
+
1979
2218
  if (cg.labelStyle && cg.labelStyle.backgroundFill) {
1980
2219
  textStyle['backgroundFill'] = new ol.style.Fill({
1981
2220
  color: cg.labelStyle.backgroundFill
1982
2221
  });
1983
- }
1984
- // 创建地图要素图标样式
2222
+ } // 创建地图要素图标样式
2223
+
2224
+
1985
2225
  style = new ol.style.Style({
1986
2226
  image: new ol.style.Icon({
1987
2227
  anchor: [-cg.markerContentX, -cg.markerContentY],
@@ -1997,8 +2237,9 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
1997
2237
  text: new ol.style.Text(textStyle)
1998
2238
  });
1999
2239
  }
2000
- feature.setStyle(style);
2001
- // 初始化适量数据源
2240
+
2241
+ feature.setStyle(style); // 初始化适量数据源
2242
+
2002
2243
  var source = new ol.source.Vector({
2003
2244
  features: [feature],
2004
2245
  name: 'point',
@@ -2012,16 +2253,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2012
2253
  t.pointLayers.push({
2013
2254
  id: item.id,
2014
2255
  layer: pointLayer
2015
- });
2016
- //添加点位图层
2256
+ }); //添加点位图层
2257
+
2017
2258
  t.state.gis.addLayer(pointLayer);
2259
+
2018
2260
  if (!item.markerContent && cg.BAnimationType == 0) {
2019
2261
  marker.setAnimation(BMAP_ANIMATION_BOUNCE);
2020
2262
  } else if (!item.markerContent && cg.BAnimationType == 1) {
2021
2263
  marker.setAnimation(BMAP_ANIMATION_DROP);
2022
2264
  }
2023
- psids.push(item.id);
2024
- //缓存图元的数据,偏于后期操作
2265
+
2266
+ psids.push(item.id); //缓存图元的数据,偏于后期操作
2267
+
2025
2268
  _this2.GM.setGraphic(item.id, feature).setGraphicParam(item.id, {
2026
2269
  attributes: _objectSpread(_objectSpread({}, item), {}, {
2027
2270
  other: item
@@ -2035,28 +2278,32 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2035
2278
  source: source
2036
2279
  });
2037
2280
  });
2281
+
2038
2282
  if (type !== 'defined') {
2039
2283
  // t.state.pointIds = psids;
2040
2284
  t.setState({
2041
2285
  pointIds: psids
2042
2286
  });
2043
2287
  }
2044
- }
2045
- //更新点
2288
+ } //更新点
2289
+
2046
2290
  }, {
2047
2291
  key: "updatePoint",
2048
2292
  value: function updatePoint() {
2049
2293
  var _this3 = this;
2294
+
2050
2295
  var mapPoints = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2051
2296
  var t = this;
2052
- mapPoints.map(function (item, index) {
2053
- //判断图元是否存在.
2297
+ var index = 0;
2298
+
2299
+ var dealPoint = function dealPoint(item) {
2054
2300
  if (_this3.GM.isRepetition(item.id)) {
2055
2301
  //点位数据不符合,直接跳过
2056
2302
  if (!item.longitude || !item.latitude) {
2057
2303
  console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
2058
2304
  return false;
2059
2305
  }
2306
+
2060
2307
  var gc = t.GM.getGraphic(item.id);
2061
2308
  var gp = t.GM.getGraphicParam(item.id);
2062
2309
  var cg = {
@@ -2071,11 +2318,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2071
2318
  markerContentY: -30,
2072
2319
  deg: 0
2073
2320
  };
2321
+
2074
2322
  if (item.config) {
2075
2323
  cg = _objectSpread(_objectSpread({}, cg), item.config);
2076
2324
  }
2325
+
2077
2326
  var text, icon, _marker;
2327
+
2078
2328
  var myImage = new Image(cg.width, cg.height);
2329
+
2079
2330
  if (item.markerContent) {
2080
2331
  var overlay = t.state.gis.getOverlayById(item.id);
2081
2332
  var nodes = t.parseDom(item.markerContent)[0];
@@ -2105,6 +2356,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2105
2356
  scale: cg.scale || 1,
2106
2357
  rotation: Math.PI / 180 * cg.deg
2107
2358
  });
2359
+
2108
2360
  if (item.canShowLabel) {
2109
2361
  var textStyle = _objectSpread({
2110
2362
  textAlign: 'center',
@@ -2129,18 +2381,22 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2129
2381
  }),
2130
2382
  padding: [2, 5, 2, 5]
2131
2383
  }, cg.labelStyle || {});
2384
+
2132
2385
  if (cg.labelStyle && cg.labelStyle.fill) {
2133
2386
  textStyle['fill'] = new ol.style.Fill({
2134
2387
  color: cg.labelStyle.fill
2135
2388
  });
2136
2389
  }
2390
+
2137
2391
  if (cg.labelStyle && cg.labelStyle.backgroundFill) {
2138
2392
  textStyle['backgroundFill'] = new ol.style.Fill({
2139
2393
  color: cg.labelStyle.backgroundFill
2140
2394
  });
2141
2395
  }
2396
+
2142
2397
  text = new ol.style.Text(textStyle);
2143
2398
  }
2399
+
2144
2400
  if (text) {
2145
2401
  gc.setStyle(new ol.style.Style({
2146
2402
  image: icon,
@@ -2152,7 +2408,9 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2152
2408
  }));
2153
2409
  }
2154
2410
  }
2411
+
2155
2412
  gc.setGeometry(new ol.geom.Point([parseFloat(item.longitude), parseFloat(item.latitude)]));
2413
+
2156
2414
  _this3.GM.setGraphicParam(item.id, {
2157
2415
  attributes: _objectSpread(_objectSpread({}, item), {}, {
2158
2416
  other: item
@@ -2169,10 +2427,23 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2169
2427
  console.warn("\u66F4\u65B0\u7684\u70B9\u4F4Did\u4E0D\u5B58\u5728!");
2170
2428
  return false;
2171
2429
  }
2172
- });
2173
- t.refresh();
2174
- }
2175
- // 更新图层
2430
+
2431
+ if (index < mapPoints.length - 1) {
2432
+ requestIdleCallback(function () {
2433
+ return dealPoint(mapPoints[++index]);
2434
+ });
2435
+ } else {
2436
+ t.refresh();
2437
+ }
2438
+ };
2439
+
2440
+ if (!(0, _lodash.isEmpty)(mapPoints)) {
2441
+ requestIdleCallback(function () {
2442
+ return dealPoint(mapPoints[index]);
2443
+ });
2444
+ }
2445
+ } // 更新图层
2446
+
2176
2447
  }, {
2177
2448
  key: "refresh",
2178
2449
  value: function refresh() {
@@ -2181,27 +2452,32 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2181
2452
  clearTimeout(timer);
2182
2453
  window.VtxMap[t.props.mapId].redrawText();
2183
2454
  }, 100);
2184
- }
2185
- // 添加先
2455
+ } // 添加先
2456
+
2186
2457
  }, {
2187
2458
  key: "addLine",
2188
2459
  value: function addLine(mapLines, type) {
2189
2460
  var _this4 = this;
2461
+
2190
2462
  var t = this;
2191
2463
  var ls = [];
2192
- var lsids = _toConsumableArray(t.state.lineIds);
2193
- //遍历添加线(图元)
2464
+
2465
+ var lsids = _toConsumableArray(t.state.lineIds); //遍历添加线(图元)
2466
+
2467
+
2194
2468
  mapLines.map(function (item, index) {
2195
2469
  //如果id重复,直接跳过不执行.
2196
2470
  if (_this4.GM.isRepetition(item.id)) {
2197
2471
  console.warn("\u591A\u6298\u7EBFid: ".concat(item.id, " \u91CD\u590D"));
2198
2472
  return false;
2199
- }
2200
- //多折线点位数据不符合,直接跳过
2473
+ } //多折线点位数据不符合,直接跳过
2474
+
2475
+
2201
2476
  if (!(item.paths && item.paths.length >= 2)) {
2202
2477
  console.warn("\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF");
2203
2478
  return false;
2204
2479
  }
2480
+
2205
2481
  var cg = {
2206
2482
  color: '#277ffa',
2207
2483
  pellucidity: 0.9,
@@ -2209,9 +2485,11 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2209
2485
  lineType: 'solid',
2210
2486
  isHidden: false
2211
2487
  };
2488
+
2212
2489
  if (item.config) {
2213
2490
  cg = _objectSpread(_objectSpread({}, cg), item.config);
2214
2491
  }
2492
+
2215
2493
  var style = new ol.style.Style({
2216
2494
  stroke: new ol.style.Stroke({
2217
2495
  color: cg.color,
@@ -2235,11 +2513,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2235
2513
  id: item.id,
2236
2514
  source: source
2237
2515
  });
2238
- t.state.gis.addLayer(lineLayer);
2239
- //缓存图元的数据,便于后期操作
2516
+ t.state.gis.addLayer(lineLayer); //缓存图元的数据,便于后期操作
2517
+
2240
2518
  var pts = item.paths.map(function (itt, ind) {
2241
2519
  return _toConsumableArray(itt);
2242
2520
  });
2521
+
2243
2522
  _this4.GM.setGraphic(item.id, polyline).setGraphicParam(item.id, {
2244
2523
  attributes: _objectSpread(_objectSpread({}, item), {}, {
2245
2524
  paths: pts,
@@ -2252,21 +2531,24 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2252
2531
  },
2253
2532
  source: source
2254
2533
  });
2534
+
2255
2535
  ls.push(polyline);
2256
2536
  lsids.push(item.id);
2257
2537
  t.state.lineIds.push(item.id);
2258
2538
  });
2539
+
2259
2540
  if (type !== 'defined') {
2260
2541
  t.state.lineIds = lsids;
2261
2542
  }
2262
- }
2263
- //更新线
2543
+ } //更新线
2544
+
2264
2545
  }, {
2265
2546
  key: "updateLine",
2266
2547
  value: function updateLine(mapLines) {
2267
2548
  var _this5 = this;
2268
- var t = this;
2269
- //遍历添加线(图元)
2549
+
2550
+ var t = this; //遍历添加线(图元)
2551
+
2270
2552
  mapLines.map(function (item, index) {
2271
2553
  //判断图元是否存在.
2272
2554
  if (_this5.GM.isRepetition(item.id)) {
@@ -2274,8 +2556,9 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2274
2556
  if (!(item.paths && item.paths.length >= 2)) {
2275
2557
  console.warn("\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF");
2276
2558
  return false;
2277
- }
2278
- //初始化默认参数
2559
+ } //初始化默认参数
2560
+
2561
+
2279
2562
  var cg = {
2280
2563
  color: '#277ffa',
2281
2564
  pellucidity: 0.9,
@@ -2283,14 +2566,17 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2283
2566
  lineType: 'solid',
2284
2567
  //'solid' 'dashed'
2285
2568
  isHidden: false
2286
- };
2287
- //获取原有的图元
2569
+ }; //获取原有的图元
2570
+
2288
2571
  var gc = _this5.GM.getGraphic(item.id);
2289
- var gp = _this5.GM.getGraphicParam(item.id);
2290
- //重新初始化值
2572
+
2573
+ var gp = _this5.GM.getGraphicParam(item.id); //重新初始化值
2574
+
2575
+
2291
2576
  if (item.config) {
2292
2577
  cg = _objectSpread(_objectSpread({}, cg), item.config);
2293
2578
  }
2579
+
2294
2580
  var pts = item.paths.map(function (itt, ind) {
2295
2581
  return _toConsumableArray(itt);
2296
2582
  });
@@ -2306,6 +2592,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2306
2592
  return style;
2307
2593
  });
2308
2594
  gc.setGeometry(new ol.geom.LineString(pts));
2595
+
2309
2596
  _this5.GM.setGraphicParam(item.id, {
2310
2597
  attributes: _objectSpread(_objectSpread({}, item), {}, {
2311
2598
  paths: pts,
@@ -2323,27 +2610,32 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2323
2610
  return false;
2324
2611
  }
2325
2612
  });
2326
- }
2327
- //添加面
2613
+ } //添加面
2614
+
2328
2615
  }, {
2329
2616
  key: "addPolygon",
2330
2617
  value: function addPolygon(mapPolygons) {
2331
2618
  var _this6 = this;
2619
+
2332
2620
  var t = this;
2333
2621
  var pgs = [];
2334
- var pgsids = _toConsumableArray(t.state.polygonIds);
2335
- //遍历添加面(图元)
2622
+
2623
+ var pgsids = _toConsumableArray(t.state.polygonIds); //遍历添加面(图元)
2624
+
2625
+
2336
2626
  mapPolygons.map(function (item, index) {
2337
2627
  //如果id重复,直接跳过不执行.
2338
2628
  if (_this6.GM.isRepetition(item.id)) {
2339
2629
  console.warn("\u591A\u8FB9\u5F62id: ".concat(item.id, " \u91CD\u590D"));
2340
2630
  return false;
2341
- }
2342
- //多边形点位数据不符合,直接跳过
2631
+ } //多边形点位数据不符合,直接跳过
2632
+
2633
+
2343
2634
  if (!(item.rings && item.rings.length >= 3)) {
2344
2635
  console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
2345
2636
  return false;
2346
2637
  }
2638
+
2347
2639
  var cg = {
2348
2640
  lineType: 'solid',
2349
2641
  lineWidth: 5,
@@ -2352,9 +2644,11 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2352
2644
  color: '#fff',
2353
2645
  pellucidity: 0.5
2354
2646
  };
2647
+
2355
2648
  if (item.config) {
2356
2649
  cg = _objectSpread(_objectSpread({}, cg), item.config);
2357
2650
  }
2651
+
2358
2652
  var style = new ol.style.Style({
2359
2653
  stroke: new ol.style.Stroke({
2360
2654
  color: cg.lineColor,
@@ -2381,11 +2675,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2381
2675
  id: item.id,
2382
2676
  source: source
2383
2677
  });
2384
- t.state.gis.addLayer(polygonLayer);
2385
- //缓存图元的数据,便于后期操作
2678
+ t.state.gis.addLayer(polygonLayer); //缓存图元的数据,便于后期操作
2679
+
2386
2680
  var pts = item.rings.map(function (itt, ind) {
2387
2681
  return _toConsumableArray(itt);
2388
2682
  });
2683
+
2389
2684
  _this6.GM.setGraphic(item.id, polygon).setGraphicParam(item.id, {
2390
2685
  attributes: _objectSpread(_objectSpread({}, item), {}, {
2391
2686
  rings: pts,
@@ -2398,16 +2693,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2398
2693
  },
2399
2694
  source: source
2400
2695
  });
2696
+
2401
2697
  pgs.push(polygon);
2402
2698
  pgsids.push(item.id);
2403
2699
  });
2404
2700
  t.state.polygonIds = pgsids;
2405
- }
2406
- //更新面
2701
+ } //更新面
2702
+
2407
2703
  }, {
2408
2704
  key: "updatePolygon",
2409
2705
  value: function updatePolygon(mapPolygons) {
2410
2706
  var _this7 = this;
2707
+
2411
2708
  var t = this;
2412
2709
  mapPolygons.map(function (item, index) {
2413
2710
  //判断图元是否存在.
@@ -2416,23 +2713,26 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2416
2713
  if (!(item.rings && item.rings.length >= 3)) {
2417
2714
  console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
2418
2715
  return false;
2419
- }
2420
- //获取原有的图元
2716
+ } //获取原有的图元
2717
+
2718
+
2421
2719
  var gc = _this7.GM.getGraphic(item.id);
2422
- var gp = t.GM.getGraphicParam(item.id);
2423
- //获取原有的面属性,转换key值
2424
- var cg = {
2720
+
2721
+ var gp = t.GM.getGraphicParam(item.id); //获取原有的面属性,转换key值
2722
+
2723
+ var cg = {
2425
2724
  lineType: 'solid',
2426
2725
  lineWidth: 5,
2427
2726
  lineColor: '#277ffa',
2428
2727
  lineOpacity: 1,
2429
2728
  color: '#fff',
2430
2729
  pellucidity: 0.5
2431
- };
2432
- //重新初始化值
2730
+ }; //重新初始化值
2731
+
2433
2732
  if (item.config) {
2434
2733
  cg = _objectSpread(_objectSpread({}, cg), item.config);
2435
2734
  }
2735
+
2436
2736
  var pts = item.rings.map(function (itt, ind) {
2437
2737
  return _toConsumableArray(itt);
2438
2738
  });
@@ -2447,6 +2747,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2447
2747
  color: cg.pellucidity ? getRgbColor(cg.color, cg.pellucidity) : cg.color
2448
2748
  })
2449
2749
  }));
2750
+
2450
2751
  _this7.GM.setGraphicParam(item.id, {
2451
2752
  attributes: _objectSpread(_objectSpread({}, item), {}, {
2452
2753
  rings: pts,
@@ -2464,39 +2765,46 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2464
2765
  return false;
2465
2766
  }
2466
2767
  });
2467
- }
2468
- //添加圆 circle
2768
+ } //添加圆 circle
2769
+
2469
2770
  }, {
2470
2771
  key: "addCircle",
2471
2772
  value: function addCircle(mapCircles, type) {
2472
2773
  var t = this;
2774
+
2473
2775
  var ccsids = _toConsumableArray(t.state.circleIds);
2776
+
2474
2777
  if (type) {
2475
2778
  ccsids = _toConsumableArray(t.state.drawIds[type]);
2476
2779
  }
2780
+
2477
2781
  mapCircles.map(function (item, index) {
2478
2782
  //如果id重复,直接跳过不执行.
2479
2783
  if (t.GM.isRepetition(item.id)) {
2480
2784
  console.warn("\u5706id: ".concat(item.id, " \u91CD\u590D"));
2481
2785
  return false;
2482
- }
2483
- //圆 点位数据不符合,直接跳过
2786
+ } //圆 点位数据不符合,直接跳过
2787
+
2788
+
2484
2789
  if (!item.longitude || !item.latitude) {
2485
2790
  console.warn("\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
2486
2791
  return false;
2487
2792
  }
2793
+
2488
2794
  var cg = {
2489
2795
  lineType: 'solid',
2490
2796
  lineWidth: 5,
2491
2797
  lineColor: '#277ffa',
2492
2798
  lineOpacity: 1,
2493
2799
  color: '#fff',
2494
- pellucidity: 0.5
2495
- // isHidden: false //后期需要在加
2800
+ pellucidity: 0.5 // isHidden: false //后期需要在加
2801
+
2496
2802
  };
2803
+
2497
2804
  if (item.config) {
2498
2805
  cg = _objectSpread(_objectSpread({}, cg), item.config);
2499
2806
  }
2807
+
2500
2808
  var style = new ol.style.Style({
2501
2809
  stroke: new ol.style.Stroke({
2502
2810
  color: cg.lineColor,
@@ -2541,15 +2849,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2541
2849
  },
2542
2850
  source: source
2543
2851
  });
2544
- });
2545
- //添加绘制点
2852
+ }); //添加绘制点
2853
+
2546
2854
  if (type) {
2547
2855
  t.state.drawIds = _objectSpread(_objectSpread({}, t.state.drawIds), {}, _defineProperty({}, type, ccsids));
2548
2856
  } else {
2549
2857
  t.state.circleIds = ccsids;
2550
2858
  }
2551
- }
2552
- //更新圆
2859
+ } //更新圆
2860
+
2553
2861
  }, {
2554
2862
  key: "updateCircle",
2555
2863
  value: function updateCircle(mapCircles) {
@@ -2565,23 +2873,26 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2565
2873
  } else {
2566
2874
  console.warn("\u66F4\u65B0\u7684\u5706id\u4E0D\u5B58\u5728!");
2567
2875
  return false;
2568
- }
2569
- //获取原有的图元
2876
+ } //获取原有的图元
2877
+
2878
+
2570
2879
  var gc = t.GM.getGraphic(item.id);
2571
- var gp = t.GM.getGraphicParam(item.id);
2572
- //获取原有的面属性,转换key值
2880
+ var gp = t.GM.getGraphicParam(item.id); //获取原有的面属性,转换key值
2881
+
2573
2882
  var cg = {
2574
2883
  lineType: 'solid',
2575
2884
  lineWidth: 5,
2576
2885
  lineColor: '#277ffa',
2577
2886
  lineOpacity: 1,
2578
2887
  color: '#fff',
2579
- pellucidity: 0.5
2580
- // isHidden: false //后期需要在加
2888
+ pellucidity: 0.5 // isHidden: false //后期需要在加
2889
+
2581
2890
  };
2891
+
2582
2892
  if (item.config) {
2583
2893
  cg = _objectSpread(_objectSpread({}, cg), item.config);
2584
2894
  }
2895
+
2585
2896
  var metersPerUnit = t.state.gis.getView().getProjection().getMetersPerUnit();
2586
2897
  var circleRadius = item.radius / metersPerUnit;
2587
2898
  gc.setGeometry(new ol.geom.Circle([item.longitude, item.latitude], parseFloat(circleRadius)));
@@ -2608,106 +2919,126 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2608
2919
  },
2609
2920
  source: gp.source
2610
2921
  });
2611
- });
2612
- //刷新图元
2613
- }
2614
- // 工具方法
2922
+ }); //刷新图元
2923
+ } // 工具方法
2615
2924
  //删除图元
2925
+
2616
2926
  }, {
2617
2927
  key: "removeGraphic",
2618
2928
  value: function removeGraphic(id, type) {
2619
2929
  var t = this;
2620
2930
  var graphic = t.GM.getGraphic(id);
2621
- var gp = t.GM.getGraphicParam(id);
2622
- //刪除label
2931
+ var gp = t.GM.getGraphicParam(id); //刪除label
2932
+
2623
2933
  if (t.Label[id]) {
2624
2934
  t.Label[id].html.remove();
2625
2935
  delete t.Label[id];
2626
2936
  }
2937
+
2627
2938
  if (!!graphic) {
2628
2939
  //清除聚合点 避免异常
2629
2940
  // t._cluster.removeMarker(this.GM.getGraphic(id));
2630
2941
  //清除地图中图元
2631
2942
  // const layers = t.state.gis.getLayers().getArray();
2632
2943
  // const layer = layers.filter(item => item.getProperties().name == type)[0];
2633
- gp.source.removeFeature(graphic);
2634
- // layer && layer.getSource().removeFeature(graphic);
2944
+ gp.source.removeFeature(graphic); // layer && layer.getSource().removeFeature(graphic);
2635
2945
  //清除对应id的图元数据缓存
2946
+
2636
2947
  t.GM.removeGraphic(id);
2637
2948
  t.GM.removeGraphicParam(id);
2949
+
2638
2950
  if (t.state.gis.getOverlayById(id)) {
2639
2951
  t.state.gis.removeOverlay(t.state.gis.getOverlayById(id));
2640
2952
  }
2641
2953
  } else {
2642
2954
  return false;
2643
2955
  }
2956
+
2644
2957
  for (var i = 0; i < t.movePoints.length; i++) {
2645
2958
  if (t.movePoints[i].id == id) {
2646
2959
  t.movePoints.splice(i, 1);
2647
2960
  continue;
2648
2961
  }
2649
2962
  }
2963
+
2650
2964
  var ids = [];
2965
+
2651
2966
  switch (type) {
2652
2967
  case 'point':
2653
2968
  ids = t.state.pointIds;
2654
2969
  break;
2970
+
2655
2971
  case 'line':
2656
2972
  ids = t.state.lineIds;
2657
2973
  break;
2974
+
2658
2975
  case 'polygon':
2659
2976
  ids = t.state.polygonIds;
2660
2977
  break;
2978
+
2661
2979
  case 'circle':
2662
2980
  ids = t.state.circleIds;
2663
2981
  break;
2982
+
2664
2983
  case 'draw':
2665
2984
  if (t.state.drawIds.point.indexOf(id) > -1) {
2666
2985
  t.state.drawIds.point.splice(t.state.drawIds.point.indexOf(id), 1);
2667
2986
  }
2987
+
2668
2988
  if (t.state.drawIds.polyline.indexOf(id) > -1) {
2669
2989
  t.state.drawIds.polyline.splice(t.state.drawIds.polyline.indexOf(id), 1);
2670
2990
  }
2991
+
2671
2992
  if (t.state.drawIds.polygon.indexOf(id) > -1) {
2672
2993
  t.state.drawIds.polygon.splice(t.state.drawIds.polygon.indexOf(id), 1);
2673
2994
  }
2995
+
2674
2996
  if (t.state.drawIds.circle.indexOf(id) > -1) {
2675
2997
  t.state.drawIds.circle.splice(t.state.drawIds.circle.indexOf(id), 1);
2676
2998
  }
2999
+
2677
3000
  if (t.state.drawIds.rectangle.indexOf(id) > -1) {
2678
3001
  t.state.drawIds.rectangle.splice(t.state.drawIds.rectangle.indexOf(id), 1);
2679
3002
  }
3003
+
2680
3004
  break;
3005
+
2681
3006
  default:
2682
3007
  if (t.state.pointIds.indexOf(id) > -1) {
2683
3008
  t.state.pointIds.splice(t.state.pointIds.indexOf(id), 1);
2684
3009
  }
3010
+
2685
3011
  if (t.state.lineIds.indexOf(id) > -1) {
2686
3012
  t.state.lineIds.splice(t.state.lineIds.indexOf(id), 1);
2687
3013
  }
3014
+
2688
3015
  if (t.state.polygonIds.indexOf(id) > -1) {
2689
3016
  t.state.polygonIds.splice(t.state.polygonIds.indexOf(id), 1);
2690
3017
  }
3018
+
2691
3019
  if (t.state.circleIds.indexOf(id) > -1) {
2692
3020
  t.state.circleIds.splice(t.state.circleIds.indexOf(id), 1);
2693
3021
  }
3022
+
2694
3023
  break;
2695
3024
  }
3025
+
2696
3026
  if (id == t.state.editId) {
2697
3027
  t.state.editId = '';
2698
3028
  }
3029
+
2699
3030
  if (ids.indexOf(id) != -1) {
2700
3031
  ids.splice(ids.indexOf(id), 1);
2701
3032
  }
2702
- }
2703
- //清空地图
3033
+ } //清空地图
3034
+
2704
3035
  }, {
2705
3036
  key: "clearAll",
2706
3037
  value: function clearAll() {
2707
3038
  var t = this;
2708
3039
  var gis = t.state.gis;
2709
- var layers = gis.getLayers();
2710
- //清空热力图
3040
+ var layers = gis.getLayers(); //清空热力图
3041
+
2711
3042
  if (t.heatmap) {
2712
3043
  var hMap = layers.filter(function (item) {
2713
3044
  return item.name == 'heatMap';
@@ -2715,6 +3046,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2715
3046
  hMap.getSource().clear();
2716
3047
  gis.removeLayer(layer);
2717
3048
  }
3049
+
2718
3050
  t.heatmap = null;
2719
3051
  t.movePoints = [];
2720
3052
  t.state.pointIds = [];
@@ -2724,6 +3056,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2724
3056
  });
2725
3057
  t.clearAllPointCollection();
2726
3058
  t.closeDraw();
3059
+
2727
3060
  if (t.clusterInfo.clusterHulls || t.clusterInfo.clusters || t.clusterInfo.clusterCircles) {
2728
3061
  t.clusterHulls.getSource().clear();
2729
3062
  t.clusterInfo.clusterSource = null;
@@ -2733,69 +3066,82 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2733
3066
  t.clusterInfo.clusterHulls = null;
2734
3067
  t.clusterInfo.clusters = null;
2735
3068
  t.clusterInfo.clusterCircles = null;
2736
- }
2737
- //清空缓存数据
2738
- t.GM.clearAll();
2739
- //循环所有id删除
3069
+ } //清空缓存数据
3070
+
3071
+
3072
+ t.GM.clearAll(); //循环所有id删除
3073
+
2740
3074
  var _t$state = t.state,
2741
- pointIds = _t$state.pointIds,
2742
- lineIds = _t$state.lineIds,
2743
- polygonIds = _t$state.polygonIds,
2744
- circleIds = _t$state.circleIds,
2745
- drawIds = _t$state.drawIds;
2746
- //拷贝数组,避免原数组操作,影响循环
3075
+ pointIds = _t$state.pointIds,
3076
+ lineIds = _t$state.lineIds,
3077
+ polygonIds = _t$state.polygonIds,
3078
+ circleIds = _t$state.circleIds,
3079
+ drawIds = _t$state.drawIds; //拷贝数组,避免原数组操作,影响循环
3080
+
2747
3081
  var ps = _toConsumableArray(pointIds),
2748
- ls = _toConsumableArray(lineIds),
2749
- pgs = _toConsumableArray(polygonIds),
2750
- cs = _toConsumableArray(circleIds);
2751
- // 删除点
3082
+ ls = _toConsumableArray(lineIds),
3083
+ pgs = _toConsumableArray(polygonIds),
3084
+ cs = _toConsumableArray(circleIds); // 删除点
3085
+
3086
+
2752
3087
  for (var i = 0; i < ps.length; i++) {
2753
3088
  t.removeGraphic(ps[i], 'point');
2754
- }
2755
- // 删除线
2756
- for (var _i = 0; _i < ls.length; _i++) {
2757
- t.removeGraphic(ls[_i], 'line');
2758
- }
2759
- // 删除面
2760
- for (var _i2 = 0; _i2 < pgs.length; _i2++) {
2761
- t.removeGraphic(pgs[_i2], 'polygon');
2762
- }
2763
- // 删除圆
2764
- for (var _i3 = 0; _i3 < cs.length; _i3++) {
2765
- t.removeGraphic(cs[_i3], 'circle');
2766
- }
2767
- //删除绘制的点
3089
+ } // 删除线
3090
+
3091
+
3092
+ for (var _i2 = 0; _i2 < ls.length; _i2++) {
3093
+ t.removeGraphic(ls[_i2], 'line');
3094
+ } // 删除面
3095
+
3096
+
3097
+ for (var _i3 = 0; _i3 < pgs.length; _i3++) {
3098
+ t.removeGraphic(pgs[_i3], 'polygon');
3099
+ } // 删除圆
3100
+
3101
+
3102
+ for (var _i4 = 0; _i4 < cs.length; _i4++) {
3103
+ t.removeGraphic(cs[_i4], 'circle');
3104
+ } //删除绘制的点
3105
+
3106
+
2768
3107
  var point = drawIds.point,
2769
- polyline = drawIds.polyline,
2770
- polygon = drawIds.polygon,
2771
- circle = drawIds.circle,
2772
- rectangle = drawIds.rectangle;
2773
- for (var _i4 = 0; _i4 < point.length; _i4++) {
2774
- t.removeGraphic(point[_i4]);
3108
+ polyline = drawIds.polyline,
3109
+ polygon = drawIds.polygon,
3110
+ circle = drawIds.circle,
3111
+ rectangle = drawIds.rectangle;
3112
+
3113
+ for (var i = 0; i < point.length; i++) {
3114
+ t.removeGraphic(point[i]);
2775
3115
  }
3116
+
2776
3117
  for (var _i5 = 0; _i5 < polyline.length; _i5++) {
2777
3118
  t.removeGraphic(polyline[_i5]);
2778
3119
  }
3120
+
2779
3121
  for (var _i6 = 0; _i6 < polygon.length; _i6++) {
2780
3122
  t.removeGraphic(polygon[_i6]);
2781
3123
  }
3124
+
2782
3125
  for (var _i7 = 0; _i7 < circle.length; _i7++) {
2783
3126
  t.removeGraphic(circle[_i7]);
2784
3127
  }
3128
+
2785
3129
  for (var _i8 = 0; _i8 < rectangle.length; _i8++) {
2786
3130
  t.removeGraphic(rectangle[_i8]);
2787
3131
  }
2788
- }
2789
- //展示比例尺
3132
+ } //展示比例尺
3133
+
2790
3134
  }, {
2791
3135
  key: "showControl",
2792
3136
  value: function showControl(props) {
2793
3137
  var t = this;
2794
3138
  var gis = t.state.gis;
2795
3139
  var config = props.showControl;
3140
+
2796
3141
  if (t.scaleControl) {
2797
3142
  gis.removeControl(t.scaleControl);
2798
3143
  }
3144
+
2799
3145
  t.scaleControl = new ol.control.ScaleLine({
2800
3146
  units: 'metric',
2801
3147
  //设置度量单位
@@ -2833,61 +3179,65 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2833
3179
  });
2834
3180
  }
2835
3181
  }, 20);
2836
- }
2837
- //设置区域限制
3182
+ } //设置区域限制
3183
+
2838
3184
  }, {
2839
3185
  key: "setAreaRestriction",
2840
3186
  value: function setAreaRestriction(areaRestriction) {
2841
3187
  var t = this;
3188
+
2842
3189
  var _t$dealData6 = t.dealData(areaRestriction),
2843
- _et = _t$dealData6._extent;
3190
+ _et = _t$dealData6._extent;
3191
+
2844
3192
  t.areaRestriction = t.state.gis.getView().setProperties({
2845
3193
  extent: [_et.xmax, _et.ymax, _et.xmin, _et.ymin]
2846
3194
  }, false);
2847
- }
2848
- //关闭区域限制
3195
+ } //关闭区域限制
3196
+
2849
3197
  }, {
2850
3198
  key: "clearAreaRestriction",
2851
3199
  value: function clearAreaRestriction() {
2852
3200
  var t = this;
2853
3201
  t.areaRestriction = null;
2854
- }
2855
- //区域限制逻辑
3202
+ } //区域限制逻辑
3203
+
2856
3204
  }, {
2857
3205
  key: "dealAreaRestriction",
2858
3206
  value: function dealAreaRestriction(e) {
2859
- var t = this;
2860
- //如果在区域内,不处理
3207
+ var t = this; //如果在区域内,不处理
3208
+
2861
3209
  if (t.areaRestriction.contains(e.extent.getCenter())) {
2862
3210
  return;
2863
- }
2864
- // if(t.containsExtent(t.areaRestriction,e.extent)){
3211
+ } // if(t.containsExtent(t.areaRestriction,e.extent)){
2865
3212
  // return;
2866
3213
  // }
3214
+
3215
+
2867
3216
  var _t$areaRestriction = t.areaRestriction,
2868
- xmin1 = _t$areaRestriction.xmin,
2869
- xmax1 = _t$areaRestriction.xmax,
2870
- ymin1 = _t$areaRestriction.ymin,
2871
- ymax1 = _t$areaRestriction.ymax;
3217
+ xmin1 = _t$areaRestriction.xmin,
3218
+ xmax1 = _t$areaRestriction.xmax,
3219
+ ymin1 = _t$areaRestriction.ymin,
3220
+ ymax1 = _t$areaRestriction.ymax;
2872
3221
  var _e$extent = e.extent,
2873
- xmin2 = _e$extent.xmin,
2874
- xmax2 = _e$extent.xmax,
2875
- ymin2 = _e$extent.ymin,
2876
- ymax2 = _e$extent.ymax;
3222
+ xmin2 = _e$extent.xmin,
3223
+ xmax2 = _e$extent.xmax,
3224
+ ymin2 = _e$extent.ymin,
3225
+ ymax2 = _e$extent.ymax;
2877
3226
  var x = e.extent.getCenter().x,
2878
- y = e.extent.getCenter().y;
3227
+ y = e.extent.getCenter().y;
2879
3228
  if (x < xmin1) x = xmin1 + 0.1;
2880
3229
  if (x > xmax1) x = xmax1 - 0.1;
2881
3230
  if (y < ymin1) y = ymin1 + 0.1;
2882
3231
  if (y > ymax1) y = ymax1 - 0.1;
2883
3232
  t.state.gis.getView().setCenter([x, y]);
2884
- }
2885
- //聚合地图图元(arg为空时聚合全部点)
3233
+ } //聚合地图图元(arg为空时聚合全部点)
3234
+
2886
3235
  }, {
2887
3236
  key: "cluster",
2888
3237
  value: function cluster(arg) {
2889
3238
  var t = this;
2890
3239
  var ary = [];
3240
+
2891
3241
  if (!arg) {
2892
3242
  var pointIds = t.state.pointIds;
2893
3243
  ary = pointIds;
@@ -2898,7 +3248,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2898
3248
  ary = arg.split(',');
2899
3249
  }
2900
3250
  }
2901
- t.state.pointIds = [];
3251
+
2902
3252
  t.pointLayers.map(function (item) {
2903
3253
  t.state.gis.removeLayer(item.layer);
2904
3254
  t.pointLayers = [];
@@ -2915,21 +3265,37 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2915
3265
  minDistance: 0,
2916
3266
  source: source
2917
3267
  });
2918
- t.clusterInfo.clusterHulls = new ol.layer.Vector({
2919
- source: t.clusterInfo.clusterSource,
2920
- style: clusterHullStyle
2921
- });
2922
- t.state.gis.addLayer(t.clusterInfo.clusterHulls);
2923
- t.clusterInfo.clusters = new ol.layer.Vector({
2924
- source: t.clusterInfo.clusterSource,
2925
- style: clusterStyle
2926
- });
2927
- t.state.gis.addLayer(t.clusterInfo.clusters);
2928
- t.clusterInfo.clusterCircles = new ol.layer.Vector({
2929
- source: t.clusterInfo.clusterSource,
2930
- style: clusterCircleStyle
2931
- });
2932
- t.state.gis.addLayer(t.clusterInfo.clusterCircles);
3268
+
3269
+ if (t.clusterInfo.clusterHulls) {
3270
+ t.clusterInfo.clusterHulls.setSource(t.clusterInfo.clusterSource);
3271
+ } else {
3272
+ t.clusterInfo.clusterHulls = new ol.layer.Vector({
3273
+ source: t.clusterInfo.clusterSource,
3274
+ style: clusterHullStyle
3275
+ });
3276
+ t.state.gis.addLayer(t.clusterInfo.clusterHulls);
3277
+ }
3278
+
3279
+ if (t.clusterInfo.clusters) {
3280
+ t.clusterInfo.clusters.setSource(t.clusterInfo.clusterSource);
3281
+ } else {
3282
+ t.clusterInfo.clusters = new ol.layer.Vector({
3283
+ source: t.clusterInfo.clusterSource,
3284
+ style: clusterStyle
3285
+ });
3286
+ t.state.gis.addLayer(t.clusterInfo.clusters);
3287
+ }
3288
+
3289
+ if (t.clusterInfo.clusterCircles) {
3290
+ t.clusterInfo.clusterCircles.setSource(t.clusterInfo.clusterSource);
3291
+ } else {
3292
+ t.clusterInfo.clusterCircles = new ol.layer.Vector({
3293
+ source: t.clusterInfo.clusterSource,
3294
+ style: clusterCircleStyle
3295
+ });
3296
+ t.state.gis.addLayer(t.clusterInfo.clusterCircles);
3297
+ }
3298
+
2933
3299
  function clusterMemberStyle(clusterMember) {
2934
3300
  var style = clusterMember.getStyle();
2935
3301
  var image = style && style.getImage ? style.getImage() : null;
@@ -2938,10 +3304,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2938
3304
  image: image
2939
3305
  });
2940
3306
  }
3307
+
2941
3308
  function clusterCircleStyle(cluster, resolution) {
2942
3309
  if (cluster !== t.clusterInfo.clickFeature || resolution !== t.clusterInfo.clickResolution) {
2943
3310
  return;
2944
3311
  }
3312
+
2945
3313
  var clusterMembers = cluster.get('features');
2946
3314
  var centerCoordinates = cluster.getGeometry().getCoordinates();
2947
3315
  return generatePointsCircle(clusterMembers.length, cluster.getGeometry().getCoordinates(), resolution).reduce(function (styles, coordinates, i) {
@@ -2960,24 +3328,30 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2960
3328
  return styles;
2961
3329
  }, []);
2962
3330
  }
3331
+
2963
3332
  function generatePointsCircle(count, clusterCenter, resolution) {
2964
3333
  var circumference = 1 * 28 * (2 + count);
2965
3334
  var legLength = circumference / (Math.PI * 2); //radius from circumference
3335
+
2966
3336
  var angleStep = Math.PI * 2 / count;
2967
3337
  var res = [];
2968
3338
  var angle;
2969
3339
  legLength = Math.max(legLength, 35) * resolution; // Minimum distance to get outside the cluster icon.
3340
+
2970
3341
  for (var i = 0; i < count; ++i) {
2971
3342
  // Clockwise, like spiral.
2972
3343
  angle = Math.PI / 2 + i * angleStep;
2973
3344
  res.push([clusterCenter[0] + legLength * Math.cos(angle), clusterCenter[1] + legLength * Math.sin(angle)]);
2974
3345
  }
3346
+
2975
3347
  return res;
2976
3348
  }
3349
+
2977
3350
  function clusterHullStyle(cluster) {
2978
3351
  if (cluster !== t.clusterInfo.hoverFeature) {
2979
3352
  return;
2980
3353
  }
3354
+
2981
3355
  var originalFeatures = cluster.get('features');
2982
3356
  var points = originalFeatures.map(function (feature) {
2983
3357
  return feature.getGeometry().getCoordinates();
@@ -2993,8 +3367,10 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
2993
3367
  })
2994
3368
  });
2995
3369
  }
3370
+
2996
3371
  function clusterStyle(feature) {
2997
3372
  var size = feature.get('features').length;
3373
+
2998
3374
  if (size > 1) {
2999
3375
  return [new ol.style.Style({
3000
3376
  image: new ol.style.Circle({
@@ -3031,18 +3407,22 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3031
3407
  key: "clearCluster",
3032
3408
  value: function clearCluster() {
3033
3409
  var t = this;
3410
+
3034
3411
  if (t.clusterInfo.clusterHulls) {
3035
3412
  t.state.gis.removeLayer(t.clusterInfo.clusterHulls);
3036
3413
  t.clusterInfo.clusterHulls = null;
3037
3414
  }
3415
+
3038
3416
  if (t.clusterInfo.clusters) {
3039
3417
  t.state.gis.removeLayer(t.clusterInfo.clusters);
3040
3418
  t.clusterInfo.clusters = null;
3041
3419
  }
3420
+
3042
3421
  if (t.clusterInfo.clusterCircles) {
3043
3422
  t.state.gis.removeLayer(t.clusterInfo.clusterCircles);
3044
3423
  t.clusterInfo.clusterCircles = null;
3045
3424
  }
3425
+
3046
3426
  t.props.mapPoints.map(function (item) {
3047
3427
  if (t.GM.getGraphic(item.id)) {
3048
3428
  t.GM.removeGraphic(item.id);
@@ -3053,20 +3433,21 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3053
3433
  }
3054
3434
  /*公共方法*/
3055
3435
  //判断extent1是否在extent2内部
3436
+
3056
3437
  }, {
3057
3438
  key: "containsExtent",
3058
3439
  value: function containsExtent(e1, e2) {
3059
3440
  var xmin1 = e1.xmin,
3060
- xmax1 = e1.xmax,
3061
- ymin1 = e1.ymin,
3062
- ymax1 = e1.ymax;
3441
+ xmax1 = e1.xmax,
3442
+ ymin1 = e1.ymin,
3443
+ ymax1 = e1.ymax;
3063
3444
  var xmin2 = e2.xmin,
3064
- xmax2 = e2.xmax,
3065
- ymin2 = e2.ymin,
3066
- ymax2 = e2.ymax;
3445
+ xmax2 = e2.xmax,
3446
+ ymin2 = e2.ymin,
3447
+ ymax2 = e2.ymax;
3067
3448
  return xmin2 > xmin1 && xmax2 < xmax1 && ymin2 > ymin1 && ymax2 < ymax1;
3068
- }
3069
- //将图元z-index设置成最高
3449
+ } //将图元z-index设置成最高
3450
+
3070
3451
  }, {
3071
3452
  key: "czIndex",
3072
3453
  value: function czIndex(id) {
@@ -3077,8 +3458,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3077
3458
  key: "equalsPoint",
3078
3459
  value: function equalsPoint(a, b) {
3079
3460
  return a.x == b.x && a.y == b.y;
3080
- }
3081
- //计算2点间距离 单位m 精确到2位小数
3461
+ } //计算2点间距离 单位m 精确到2位小数
3462
+
3082
3463
  }, {
3083
3464
  key: "calculatePointsDistance",
3084
3465
  value: function calculatePointsDistance(fp, ep) {
@@ -3086,16 +3467,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3086
3467
  var distance = ol.sphere.getDistance(fp, ep);
3087
3468
  console.log(distance);
3088
3469
  return Math.round(distance);
3089
- }
3090
- //计算多个点的距离(常用于线计算)
3470
+ } //计算多个点的距离(常用于线计算)
3471
+
3091
3472
  }, {
3092
3473
  key: "calculateDistance",
3093
3474
  value: function calculateDistance(ps) {
3094
3475
  var t = this,
3095
- totalDistance = 0;
3476
+ totalDistance = 0;
3477
+
3096
3478
  if (ps.length < 0) {
3097
3479
  return 0;
3098
3480
  }
3481
+
3099
3482
  for (var i = 0; i < ps.length; i++) {
3100
3483
  if (i < ps.length - 1) {
3101
3484
  var distance = t.calculatePointsDistance(ps[i], ps[i + 1]);
@@ -3103,37 +3486,43 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3103
3486
  totalDistance += distance;
3104
3487
  }
3105
3488
  }
3489
+
3106
3490
  console.log(totalDistance);
3107
3491
  return Math.round(totalDistance * 100) / 100;
3108
- }
3109
- //处理线和面的 经纬度数据
3492
+ } //处理线和面的 经纬度数据
3493
+
3110
3494
  }, {
3111
3495
  key: "dealData",
3112
3496
  value: function dealData(paths) {
3113
3497
  //区别点和圆的经纬度数据处理
3114
3498
  var lnglatAry = [],
3115
- _extent = {
3116
- xmax: 0,
3117
- xmin: 0,
3118
- ymax: 0,
3119
- ymin: 0
3120
- },
3121
- path = [];
3499
+ _extent = {
3500
+ xmax: 0,
3501
+ xmin: 0,
3502
+ ymax: 0,
3503
+ ymin: 0
3504
+ },
3505
+ path = [];
3122
3506
  path = paths.map(function (item, index) {
3123
3507
  var lng = item[0],
3124
- lat = item[1];
3508
+ lat = item[1];
3509
+
3125
3510
  if (lng > _extent.xmax) {
3126
3511
  _extent.xmax = lng;
3127
3512
  }
3513
+
3128
3514
  if (lng < _extent.xmin || _extent.xmin == 0) {
3129
3515
  _extent.xmin = lng;
3130
3516
  }
3517
+
3131
3518
  if (lat > _extent.ymax) {
3132
3519
  _extent.ymax = lat;
3133
3520
  }
3521
+
3134
3522
  if (lat < _extent.ymin || _extent.ymin == 0) {
3135
3523
  _extent.ymin = lat;
3136
3524
  }
3525
+
3137
3526
  lnglatAry.push({
3138
3527
  lngX: lng,
3139
3528
  latX: lat
@@ -3145,50 +3534,55 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3145
3534
  _extent: _extent,
3146
3535
  path: path
3147
3536
  };
3148
- }
3149
- //处理点位图元的添加 和 更新
3537
+ } //处理点位图元的添加 和 更新
3538
+
3150
3539
  }, {
3151
3540
  key: "dealLabelGraphics",
3152
3541
  value: function dealLabelGraphics(id, label) {
3153
3542
  var t = this;
3543
+
3154
3544
  if (label) {
3155
- var position = (t.GM.getGraphic(id) || {}).geometry || label.position;
3156
- //经纬度转top和left
3545
+ var position = (t.GM.getGraphic(id) || {}).geometry || label.position; //经纬度转top和left
3546
+
3157
3547
  var tl = t.state.gis.toScreen(position),
3158
- lbl = _objectSpread({}, label);
3159
- //渲染優化
3548
+ lbl = _objectSpread({}, label); //渲染優化
3549
+
3550
+
3160
3551
  if (!(tl.y < -50 || tl.x < -50 || tl.y > t.state.gis.height || tl.x > t.state.gis.width)) {
3161
3552
  //设置label的位置(通过定位来实现)
3162
3553
  label.html.css({
3163
3554
  position: 'absolute',
3164
3555
  top: tl.y + (label.offset.y || 0) - t.labelLayer.y,
3165
3556
  left: tl.x + (label.offset.x || 0) - t.labelLayer.x
3166
- });
3167
- //添加点位到(地图)
3557
+ }); //添加点位到(地图)
3558
+
3168
3559
  $("#".concat(t.htmlPointsId)).append(label.html);
3169
3560
  lbl.add = true;
3170
3561
  } else {
3171
3562
  lbl.add = false;
3172
- }
3173
- //记录下label的dom对象,用于后期修改和删除(基本是删除)
3563
+ } //记录下label的dom对象,用于后期修改和删除(基本是删除)
3564
+
3565
+
3174
3566
  t.Label[id] = lbl;
3175
3567
  }
3176
- }
3177
- //点的跳动动画
3568
+ } //点的跳动动画
3569
+
3178
3570
  }, {
3179
3571
  key: "pointAnimation",
3180
3572
  value: function pointAnimation(id, marker) {
3181
- var t = this;
3182
- //null时关闭跳动
3573
+ var t = this; //null时关闭跳动
3574
+
3183
3575
  if (!!marker) {
3184
3576
  if (t.animTimer[id]) {
3185
3577
  clearInterval(t.animTimer[id]);
3186
3578
  }
3579
+
3187
3580
  t.animTimer[id] = setInterval(function () {
3188
3581
  //点被隐藏时,没有执行,定时不关
3189
3582
  if (marker.symbol) {
3190
- var shape = _objectSpread({}, marker.symbol);
3191
- //初始数据 点位有变动,重新刷新数据
3583
+ var shape = _objectSpread({}, marker.symbol); //初始数据 点位有变动,重新刷新数据
3584
+
3585
+
3192
3586
  if (!t.animCount[id] || shape.yoffset != t.animCount[id].now) {
3193
3587
  t.animCount[id] = {
3194
3588
  start: shape.yoffset,
@@ -3196,12 +3590,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3196
3590
  notation: -1
3197
3591
  };
3198
3592
  }
3593
+
3199
3594
  if (t.animCount[id].now - t.animCount[id].start == 20) {
3200
3595
  t.animCount[id].notation = -1;
3201
3596
  }
3597
+
3202
3598
  if (t.animCount[id].now - t.animCount[id].start == 0) {
3203
3599
  t.animCount[id].notation = 1;
3204
3600
  }
3601
+
3205
3602
  shape.yoffset = t.animCount[id].now = t.animCount[id].now + t.animCount[id].notation * 2;
3206
3603
  marker.symbol.setOffset(shape.xoffset, shape.yoffset);
3207
3604
  t.state.gis.graphics.refresh();
@@ -3215,93 +3612,107 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3215
3612
  key: "moveAnimation",
3216
3613
  value: function moveAnimation() {
3217
3614
  var t = this;
3615
+
3218
3616
  if (t.moveToTimer) {
3219
3617
  clearInterval(t.moveToTimer);
3220
3618
  }
3619
+
3221
3620
  t.moveToTimer = setInterval(function () {
3222
3621
  for (var i = 0; i < t.movePoints.length; i++) {
3223
3622
  t.movePoints[i].waitTime += 10;
3224
3623
  t.movePoints[i].deleteTime -= 10;
3225
3624
  }
3625
+
3226
3626
  t.movePoints.sort(function (x, y) {
3227
3627
  return y.waitTime - x.waitTime;
3228
3628
  });
3229
3629
  var nowMovePoints = t.movePoints.slice(0, 10),
3230
- deleteIndex = [];
3630
+ deleteIndex = [];
3631
+
3231
3632
  for (var _i9 = 0; _i9 < nowMovePoints.length; _i9++) {
3232
3633
  var _nowMovePoints$_i = nowMovePoints[_i9],
3233
- id = _nowMovePoints$_i.id,
3234
- rx = _nowMovePoints$_i.rx,
3235
- ry = _nowMovePoints$_i.ry,
3236
- waitTime = _nowMovePoints$_i.waitTime,
3237
- deleteTime = _nowMovePoints$_i.deleteTime,
3238
- ddeg = _nowMovePoints$_i.ddeg;
3634
+ id = _nowMovePoints$_i.id,
3635
+ rx = _nowMovePoints$_i.rx,
3636
+ ry = _nowMovePoints$_i.ry,
3637
+ waitTime = _nowMovePoints$_i.waitTime,
3638
+ deleteTime = _nowMovePoints$_i.deleteTime,
3639
+ ddeg = _nowMovePoints$_i.ddeg;
3239
3640
  var gc = t.GM.getGraphic(id);
3641
+
3240
3642
  if (!gc || !gc._graphicsLayer) {
3241
3643
  clearInterval(t.moveToTimer);
3242
3644
  } else {
3243
3645
  var gg = gc.getGeometry();
3244
3646
  var tx = gg[0] + rx,
3245
- ty = gg[1] + ry;
3647
+ ty = gg[1] + ry;
3246
3648
  gc.setGeometry([tx, ty]);
3247
3649
  t.movePoints[_i9].waitTime = 0;
3650
+
3248
3651
  if (deleteTime <= 0) {
3249
3652
  deleteIndex.push(_i9);
3250
3653
  }
3251
3654
  }
3252
3655
  }
3656
+
3253
3657
  deleteIndex.sort(function (a, b) {
3254
3658
  return b - a;
3255
3659
  });
3660
+
3256
3661
  for (var _i10 = 0; _i10 < deleteIndex.length; _i10++) {
3257
3662
  t.movePoints.splice(deleteIndex[_i10], 1);
3258
3663
  }
3664
+
3259
3665
  if (nowMovePoints.length == 0) {
3260
3666
  clearInterval(t.moveToTimer);
3261
3667
  }
3262
3668
  }, 10);
3263
- }
3264
- //点位移动动画效果
3669
+ } //点位移动动画效果
3670
+
3265
3671
  }, {
3266
3672
  key: "moveTo",
3267
3673
  value: function moveTo(id, lnglat, delay, autoRotation, urlright, urlleft) {
3268
3674
  delay = delay || 3;
3269
3675
  var t = this,
3270
- timer = 10;
3676
+ timer = 10;
3271
3677
  delay = eval(delay) * 1000;
3272
3678
  var count = delay / timer,
3273
- gc = this.GM.getGraphic(id);
3679
+ gc = this.GM.getGraphic(id);
3274
3680
  var s = gc.geometry,
3275
- e = {
3276
- x: lnglat[0],
3277
- y: lnglat[1]
3278
- };
3681
+ e = {
3682
+ x: lnglat[0],
3683
+ y: lnglat[1]
3684
+ };
3685
+
3279
3686
  if (t.equalsPoint(s, e)) {
3280
3687
  return false;
3281
3688
  } else {
3282
3689
  var ddeg = 0,
3283
- url = null;
3284
- //计算角度,旋转
3690
+ url = null; //计算角度,旋转
3691
+
3285
3692
  if (autoRotation) {
3286
3693
  //自己实现旋转
3287
3694
  ddeg = t.rotateDeg(gc.geometry, lnglat);
3695
+
3288
3696
  if (urlleft && ddeg < -90 && ddeg > -270) {
3289
3697
  ddeg += 180;
3290
3698
  url = urlleft;
3291
3699
  } else {
3292
3700
  url = urlright;
3293
3701
  }
3702
+
3294
3703
  gc.setStyle(new ol.style.Style({
3295
3704
  image: new ol.style.Icon({
3296
3705
  src: url,
3297
3706
  rotation: Math.PI / 180 * ddeg
3298
3707
  })
3299
3708
  }));
3300
- }
3301
- //拆分延迟移动定位
3709
+ } //拆分延迟移动定位
3710
+
3711
+
3302
3712
  var rx = (e.x - s.x) / count,
3303
- ry = (e.y - s.y) / count;
3713
+ ry = (e.y - s.y) / count;
3304
3714
  var isHave = false;
3715
+
3305
3716
  for (var i = 0; i < t.movePoints.length; i++) {
3306
3717
  if (t.movePoints[i].id == id) {
3307
3718
  t.movePoints.splice(i, 1, {
@@ -3314,6 +3725,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3314
3725
  isHave = true;
3315
3726
  }
3316
3727
  }
3728
+
3317
3729
  if (!isHave) {
3318
3730
  t.movePoints.push({
3319
3731
  id: id,
@@ -3324,30 +3736,34 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3324
3736
  });
3325
3737
  }
3326
3738
  }
3327
- }
3328
- //点位角度旋转(以指向东(右)为0°)
3739
+ } //点位角度旋转(以指向东(右)为0°)
3740
+
3329
3741
  }, {
3330
3742
  key: "rotateDeg",
3331
3743
  value: function rotateDeg(sp, ep) {
3332
3744
  var t = this;
3333
3745
  var spLngLat = sp;
3746
+
3334
3747
  if (Array.isArray(sp)) {
3335
3748
  spLngLat = new ol.geom.Point(sp[0], sp[1]);
3336
3749
  }
3750
+
3337
3751
  var s = t.state.gis.getPixelFromCoordinate(spLngLat),
3338
- //获取当前点位的经纬度
3339
- e = t.state.gis.getPixelFromCoordinate(new ol.geom.Point(ep[0], ep[1])),
3340
- deg = 0;
3752
+ //获取当前点位的经纬度
3753
+ e = t.state.gis.getPixelFromCoordinate(new ol.geom.Point(ep[0], ep[1])),
3754
+ deg = 0;
3755
+
3341
3756
  if (e.x != s.x) {
3342
3757
  var tan = (e.y - s.y) / (e.x - s.x),
3343
- atan = Math.atan(tan);
3344
- deg = atan * 360 / (2 * Math.PI);
3345
- //degree correction;
3758
+ atan = Math.atan(tan);
3759
+ deg = atan * 360 / (2 * Math.PI); //degree correction;
3760
+
3346
3761
  if (e.x < s.x) {
3347
3762
  deg = -deg + 90 + 90;
3348
3763
  } else {
3349
3764
  deg = -deg;
3350
3765
  }
3766
+
3351
3767
  deg = -deg;
3352
3768
  } else {
3353
3769
  var disy = e.y - s.y;
@@ -3356,15 +3772,16 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3356
3772
  if (disy == 0) bias = 0;
3357
3773
  deg = -bias * 90;
3358
3774
  }
3775
+
3359
3776
  return deg;
3360
- }
3361
- //对比对象数据是否相等
3777
+ } //对比对象数据是否相等
3778
+
3362
3779
  }, {
3363
3780
  key: "deepEqual",
3364
3781
  value: function deepEqual(a, b) {
3365
3782
  return _immutable["default"].is(_immutable["default"].fromJS(a), _immutable["default"].fromJS(b));
3366
- }
3367
- //数据解析(分析,新增,更新,删除对应的数据)
3783
+ } //数据解析(分析,新增,更新,删除对应的数据)
3784
+
3368
3785
  }, {
3369
3786
  key: "dataMatch",
3370
3787
  value: function dataMatch(oldData, newData, type) {
@@ -3395,13 +3812,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3395
3812
  updatedData: updatedData,
3396
3813
  replacedData: replacedData
3397
3814
  };
3398
- }
3399
- //处理需要增加图元的数据(避免意外问题)
3815
+ } //处理需要增加图元的数据(避免意外问题)
3816
+
3400
3817
  }, {
3401
3818
  key: "dealAdd",
3402
3819
  value: function dealAdd(ary, ids) {
3403
3820
  var ads = [],
3404
- otherupds = [];
3821
+ otherupds = [];
3822
+
3405
3823
  for (var i = 0; i < ary.length; i++) {
3406
3824
  if (ids.indexOf(ary[i].id) > -1) {
3407
3825
  otherupds.push(ary[i]);
@@ -3409,17 +3827,19 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3409
3827
  ads.push(ary[i]);
3410
3828
  }
3411
3829
  }
3830
+
3412
3831
  return {
3413
3832
  ads: ads,
3414
3833
  otherupds: otherupds
3415
3834
  };
3416
- }
3417
- //处理需要更新图元的数据(避免意外问题)
3835
+ } //处理需要更新图元的数据(避免意外问题)
3836
+
3418
3837
  }, {
3419
3838
  key: "dealUpdate",
3420
3839
  value: function dealUpdate(ary, ids) {
3421
3840
  var upds = [],
3422
- otherads = [];
3841
+ otherads = [];
3842
+
3423
3843
  for (var i = 0; i < ary.length; i++) {
3424
3844
  if (ids.indexOf(ary[i].id) > -1) {
3425
3845
  upds.push(ary[i]);
@@ -3427,6 +3847,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3427
3847
  otherads.push(ary[i]);
3428
3848
  }
3429
3849
  }
3850
+
3430
3851
  return {
3431
3852
  upds: upds,
3432
3853
  otherads: otherads
@@ -3444,8 +3865,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3444
3865
  height: '100%'
3445
3866
  }
3446
3867
  });
3447
- }
3448
- //初始化
3868
+ } //初始化
3869
+
3449
3870
  }, {
3450
3871
  key: "componentDidMount",
3451
3872
  value: function componentDidMount() {
@@ -3453,74 +3874,75 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3453
3874
  t.loadMapComplete.then(function () {
3454
3875
  t.init();
3455
3876
  });
3456
- }
3457
- //已加载组件,收到新的参数时调用
3877
+ } //已加载组件,收到新的参数时调用
3878
+
3458
3879
  }, {
3459
3880
  key: "componentWillReceiveProps",
3460
3881
  value: function componentWillReceiveProps(nextProps, prevProps) {
3461
- var t = this;
3462
- //点/线旧数据
3882
+ var t = this; //点/线旧数据
3883
+
3463
3884
  var _t$state2 = t.state,
3464
- pointIds = _t$state2.pointIds,
3465
- lineIds = _t$state2.lineIds,
3466
- polygonIds = _t$state2.polygonIds,
3467
- circleIds = _t$state2.circleIds,
3468
- drawIds = _t$state2.drawIds;
3885
+ pointIds = _t$state2.pointIds,
3886
+ lineIds = _t$state2.lineIds,
3887
+ polygonIds = _t$state2.polygonIds,
3888
+ circleIds = _t$state2.circleIds,
3889
+ drawIds = _t$state2.drawIds;
3469
3890
  var point = drawIds.point,
3470
- polyline = drawIds.polyline,
3471
- polygon = drawIds.polygon,
3472
- circle = drawIds.circle,
3473
- rectangle = drawIds.rectangle;
3474
- //点/线新数据
3891
+ polyline = drawIds.polyline,
3892
+ polygon = drawIds.polygon,
3893
+ circle = drawIds.circle,
3894
+ rectangle = drawIds.rectangle; //点/线新数据
3895
+
3475
3896
  var _nextProps$mapPoints = nextProps.mapPoints,
3476
- mapPoints = _nextProps$mapPoints === void 0 ? [] : _nextProps$mapPoints,
3477
- _nextProps$mapLines = nextProps.mapLines,
3478
- mapLines = _nextProps$mapLines === void 0 ? [] : _nextProps$mapLines,
3479
- _nextProps$mapPolygon = nextProps.mapPolygons,
3480
- mapPolygons = _nextProps$mapPolygon === void 0 ? [] : _nextProps$mapPolygon,
3481
- _nextProps$mapCircles = nextProps.mapCircles,
3482
- mapCircles = _nextProps$mapCircles === void 0 ? [] : _nextProps$mapCircles,
3483
- _nextProps$customized = nextProps.customizedBoundary,
3484
- customizedBoundary = _nextProps$customized === void 0 ? [] : _nextProps$customized,
3485
- isOpenTrafficInfo = nextProps.isOpenTrafficInfo,
3486
- boundaryName = nextProps.boundaryName,
3487
- heatMapData = nextProps.heatMapData,
3488
- mapVisiblePoints = nextProps.mapVisiblePoints,
3489
- setVisiblePoints = nextProps.setVisiblePoints,
3490
- setCenter = nextProps.setCenter,
3491
- mapCenter = nextProps.mapCenter,
3492
- setZoomLevel = nextProps.setZoomLevel,
3493
- mapZoomLevel = nextProps.mapZoomLevel,
3494
- setCluster = nextProps.setCluster,
3495
- mapCluster = nextProps.mapCluster,
3496
- isRangingTool = nextProps.isRangingTool,
3497
- mapRangingTool = nextProps.mapRangingTool,
3498
- isRemove = nextProps.isRemove,
3499
- mapRemove = nextProps.mapRemove,
3500
- mapDraw = nextProps.mapDraw,
3501
- isDraw = nextProps.isDraw,
3502
- isCloseDraw = nextProps.isCloseDraw,
3503
- editGraphicId = nextProps.editGraphicId,
3504
- isDoEdit = nextProps.isDoEdit,
3505
- isEndEdit = nextProps.isEndEdit,
3506
- mapPointCollection = nextProps.mapPointCollection,
3507
- isclearAllPointCollection = nextProps.isclearAllPointCollection,
3508
- isSetAreaRestriction = nextProps.isSetAreaRestriction,
3509
- areaRestriction = nextProps.areaRestriction,
3510
- isClearAreaRestriction = nextProps.isClearAreaRestriction,
3511
- isClearAll = nextProps.isClearAll,
3512
- olProps = nextProps.olProps;
3513
- // 等待地图加载
3897
+ mapPoints = _nextProps$mapPoints === void 0 ? [] : _nextProps$mapPoints,
3898
+ _nextProps$mapLines = nextProps.mapLines,
3899
+ mapLines = _nextProps$mapLines === void 0 ? [] : _nextProps$mapLines,
3900
+ _nextProps$mapPolygon = nextProps.mapPolygons,
3901
+ mapPolygons = _nextProps$mapPolygon === void 0 ? [] : _nextProps$mapPolygon,
3902
+ _nextProps$mapCircles = nextProps.mapCircles,
3903
+ mapCircles = _nextProps$mapCircles === void 0 ? [] : _nextProps$mapCircles,
3904
+ _nextProps$customized = nextProps.customizedBoundary,
3905
+ customizedBoundary = _nextProps$customized === void 0 ? [] : _nextProps$customized,
3906
+ isOpenTrafficInfo = nextProps.isOpenTrafficInfo,
3907
+ boundaryName = nextProps.boundaryName,
3908
+ heatMapData = nextProps.heatMapData,
3909
+ mapVisiblePoints = nextProps.mapVisiblePoints,
3910
+ setVisiblePoints = nextProps.setVisiblePoints,
3911
+ setCenter = nextProps.setCenter,
3912
+ mapCenter = nextProps.mapCenter,
3913
+ setZoomLevel = nextProps.setZoomLevel,
3914
+ mapZoomLevel = nextProps.mapZoomLevel,
3915
+ setCluster = nextProps.setCluster,
3916
+ mapCluster = nextProps.mapCluster,
3917
+ isRangingTool = nextProps.isRangingTool,
3918
+ mapRangingTool = nextProps.mapRangingTool,
3919
+ isRemove = nextProps.isRemove,
3920
+ mapRemove = nextProps.mapRemove,
3921
+ mapDraw = nextProps.mapDraw,
3922
+ isDraw = nextProps.isDraw,
3923
+ isCloseDraw = nextProps.isCloseDraw,
3924
+ editGraphicId = nextProps.editGraphicId,
3925
+ isDoEdit = nextProps.isDoEdit,
3926
+ isEndEdit = nextProps.isEndEdit,
3927
+ mapPointCollection = nextProps.mapPointCollection,
3928
+ isclearAllPointCollection = nextProps.isclearAllPointCollection,
3929
+ isSetAreaRestriction = nextProps.isSetAreaRestriction,
3930
+ areaRestriction = nextProps.areaRestriction,
3931
+ isClearAreaRestriction = nextProps.isClearAreaRestriction,
3932
+ isClearAll = nextProps.isClearAll,
3933
+ olProps = nextProps.olProps; // 等待地图加载
3934
+
3514
3935
  if (!t.state.mapCreated) return;
3515
3936
  /*点数据处理
3516
3937
  pointData[2]相同的点,执行刷新
3517
3938
  pointData[1]的数据在idsForGraphicId中不存在的,执行新增
3518
3939
  pointData[0]数据中多余的id,执行删除
3519
3940
  */
3941
+
3520
3942
  if (mapPoints instanceof Array && t.props.mapPoints instanceof Array && !t.deepEqual(mapPoints, t.props.mapPoints)) {
3521
3943
  var oldMapPoints = t.props.mapPoints;
3522
- var newMapPoints = mapPoints;
3523
- //过滤编辑的图元
3944
+ var newMapPoints = mapPoints; //过滤编辑的图元
3945
+
3524
3946
  if (!!t.editId) {
3525
3947
  oldMapPoints = t.props.mapPoints.filter(function (item) {
3526
3948
  return item.id !== editGraphicId;
@@ -3529,41 +3951,52 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3529
3951
  return item.id !== editGraphicId;
3530
3952
  });
3531
3953
  }
3954
+
3532
3955
  var _t$dataMatch = t.dataMatch(oldMapPoints, newMapPoints, 'id'),
3533
- deletedDataIDs = _t$dataMatch.deletedDataIDs,
3534
- addedData = _t$dataMatch.addedData,
3535
- updatedData = _t$dataMatch.updatedData;
3956
+ deletedDataIDs = _t$dataMatch.deletedDataIDs,
3957
+ addedData = _t$dataMatch.addedData,
3958
+ updatedData = _t$dataMatch.updatedData;
3959
+
3536
3960
  var _t$dealAdd = t.dealAdd(addedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
3537
- ads = _t$dealAdd.ads,
3538
- otherupds = _t$dealAdd.otherupds;
3961
+ ads = _t$dealAdd.ads,
3962
+ otherupds = _t$dealAdd.otherupds;
3963
+
3539
3964
  var _t$dealUpdate = t.dealUpdate(updatedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
3540
- upds = _t$dealUpdate.upds,
3541
- otherads = _t$dealUpdate.otherads;
3542
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3543
- var _iterator = _createForOfIteratorHelper(deletedDataIDs),
3544
- _step;
3545
- try {
3546
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
3547
- var id = _step.value;
3548
- t.removeGraphic(id, 'point');
3965
+ upds = _t$dealUpdate.upds,
3966
+ otherads = _t$dealUpdate.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3967
+
3968
+
3969
+ var index = 0;
3970
+
3971
+ var removeGraphic = function removeGraphic(id) {
3972
+ t.removeGraphic(id, 'point');
3973
+
3974
+ if (index < deletedDataIDs.length - 1) {
3975
+ requestIdleCallback(function () {
3976
+ return removeGraphic(deletedDataIDs[++index]);
3977
+ });
3549
3978
  }
3550
- //增加
3551
- } catch (err) {
3552
- _iterator.e(err);
3553
- } finally {
3554
- _iterator.f();
3555
- }
3556
- t.addPoint([].concat(_toConsumableArray(ads), _toConsumableArray(otherads)));
3557
- //更新
3979
+ };
3980
+
3981
+ if (!(0, _lodash.isEmpty)(deletedDataIDs)) {
3982
+ removeGraphic(deletedDataIDs[index]);
3983
+ } //增加
3984
+
3985
+
3986
+ t.addPoint([].concat(_toConsumableArray(ads), _toConsumableArray(otherads))); //更新
3987
+
3558
3988
  t.updatePoint([].concat(_toConsumableArray(upds), _toConsumableArray(otherupds)));
3559
3989
  }
3560
3990
  /*
3561
3991
  线数据处理
3562
3992
  先全删除,再新增
3563
3993
  */
3994
+
3995
+
3564
3996
  if (mapLines instanceof Array && t.props.mapLines instanceof Array && !t.deepEqual(mapLines, t.props.mapLines)) {
3565
3997
  var oldMapLines = t.props.mapLines;
3566
3998
  var newMapLines = mapLines;
3999
+
3567
4000
  if (!!t.editId) {
3568
4001
  oldMapLines = t.props.mapLines.filter(function (item) {
3569
4002
  return item.id !== editGraphicId;
@@ -3572,41 +4005,50 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3572
4005
  return item.id !== editGraphicId;
3573
4006
  });
3574
4007
  }
4008
+
3575
4009
  var _t$dataMatch2 = t.dataMatch(oldMapLines, newMapLines, 'id'),
3576
- _deletedDataIDs = _t$dataMatch2.deletedDataIDs,
3577
- _addedData = _t$dataMatch2.addedData,
3578
- _updatedData = _t$dataMatch2.updatedData;
4010
+ _deletedDataIDs = _t$dataMatch2.deletedDataIDs,
4011
+ _addedData = _t$dataMatch2.addedData,
4012
+ _updatedData = _t$dataMatch2.updatedData;
4013
+
3579
4014
  var _t$dealAdd2 = t.dealAdd(_addedData, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
3580
- _ads = _t$dealAdd2.ads,
3581
- _otherupds = _t$dealAdd2.otherupds;
4015
+ _ads = _t$dealAdd2.ads,
4016
+ _otherupds = _t$dealAdd2.otherupds;
4017
+
3582
4018
  var _t$dealUpdate2 = t.dealUpdate(_updatedData, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
3583
- _upds = _t$dealUpdate2.upds,
3584
- _otherads = _t$dealUpdate2.otherads;
3585
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3586
- var _iterator2 = _createForOfIteratorHelper(_deletedDataIDs),
3587
- _step2;
4019
+ _upds = _t$dealUpdate2.upds,
4020
+ _otherads = _t$dealUpdate2.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
4021
+
4022
+
4023
+ var _iterator = _createForOfIteratorHelper(_deletedDataIDs),
4024
+ _step;
4025
+
3588
4026
  try {
3589
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3590
- var _id = _step2.value;
3591
- t.removeGraphic(_id, 'line');
3592
- }
3593
- //增加
4027
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4028
+ var id = _step.value;
4029
+ t.removeGraphic(id, 'line');
4030
+ } //增加
4031
+
3594
4032
  } catch (err) {
3595
- _iterator2.e(err);
4033
+ _iterator.e(err);
3596
4034
  } finally {
3597
- _iterator2.f();
4035
+ _iterator.f();
3598
4036
  }
3599
- t.addLine([].concat(_toConsumableArray(_ads), _toConsumableArray(_otherads)));
3600
- //更新
4037
+
4038
+ t.addLine([].concat(_toConsumableArray(_ads), _toConsumableArray(_otherads))); //更新
4039
+
3601
4040
  t.updateLine([].concat(_toConsumableArray(_upds), _toConsumableArray(_otherupds)));
3602
4041
  }
3603
4042
  /*
3604
4043
  面数据处理
3605
4044
  先全删除,再新增
3606
4045
  */
4046
+
4047
+
3607
4048
  if (mapPolygons instanceof Array && t.props.mapPolygons instanceof Array && !t.deepEqual(mapPolygons, t.props.mapPolygons)) {
3608
4049
  var oldMapPolygons = t.props.mapPolygons;
3609
4050
  var newMapPolygons = mapPolygons;
4051
+
3610
4052
  if (!!t.editId) {
3611
4053
  oldMapPolygons = t.props.mapPolygons.filter(function (item) {
3612
4054
  return item.id !== editGraphicId;
@@ -3615,41 +4057,50 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3615
4057
  return item.id !== editGraphicId;
3616
4058
  });
3617
4059
  }
4060
+
3618
4061
  var _t$dataMatch3 = t.dataMatch(oldMapPolygons, newMapPolygons, 'id'),
3619
- _deletedDataIDs2 = _t$dataMatch3.deletedDataIDs,
3620
- _addedData2 = _t$dataMatch3.addedData,
3621
- _updatedData2 = _t$dataMatch3.updatedData;
4062
+ _deletedDataIDs2 = _t$dataMatch3.deletedDataIDs,
4063
+ _addedData2 = _t$dataMatch3.addedData,
4064
+ _updatedData2 = _t$dataMatch3.updatedData;
4065
+
3622
4066
  var _t$dealAdd3 = t.dealAdd(_addedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
3623
- _ads2 = _t$dealAdd3.ads,
3624
- _otherupds2 = _t$dealAdd3.otherupds;
4067
+ _ads2 = _t$dealAdd3.ads,
4068
+ _otherupds2 = _t$dealAdd3.otherupds;
4069
+
3625
4070
  var _t$dealUpdate3 = t.dealUpdate(_updatedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
3626
- _upds2 = _t$dealUpdate3.upds,
3627
- _otherads2 = _t$dealUpdate3.otherads;
3628
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3629
- var _iterator3 = _createForOfIteratorHelper(_deletedDataIDs2),
3630
- _step3;
4071
+ _upds2 = _t$dealUpdate3.upds,
4072
+ _otherads2 = _t$dealUpdate3.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
4073
+
4074
+
4075
+ var _iterator2 = _createForOfIteratorHelper(_deletedDataIDs2),
4076
+ _step2;
4077
+
3631
4078
  try {
3632
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
3633
- var _id2 = _step3.value;
3634
- t.removeGraphic(_id2, 'polygon');
3635
- }
3636
- //增加
4079
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4080
+ var _id = _step2.value;
4081
+ t.removeGraphic(_id, 'polygon');
4082
+ } //增加
4083
+
3637
4084
  } catch (err) {
3638
- _iterator3.e(err);
4085
+ _iterator2.e(err);
3639
4086
  } finally {
3640
- _iterator3.f();
4087
+ _iterator2.f();
3641
4088
  }
3642
- t.addPolygon([].concat(_toConsumableArray(_ads2), _toConsumableArray(_otherads2)));
3643
- //更新
4089
+
4090
+ t.addPolygon([].concat(_toConsumableArray(_ads2), _toConsumableArray(_otherads2))); //更新
4091
+
3644
4092
  t.updatePolygon([].concat(_toConsumableArray(_upds2), _toConsumableArray(_otherupds2)));
3645
4093
  }
3646
4094
  /*
3647
4095
  圆数据处理
3648
4096
  先全删除,再新增
3649
4097
  */
4098
+
4099
+
3650
4100
  if (mapCircles instanceof Array && t.props.mapCircles instanceof Array && !t.deepEqual(mapCircles, t.props.mapCircles)) {
3651
4101
  var oldMapCircles = t.props.mapCircles;
3652
4102
  var newMapCircles = mapCircles;
4103
+
3653
4104
  if (!!t.editId) {
3654
4105
  oldMapCircles = t.props.mapCircles.filter(function (item) {
3655
4106
  return item.id !== editGraphicId;
@@ -3658,120 +4109,145 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3658
4109
  return item.id !== editGraphicId;
3659
4110
  });
3660
4111
  }
4112
+
3661
4113
  var _t$dataMatch4 = t.dataMatch(oldMapCircles, newMapCircles, 'id'),
3662
- _deletedDataIDs3 = _t$dataMatch4.deletedDataIDs,
3663
- _addedData3 = _t$dataMatch4.addedData,
3664
- _updatedData3 = _t$dataMatch4.updatedData;
4114
+ _deletedDataIDs3 = _t$dataMatch4.deletedDataIDs,
4115
+ _addedData3 = _t$dataMatch4.addedData,
4116
+ _updatedData3 = _t$dataMatch4.updatedData;
4117
+
3665
4118
  var _t$dealAdd4 = t.dealAdd(_addedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
3666
- _ads3 = _t$dealAdd4.ads,
3667
- _otherupds3 = _t$dealAdd4.otherupds;
4119
+ _ads3 = _t$dealAdd4.ads,
4120
+ _otherupds3 = _t$dealAdd4.otherupds;
4121
+
3668
4122
  var _t$dealUpdate4 = t.dealUpdate(_updatedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
3669
- _upds3 = _t$dealUpdate4.upds,
3670
- _otherads3 = _t$dealUpdate4.otherads;
3671
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3672
- var _iterator4 = _createForOfIteratorHelper(_deletedDataIDs3),
3673
- _step4;
4123
+ _upds3 = _t$dealUpdate4.upds,
4124
+ _otherads3 = _t$dealUpdate4.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
4125
+
4126
+
4127
+ var _iterator3 = _createForOfIteratorHelper(_deletedDataIDs3),
4128
+ _step3;
4129
+
3674
4130
  try {
3675
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
3676
- var _id3 = _step4.value;
3677
- t.removeGraphic(_id3, 'circle');
3678
- }
3679
- //增加
4131
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
4132
+ var _id2 = _step3.value;
4133
+ t.removeGraphic(_id2, 'circle');
4134
+ } //增加
4135
+
3680
4136
  } catch (err) {
3681
- _iterator4.e(err);
4137
+ _iterator3.e(err);
3682
4138
  } finally {
3683
- _iterator4.f();
4139
+ _iterator3.f();
3684
4140
  }
3685
- t.addCircle([].concat(_toConsumableArray(_ads3), _toConsumableArray(_otherads3)));
3686
- //更新
4141
+
4142
+ t.addCircle([].concat(_toConsumableArray(_ads3), _toConsumableArray(_otherads3))); //更新
4143
+
3687
4144
  t.updateCircle([].concat(_toConsumableArray(_upds3), _toConsumableArray(_otherupds3)));
3688
- }
3689
- //图元编辑调用
4145
+ } //图元编辑调用
4146
+
4147
+
3690
4148
  if (typeof isDoEdit == 'boolean' && isDoEdit || isDoEdit && isDoEdit !== t.props.isDoEdit) {
3691
4149
  t.doEdit(editGraphicId);
3692
- }
3693
- // 获取热力图
4150
+ } // 获取热力图
4151
+
4152
+
3694
4153
  if (heatMapData && heatMapData.data && !t.deepEqual(heatMapData, t.props.heatMapData)) {
3695
4154
  t.heatMapOverlay(heatMapData);
3696
4155
  } else if (!t.deepEqual(heatMapData, t.props.heatMapData)) {
3697
4156
  t.clearHeatMap(heatMapData);
3698
- }
3699
- //清空地图
4157
+ } //清空地图
4158
+
4159
+
3700
4160
  if (typeof isClearAll == 'boolean' && isClearAll || isClearAll && isClearAll !== t.props.isClearAll) {
3701
4161
  t.clearAll();
3702
- }
3703
- //测距工具调用
4162
+ } //测距工具调用
4163
+
4164
+
3704
4165
  if (typeof isRangingTool == 'boolean' && isRangingTool || isRangingTool && isRangingTool !== t.props.isRangingTool) {
3705
4166
  t.vtxRangingTool(mapRangingTool);
3706
4167
  }
3707
4168
  /*设置指定图元展示*/
4169
+
4170
+
3708
4171
  if (typeof setVisiblePoints == 'boolean' && setVisiblePoints || setVisiblePoints && setVisiblePoints !== t.props.setVisiblePoints) {
3709
4172
  t.setVisiblePoints(mapVisiblePoints);
3710
- }
3711
- //设置中心点
4173
+ } //设置中心点
3712
4174
  // if ((typeof (setCenter) == 'boolean' && setCenter) || (setCenter && setCenter !== t.props.setCenter)) {
3713
4175
  // if (!(t.getCurrentCenter().lng == mapCenter[0] && t.getCurrentCenter().lat == mapCenter[1])) {
3714
4176
  // t.setCenter(mapCenter);
3715
4177
  // }
3716
4178
  // }
4179
+
4180
+
3717
4181
  if (nextProps.mapCenter && nextProps.mapCenter.length > 0 && JSON.stringify(nextProps.mapCenter) !== JSON.stringify(this.props.mapCenter)) {
3718
4182
  t.setCenter(mapCenter);
3719
- }
3720
- //设置点聚合
4183
+ } //设置点聚合
4184
+
4185
+
3721
4186
  if (typeof setCluster == 'boolean' && setCluster || setCluster && setCluster !== t.props.setCluster) {
3722
4187
  t.cluster(mapCluster);
3723
4188
  } else if (setCluster !== t.props.setCluster) {
3724
4189
  t.clearCluster();
3725
- }
3726
- //图元编辑调用
4190
+ } //图元编辑调用
4191
+
4192
+
3727
4193
  if (typeof isDoEdit == 'boolean' && isDoEdit || isDoEdit && isDoEdit !== t.props.isDoEdit) {
3728
4194
  t.doEdit(editGraphicId);
3729
- }
3730
- //关闭图元编辑
4195
+ } //关闭图元编辑
4196
+
4197
+
3731
4198
  if (typeof isEndEdit == 'boolean' && isEndEdit || isEndEdit && isEndEdit !== t.props.isEndEdit) {
3732
4199
  t.endEdit();
3733
- }
3734
- //绘制图元
4200
+ } //绘制图元
4201
+
4202
+
3735
4203
  if (typeof isDraw == 'boolean' && isDraw || isDraw && isDraw !== t.props.isDraw) {
3736
4204
  t.draw(mapDraw);
3737
- }
3738
- //关闭绘制
4205
+ } //关闭绘制
4206
+
4207
+
3739
4208
  if (typeof isCloseDraw == 'boolean' && isCloseDraw || isCloseDraw && isCloseDraw !== t.props.isCloseDraw) {
3740
4209
  t.closeDraw();
3741
- }
3742
- //单独删除操作
4210
+ } //单独删除操作
4211
+
4212
+
3743
4213
  if (typeof isRemove == 'boolean' && isRemove || isRemove && isRemove !== t.props.isRemove) {
3744
4214
  mapRemove.map(function (item, index) {
3745
4215
  t.removeGraphic(item.id, item.type);
3746
4216
  });
3747
- }
3748
- //设置区域限制
4217
+ } //设置区域限制
4218
+
4219
+
3749
4220
  if (typeof isSetAreaRestriction == 'boolean' && isSetAreaRestriction || isSetAreaRestriction && isSetAreaRestriction !== t.props.isSetAreaRestriction && areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
3750
4221
  t.setAreaRestriction(areaRestriction);
3751
- }
3752
- //关闭区域限制
4222
+ } //关闭区域限制
4223
+
4224
+
3753
4225
  if (typeof isClearAreaRestriction == 'boolean' && isClearAreaRestriction || isClearAreaRestriction && isClearAreaRestriction !== t.props.isClearAreaRestriction) {
3754
4226
  t.clearAreaRestriction();
3755
- }
3756
- // 设置地图层级
4227
+ } // 设置地图层级
4228
+
4229
+
3757
4230
  if (typeof setZoomLevel == 'boolean' && setZoomLevel || setZoomLevel && setZoomLevel !== t.props.setZoomLevel) {
3758
4231
  t.setZoomLevel(mapZoomLevel);
3759
- }
3760
- // 比例尺控件位置改变
4232
+ } // 比例尺控件位置改变
4233
+
4234
+
3761
4235
  if (nextProps.showControl && JSON.stringify(nextProps.showControl) != JSON.stringify(t.props.showControl)) {
3762
4236
  t.showControl(nextProps);
3763
- }
3764
- // 更新需要加载的图层
4237
+ } // 更新需要加载的图层
4238
+
4239
+
3765
4240
  if (nextProps.olProps && JSON.stringify(nextProps.olProps) !== JSON.stringify(t.props.olProps)) {
3766
4241
  t.loadLayers(nextProps.olProps.olCoverage, t.props.olProps.olCoverage);
3767
4242
  }
3768
- }
3769
- // 地图事件
4243
+ } // 地图事件
3770
4244
  //地图点击事件
4245
+
3771
4246
  }, {
3772
4247
  key: "clickMap",
3773
4248
  value: function clickMap(e) {
3774
4249
  var t = this;
4250
+
3775
4251
  if (typeof t.props.clickMap === 'function') {
3776
4252
  var obj = t.getMapExtent();
3777
4253
  obj.e = e;
@@ -3789,17 +4265,20 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3789
4265
  temp.push(t.getFeatureInfo(e, t.state.gis.getView(), item.layer.getSource()));
3790
4266
  }
3791
4267
  });
4268
+
3792
4269
  if (temp.length) {
3793
4270
  obj.features = temp;
3794
4271
  }
4272
+
3795
4273
  t.props.clickMap(obj);
3796
4274
  }
3797
- }
3798
- // 获取geoServer要素
4275
+ } // 获取geoServer要素
4276
+
3799
4277
  }, {
3800
4278
  key: "getFeatureInfo",
3801
4279
  value: function getFeatureInfo(event, view, source) {
3802
4280
  var _this8 = this;
4281
+
3803
4282
  var sourceParam = source.getParams();
3804
4283
  var url = source.getFeatureInfoUrl(event.coordinate, view.getResolution(), view.getProjection(), {
3805
4284
  cql_filter: sourceParam === null || sourceParam === void 0 ? void 0 : sourceParam.cql_filter,
@@ -3808,41 +4287,49 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3808
4287
  REQUEST: "GetFeatureInfo",
3809
4288
  FEATURE_COUNT: 50
3810
4289
  });
4290
+
3811
4291
  var _this$formatUrl2 = this.formatUrl(url),
3812
- param = _this$formatUrl2.param,
3813
- address = _this$formatUrl2.address;
3814
- // let temp = param.BBOX.split(",");
4292
+ param = _this$formatUrl2.param,
4293
+ address = _this$formatUrl2.address; // let temp = param.BBOX.split(",");
3815
4294
  // let BBOX = [temp[1],temp[0],temp[3],temp[2]].join(",");
3816
4295
  // param.BBOX = BBOX;
4296
+
4297
+
3817
4298
  param.QUERY_LAYERS = param.LAYERS;
3818
4299
  var temp = [];
4300
+
3819
4301
  for (var key in param) {
3820
4302
  temp.push("".concat(key, "=").concat(param[key]));
3821
4303
  }
4304
+
3822
4305
  address += "?".concat(temp.join("&"));
3823
4306
  var geoJsonFormat = new ol.format.GeoJSON();
3824
4307
  return fetch(address).then(function (res) {
3825
4308
  return res.json();
3826
4309
  }).then(function (data) {
3827
4310
  var _data$features;
4311
+
3828
4312
  var features = [];
4313
+
3829
4314
  if (data !== null && data !== void 0 && (_data$features = data.features) !== null && _data$features !== void 0 && _data$features.length) {
3830
4315
  features = geoJsonFormat.readFeatures(data);
3831
4316
  features.map(function (item) {
3832
4317
  item.key = _this8 === null || _this8 === void 0 ? void 0 : _this8.key;
3833
4318
  });
3834
4319
  }
4320
+
3835
4321
  return features;
3836
4322
  })["catch"](function () {
3837
4323
  return [];
3838
4324
  });
3839
- }
3840
- // 要素鼠标悬浮事件
4325
+ } // 要素鼠标悬浮事件
4326
+
3841
4327
  }, {
3842
4328
  key: "mouseOverGraphic",
3843
4329
  value: function mouseOverGraphic(id, e) {
3844
4330
  var t = this;
3845
4331
  if (t.state.editId == id) return false;
4332
+
3846
4333
  if (typeof t.props.mouseOverGraphic === 'function') {
3847
4334
  var obj = {
3848
4335
  e: e,
@@ -3854,14 +4341,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3854
4341
  };
3855
4342
  t.props.mouseOverGraphic(obj);
3856
4343
  }
3857
- }
3858
- // 要素鼠标移开事件
4344
+ } // 要素鼠标移开事件
4345
+
3859
4346
  }, {
3860
4347
  key: "mouseOutGraphic",
3861
4348
  value: function mouseOutGraphic(id, e) {
3862
- var t = this;
3863
- //编辑中的图元关闭其他事件返回
4349
+ var t = this; //编辑中的图元关闭其他事件返回
4350
+
3864
4351
  if (t.state.editId == id) return false;
4352
+
3865
4353
  if (typeof t.props.mouseOutGraphic === 'function') {
3866
4354
  var obj = {
3867
4355
  e: e,
@@ -3873,30 +4361,32 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3873
4361
  };
3874
4362
  t.props.mouseOutGraphic(obj);
3875
4363
  }
3876
- }
3877
- //地图拖动之前事件
4364
+ } //地图拖动之前事件
4365
+
3878
4366
  }, {
3879
4367
  key: "dragMapStart",
3880
4368
  value: function dragMapStart(e) {
3881
4369
  var t = this;
4370
+
3882
4371
  if (typeof t.props.dragMapStart === 'function') {
3883
4372
  var obj = t.getMapExtent();
3884
4373
  obj.e = e;
3885
4374
  t.props.dragMapStart(obj);
3886
4375
  }
3887
- }
3888
- //地图拖动结束后事件
4376
+ } //地图拖动结束后事件
4377
+
3889
4378
  }, {
3890
4379
  key: "dragMapEnd",
3891
4380
  value: function dragMapEnd(e) {
3892
4381
  var t = this;
4382
+
3893
4383
  if (typeof t.props.dragMapEnd === 'function') {
3894
4384
  var obj = t.getMapExtent();
3895
4385
  obj.e = e;
3896
4386
  t.props.dragMapEnd(obj);
3897
4387
  }
3898
- }
3899
- //热力图
4388
+ } //热力图
4389
+
3900
4390
  }, {
3901
4391
  key: "heatMapOverlay",
3902
4392
  value: function heatMapOverlay() {
@@ -3909,23 +4399,28 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3909
4399
  opacity: 0.7,
3910
4400
  gradient: ['#00f', '#0ff', '#0f0', '#ff0', '#f00']
3911
4401
  };
4402
+
3912
4403
  if (d.config) {
3913
4404
  cg = _objectSpread(_objectSpread({}, cg), d.config);
3914
4405
  }
4406
+
3915
4407
  var gradient = [];
4408
+
3916
4409
  if (cg.gradient) {
3917
4410
  for (var key in cg.gradient) {
3918
4411
  gradient.push(cg.gradient[key]);
3919
4412
  }
4413
+
3920
4414
  cg.gradient = gradient;
3921
- }
3922
- // if(d.data){
4415
+ } // if(d.data){
3923
4416
  // t.state.pointIds = [];
3924
4417
  // t.pointLayers.map(item => {
3925
4418
  // t.state.gis.removeLayer(item.layer);
3926
4419
  // t.pointLayers=[];
3927
4420
  // })
3928
4421
  // }
4422
+
4423
+
3929
4424
  var heatData = {
3930
4425
  type: 'FeatureCollection',
3931
4426
  features: (d.data || []).map(function (item) {
@@ -3964,63 +4459,69 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
3964
4459
  if (t.heatmap) t.state.gis.removeLayer(t.heatmap);
3965
4460
  t.heatmap = null;
3966
4461
  t.refresh();
3967
- }
3968
- //地图移动之前事件
4462
+ } //地图移动之前事件
4463
+
3969
4464
  }, {
3970
4465
  key: "moveStart",
3971
4466
  value: function moveStart(e) {
3972
4467
  var t = this;
4468
+
3973
4469
  if (typeof t.props.moveStart === 'function') {
3974
4470
  var obj = t.getMapExtent();
3975
4471
  obj.e = e;
3976
4472
  t.props.moveStart(obj);
3977
4473
  }
3978
- }
3979
- //地图移动结束后事件
4474
+ } //地图移动结束后事件
4475
+
3980
4476
  }, {
3981
4477
  key: "moveEnd",
3982
4478
  value: function moveEnd(e) {
3983
4479
  var t = this;
4480
+
3984
4481
  if (typeof t.props.moveEnd === 'function') {
3985
4482
  var obj = t.getMapExtent();
3986
4483
  obj.e = e;
3987
4484
  t.props.moveEnd(obj);
3988
4485
  }
3989
- }
3990
- //地图更改缩放级别开始时触发触发此事件
4486
+ } //地图更改缩放级别开始时触发触发此事件
4487
+
3991
4488
  }, {
3992
4489
  key: "zoomStart",
3993
4490
  value: function zoomStart(e) {
3994
4491
  var t = this;
4492
+
3995
4493
  if (typeof t.props.zoomStart === 'function') {
3996
4494
  var obj = t.getMapExtent();
3997
4495
  obj.e = e;
3998
4496
  t.props.zoomStart(obj);
3999
4497
  }
4000
- }
4001
- //地图更改缩放级别结束时触发触发此事件
4498
+ } //地图更改缩放级别结束时触发触发此事件
4499
+
4002
4500
  }, {
4003
4501
  key: "zoomEnd",
4004
4502
  value: function zoomEnd(e) {
4005
4503
  var t = this;
4504
+
4006
4505
  if (typeof t.props.zoomEnd === 'function') {
4007
4506
  var obj = t.getMapExtent();
4008
4507
  obj.e = e;
4009
4508
  t.props.zoomEnd(obj);
4010
4509
  }
4011
- }
4012
- // 图元点击事件
4510
+ } // 图元点击事件
4511
+
4013
4512
  }, {
4014
4513
  key: "clickGraphic",
4015
4514
  value: function clickGraphic(id, e) {
4016
4515
  var target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4017
- var t = this;
4018
- //编辑中的图元关闭其他事件返回
4516
+ var t = this; //编辑中的图元关闭其他事件返回
4517
+
4019
4518
  if (t.editId == id) return false;
4519
+
4020
4520
  if (typeof t.props.clickGraphic === 'function') {
4021
4521
  var _e$pixel = _slicedToArray(e.pixel, 2),
4022
- clientX = _e$pixel[0],
4023
- clientY = _e$pixel[1];
4522
+ clientX = _e$pixel[0],
4523
+ clientY = _e$pixel[1];
4524
+
4024
4525
  var param = t.getGraphic(id, clientX, clientY);
4025
4526
  var obj = {
4026
4527
  param: param,
@@ -4044,27 +4545,38 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
4044
4545
  value: function componentWillUnmount() {
4045
4546
  //关闭moveTo定时
4046
4547
  var t = this;
4548
+
4047
4549
  if (t.moveToTimer) {
4048
4550
  clearInterval(t.moveToTimer);
4049
- }
4050
- //关闭animation定时
4551
+ } //关闭animation定时
4552
+
4553
+
4051
4554
  for (var j in t.animTimer) {
4052
4555
  if (t.animTimer[j]) {
4053
4556
  clearInterval(t.animTimer[j]);
4054
4557
  }
4055
4558
  }
4559
+
4056
4560
  window.VtxMap && (window.VtxMap[t.state.mapId] = null);
4057
4561
  }
4058
4562
  }]);
4563
+
4059
4564
  return OlMap;
4060
4565
  }(_react["default"].Component);
4061
- var _default = exports["default"] = OlMap;
4566
+
4567
+ var _default = OlMap;
4568
+ exports["default"] = _default;
4569
+
4062
4570
  var Popup = /*#__PURE__*/function (_React$Component2) {
4063
4571
  _inherits(Popup, _React$Component2);
4572
+
4064
4573
  var _super2 = _createSuper(Popup);
4574
+
4065
4575
  function Popup(props) {
4066
4576
  var _this9;
4577
+
4067
4578
  _classCallCheck(this, Popup);
4579
+
4068
4580
  _this9 = _super2.call(this);
4069
4581
  _this9.map = props.map;
4070
4582
  _this9.position = props.position;
@@ -4073,17 +4585,18 @@ var Popup = /*#__PURE__*/function (_React$Component2) {
4073
4585
  _this9.innerHTML = props.innerHTML;
4074
4586
  _this9.closeble = props.close;
4075
4587
  return _this9;
4076
- }
4588
+ } // 弹出框
4589
+
4077
4590
 
4078
- // 弹出框
4079
4591
  _createClass(Popup, [{
4080
4592
  key: "showPopup",
4081
4593
  value: function showPopup() {
4082
4594
  var t = this;
4083
- this.removePopup();
4084
- // 获取弹出层DOM
4595
+ this.removePopup(); // 获取弹出层DOM
4596
+
4085
4597
  t.container = document.createElement("div");
4086
4598
  t.container['className'] = "ol-popup";
4599
+
4087
4600
  if (t.closeble) {
4088
4601
  var close = document.createElement("a");
4089
4602
  close['className'] = "ol-popup-closer";
@@ -4092,8 +4605,10 @@ var Popup = /*#__PURE__*/function (_React$Component2) {
4092
4605
  });
4093
4606
  t.container.appendChild(close);
4094
4607
  }
4608
+
4095
4609
  var content = document.createElement("div");
4096
4610
  t.container.appendChild(content);
4611
+
4097
4612
  if (t.overlay) {} else {
4098
4613
  // 创建Overlay弹出层绑定DOM
4099
4614
  t.overlay = new ol.Overlay({
@@ -4103,85 +4618,100 @@ var Popup = /*#__PURE__*/function (_React$Component2) {
4103
4618
  duration: 250
4104
4619
  }
4105
4620
  }
4106
- });
4107
- // 添加到map
4621
+ }); // 添加到map
4622
+
4108
4623
  t.map.addOverlay(t.overlay);
4109
- }
4110
- // 弹出层内容
4111
- content.innerHTML = t.innerHTML;
4112
- // 设置弹出层位置即可出现
4624
+ } // 弹出层内容
4625
+
4626
+
4627
+ content.innerHTML = t.innerHTML; // 设置弹出层位置即可出现
4628
+
4113
4629
  t.overlay.setPosition(t.position);
4114
- }
4115
- // 清除弹出框
4630
+ } // 清除弹出框
4631
+
4116
4632
  }, {
4117
4633
  key: "removePopup",
4118
4634
  value: function removePopup() {
4119
4635
  if (this.overlay) {
4120
- this.container.remove();
4121
- // 设置位置undefined可达到隐藏清除弹出框
4636
+ this.container.remove(); // 设置位置undefined可达到隐藏清除弹出框
4637
+
4122
4638
  this.overlay.setPosition(undefined);
4123
4639
  this.overlay = null;
4124
4640
  }
4125
4641
  }
4126
4642
  }]);
4643
+
4127
4644
  return Popup;
4128
4645
  }(_react["default"].Component);
4646
+
4129
4647
  function getRgbColor(color, opacity) {
4130
4648
  var reg = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;
4649
+
4131
4650
  if (!reg.test(color) && typeof color !== 'string') {
4132
4651
  return;
4133
4652
  }
4653
+
4134
4654
  var newStr = color.toLowerCase().replace(/\#/g, '');
4135
4655
  var len = newStr.length;
4656
+
4136
4657
  if (len == 3) {
4137
4658
  var t = '';
4659
+
4138
4660
  for (var i = 0; i < len; i++) {
4139
4661
  t += newStr.slice(i, i + 1).concat(newStr.slice(i, i + 1));
4140
4662
  }
4663
+
4141
4664
  newStr = t;
4142
4665
  }
4666
+
4143
4667
  var arr = []; //将字符串分隔,两个两个的分隔
4668
+
4144
4669
  for (var i = 0; i < 6; i = i + 2) {
4145
4670
  var s = newStr.slice(i, i + 2);
4146
4671
  arr.push(parseInt('0x' + s));
4147
4672
  }
4673
+
4148
4674
  return 'rgba(' + arr.join(',') + ',' + opacity + ')';
4149
- }
4675
+ } // 压缩图片的方法
4676
+
4150
4677
 
4151
- // 压缩图片的方法
4152
4678
  function canvasDataURL(path, obj, callback) {
4153
4679
  var img = new Image();
4154
4680
  img.src = path;
4155
4681
  img.setAttribute("crossOrigin", 'Anonymous');
4682
+
4156
4683
  img.onload = function () {
4157
- var that = this;
4158
- // 默认按比例压缩
4684
+ var that = this; // 默认按比例压缩
4685
+
4159
4686
  var w = that.width,
4160
- h = that.height,
4161
- scale = w / h;
4687
+ h = that.height,
4688
+ scale = w / h;
4162
4689
  w = obj.width || w;
4163
4690
  h = obj.height || w / scale;
4164
4691
  var quality = 0.7; // 默认图片质量为0.7
4165
4692
  //生成canvas
4693
+
4166
4694
  var canvas = document.createElement('canvas');
4167
- var ctx = canvas.getContext('2d');
4168
- // 创建属性节点
4695
+ var ctx = canvas.getContext('2d'); // 创建属性节点
4696
+
4169
4697
  var anw = document.createAttribute("width");
4170
4698
  anw.nodeValue = w;
4171
4699
  var anh = document.createAttribute("height");
4172
4700
  anh.nodeValue = h;
4173
4701
  canvas.setAttributeNode(anw);
4174
4702
  canvas.setAttributeNode(anh);
4175
- ctx.drawImage(that, 0, 0, w, h);
4176
- // 图像质量
4703
+ ctx.drawImage(that, 0, 0, w, h); // 图像质量
4704
+
4177
4705
  if (obj.quality && obj.quality <= 1 && obj.quality > 0) {
4178
4706
  quality = obj.quality;
4179
- }
4180
- // quality值越小,所绘制出的图像越模糊
4181
- var base64 = canvas.toDataURL('image/png', quality);
4182
- // 回调函数返回base64的值
4707
+ } // quality值越小,所绘制出的图像越模糊
4708
+
4709
+
4710
+ var base64 = canvas.toDataURL('image/png', quality); // 回调函数返回base64的值
4711
+
4183
4712
  callback(base64);
4184
4713
  };
4185
4714
  }
4715
+
4186
4716
  module.exports = exports["default"];
4187
4717
  //# sourceMappingURL=Map.js.map