@vtx/map 1.1.49 → 1.1.51

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