@vtx/map 1.1.36 → 1.1.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/lib/VtxMap/AMap/AMap.js +1014 -624
  2. package/lib/VtxMap/AMap/AMap.js.map +1 -1
  3. package/lib/VtxMap/BMap/Map.js +1207 -746
  4. package/lib/VtxMap/BMap/Map.js.map +1 -1
  5. package/lib/VtxMap/GMap/Map.js +1564 -1046
  6. package/lib/VtxMap/GMap/Map.js.map +1 -1
  7. package/lib/VtxMap/Map.js +42 -8
  8. package/lib/VtxMap/Map.js.map +1 -1
  9. package/lib/VtxMap/MapToolFunction.js +63 -26
  10. package/lib/VtxMap/MapToolFunction.js.map +1 -1
  11. package/lib/VtxMap/OMap/Map.js +1361 -867
  12. package/lib/VtxMap/OMap/Map.js.map +1 -1
  13. package/lib/VtxMap/OlMap/Map.js +1276 -746
  14. package/lib/VtxMap/OlMap/Map.js.map +1 -1
  15. package/lib/VtxMap/TMap/TMap.js +1072 -645
  16. package/lib/VtxMap/TMap/TMap.js.map +1 -1
  17. package/lib/VtxMap/index.js +8 -1
  18. package/lib/VtxMap/index.js.map +1 -1
  19. package/lib/VtxMap/mapPlayer.js +123 -67
  20. package/lib/VtxMap/mapPlayer.js.map +1 -1
  21. package/lib/VtxMap/optimizingPointMap.js +77 -21
  22. package/lib/VtxMap/optimizingPointMap.js.map +1 -1
  23. package/lib/VtxMap/style/css.js +6 -0
  24. package/lib/VtxMap/style/css.js.map +1 -1
  25. package/lib/VtxMap/style/index.js +6 -0
  26. package/lib/VtxMap/style/index.js.map +1 -1
  27. package/lib/VtxMap/zoomMap.js +41 -12
  28. package/lib/VtxMap/zoomMap.js.map +1 -1
  29. package/lib/VtxModal/VtxModal.js +63 -19
  30. package/lib/VtxModal/VtxModal.js.map +1 -1
  31. package/lib/VtxModal/draggableModal.js +48 -12
  32. package/lib/VtxModal/draggableModal.js.map +1 -1
  33. package/lib/VtxModal/index.js +6 -1
  34. package/lib/VtxModal/index.js.map +1 -1
  35. package/lib/VtxModal/style/css.js +6 -0
  36. package/lib/VtxModal/style/css.js.map +1 -1
  37. package/lib/VtxModal/style/index.js +6 -0
  38. package/lib/VtxModal/style/index.js.map +1 -1
  39. package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js +238 -105
  40. package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js.map +1 -1
  41. package/lib/VtxSearchCheckMap/index.js +2 -0
  42. package/lib/VtxSearchCheckMap/index.js.map +1 -1
  43. package/lib/VtxSearchCheckMap/mapping.js +2 -1
  44. package/lib/VtxSearchCheckMap/mapping.js.map +1 -1
  45. package/lib/VtxSearchCheckMap/style/css.js +19 -0
  46. package/lib/VtxSearchCheckMap/style/css.js.map +1 -1
  47. package/lib/VtxSearchCheckMap/style/index.js +19 -0
  48. package/lib/VtxSearchCheckMap/style/index.js.map +1 -1
  49. package/lib/VtxSearchMap/VtxSearchMap.js +221 -91
  50. package/lib/VtxSearchMap/VtxSearchMap.js.map +1 -1
  51. package/lib/VtxSearchMap/index.js +2 -0
  52. package/lib/VtxSearchMap/index.js.map +1 -1
  53. package/lib/VtxSearchMap/mapping.js +2 -1
  54. package/lib/VtxSearchMap/mapping.js.map +1 -1
  55. package/lib/VtxSearchMap/style/css.js +19 -0
  56. package/lib/VtxSearchMap/style/css.js.map +1 -1
  57. package/lib/VtxSearchMap/style/index.js +19 -0
  58. package/lib/VtxSearchMap/style/index.js.map +1 -1
  59. package/lib/default.js +13 -4
  60. package/lib/default.js.map +1 -1
  61. package/lib/index.js +3 -0
  62. package/lib/index.js.map +1 -1
  63. package/package.json +1 -1
@@ -1,51 +1,84 @@
1
1
  "use strict";
2
2
 
3
- 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); }
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
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports["default"] = void 0;
9
+
8
10
  var _react = _interopRequireDefault(require("react"));
11
+
9
12
  var _reactDom = require("react-dom");
13
+
10
14
  var _MapToolFunction = require("../MapToolFunction");
15
+
11
16
  var _immutable = _interopRequireDefault(require("immutable"));
17
+
12
18
  var _default2 = _interopRequireDefault(require("../../default"));
19
+
13
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
+
14
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(_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; } } }; }
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 _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
29
+
18
30
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
31
+
19
32
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
20
- 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; }
21
- 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; }
22
- 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; }
23
- 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; }
33
+
34
+ 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; }
35
+
36
+ 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; }
37
+
38
+ 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; }
39
+
40
+ 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; }
41
+
24
42
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
- 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); } }
43
+
44
+ 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); } }
45
+
26
46
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
27
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
28
- 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); }
47
+
29
48
  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); }
49
+
30
50
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
51
+
31
52
  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); }; }
53
+
32
54
  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); }
55
+
33
56
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
57
+
34
58
  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; } }
35
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } //公共地址配置
59
+
60
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
61
+
36
62
  var Set = _immutable["default"].Set;
63
+
37
64
  var VortexAMap = /*#__PURE__*/function (_React$Component) {
38
65
  _inherits(VortexAMap, _React$Component);
66
+
39
67
  var _super = _createSuper(VortexAMap);
68
+
40
69
  function VortexAMap(props) {
41
70
  var _this;
71
+
42
72
  _classCallCheck(this, VortexAMap);
43
- _this = _super.call(this, props);
44
- //初始化 图元管理方法
73
+
74
+ _this = _super.call(this, props); //初始化 图元管理方法
75
+
45
76
  _this.GM = new _MapToolFunction.graphicManage();
46
77
  _this.getPolygonArea = _MapToolFunction.getPolygonArea;
47
78
  _this.pointCollectionId = 'vtx_gmap_html_pointCollection'; //海量点canvas点位容器id class管理
79
+
48
80
  _this.morepoints = []; //海量点集合
81
+
49
82
  _this.htmlXY = {
50
83
  x: 0,
51
84
  y: 0,
@@ -54,22 +87,38 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
54
87
  isCount: false
55
88
  };
56
89
  _this.stopMove = true; //防止zoom事件触发时,联动的触发move事件
90
+
57
91
  _this.mapLeft = 0; //地图offset的Left值
92
+
58
93
  _this.mapTop = 0; //地图offset的Top值
94
+
59
95
  _this.clusterObj = null; //聚合点类对象
96
+
60
97
  _this.trafficLayer = null; //路况类对象
98
+
61
99
  _this.scale = null; //比例尺控件对象
100
+
62
101
  _this.tool = null; //比例尺工具对象
102
+
63
103
  _this.ruler = null; //测距对象
104
+
64
105
  _this.mousetool = null; //绘制图元对象
106
+
65
107
  _this.districeSearch = null; //行政区划搜索对象
108
+
66
109
  _this.polyEdit = null; //折线和多边形编辑对象
110
+
67
111
  _this.circleEdit = null; //圆编辑对象
112
+
68
113
  _this.editTimeout = null; //圆编辑时的延迟回调,避免重复调用
114
+
69
115
  _this.heatmap = null; //热力图对象
116
+
70
117
  _this.satellite = null; //底图图层对象-卫星图
118
+
71
119
  _this.roadNet = null; //路网图层对象
72
120
  //为了样式相同,引用百度的鼠标样式
121
+
73
122
  _this.csr = /webkit/.test(navigator.userAgent.toLowerCase()) ? 'url("http://api.map.baidu.com/images/ruler.cur") 3 6, crosshair' : 'url("http://api.map.baidu.com/images/ruler.cur"), crosshair';
74
123
  _this.state = {
75
124
  gis: null,
@@ -108,9 +157,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
108
157
  br: 'RB'
109
158
  };
110
159
  _this.frameSelectProps = {};
160
+
111
161
  _this.loadMapJs();
162
+
112
163
  return _this;
113
164
  }
165
+
114
166
  _createClass(VortexAMap, [{
115
167
  key: "loadMapJs",
116
168
  value: function loadMapJs() {
@@ -129,6 +181,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
129
181
  (function setTime() {
130
182
  var allEvents = [window.AMap, 'MarkerClusterer', 'MapType', 'Scale', 'ToolBar', 'DistrictSearch', 'RangingTool', 'MouseTool', 'PolyEditor', 'CircleEditor', 'PlaceSearch', 'Heatmap'];
131
183
  var isLoading = true;
184
+
132
185
  for (var i = 0; i <= allEvents.length - 1; i++) {
133
186
  if (i === 0) {
134
187
  if (!allEvents[i]) {
@@ -142,6 +195,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
142
195
  }
143
196
  }
144
197
  }
198
+
145
199
  if (isLoading) {
146
200
  resolve(window.AMap);
147
201
  } else {
@@ -155,145 +209,164 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
155
209
  });
156
210
  }
157
211
  });
158
- }
159
- //初始化地图
212
+ } //初始化地图
213
+
160
214
  }, {
161
215
  key: "init",
162
216
  value: function init() {
163
217
  var t = this;
164
218
  var _t$props = t.props,
165
- mapPoints = _t$props.mapPoints,
166
- mapLines = _t$props.mapLines,
167
- mapPolygons = _t$props.mapPolygons,
168
- mapCircles = _t$props.mapCircles,
169
- imageOverlays = _t$props.imageOverlays,
170
- setVisiblePoints = _t$props.setVisiblePoints,
171
- mapVisiblePoints = _t$props.mapVisiblePoints,
172
- mapCenter = _t$props.mapCenter,
173
- mapZoomLevel = _t$props.mapZoomLevel,
174
- mapCluster = _t$props.mapCluster,
175
- mapPointCollection = _t$props.mapPointCollection,
176
- showControl = _t$props.showControl,
177
- boundaryName = _t$props.boundaryName,
178
- heatMapData = _t$props.heatMapData,
179
- areaRestriction = _t$props.areaRestriction,
180
- coverageType = _t$props.coverageType,
181
- infoWindowData = _t$props.infoWindowData;
182
- // 切换地图矢量图和卫星图背景
219
+ mapPoints = _t$props.mapPoints,
220
+ mapLines = _t$props.mapLines,
221
+ mapPolygons = _t$props.mapPolygons,
222
+ mapCircles = _t$props.mapCircles,
223
+ imageOverlays = _t$props.imageOverlays,
224
+ setVisiblePoints = _t$props.setVisiblePoints,
225
+ mapVisiblePoints = _t$props.mapVisiblePoints,
226
+ mapCenter = _t$props.mapCenter,
227
+ mapZoomLevel = _t$props.mapZoomLevel,
228
+ mapCluster = _t$props.mapCluster,
229
+ mapPointCollection = _t$props.mapPointCollection,
230
+ showControl = _t$props.showControl,
231
+ boundaryName = _t$props.boundaryName,
232
+ heatMapData = _t$props.heatMapData,
233
+ areaRestriction = _t$props.areaRestriction,
234
+ coverageType = _t$props.coverageType,
235
+ infoWindowData = _t$props.infoWindowData; // 切换地图矢量图和卫星图背景
236
+
183
237
  if (coverageType) {
184
238
  t.setMapType(coverageType);
185
- }
186
- //创建地图
187
- t.createMap();
188
- //初始化中心点
189
- t.setCenter(mapCenter);
190
- //添加点
239
+ } //创建地图
240
+
241
+
242
+ t.createMap(); //初始化中心点
243
+
244
+ t.setCenter(mapCenter); //添加点
245
+
191
246
  if (mapPoints instanceof Array) {
192
247
  t.addPoint(mapPoints);
193
- }
194
- //添加线
248
+ } //添加线
249
+
250
+
195
251
  if (mapLines instanceof Array) {
196
252
  t.addLine(mapLines);
197
- }
198
- //添加面
253
+ } //添加面
254
+
255
+
199
256
  if (mapPolygons instanceof Array) {
200
257
  t.addPolygon(mapPolygons);
201
- }
202
- //添加圆
258
+ } //添加圆
259
+
260
+
203
261
  if (mapCircles instanceof Array) {
204
262
  t.addCircle(mapCircles);
205
- }
206
- //添加图片图层
263
+ } //添加图片图层
264
+
265
+
207
266
  if (imageOverlays instanceof Array) {
208
267
  t.imageUrlOverlay(imageOverlays);
209
268
  }
210
269
  /*设置指定图元展示*/
270
+
271
+
211
272
  if (mapVisiblePoints) {
212
273
  t.setVisiblePoints(mapVisiblePoints);
213
- }
214
- //设置比例尺
274
+ } //设置比例尺
275
+
276
+
215
277
  if (mapZoomLevel) {
216
278
  t.setZoomLevel(mapZoomLevel);
217
- }
218
- //设置点聚合
279
+ } //设置点聚合
280
+
281
+
219
282
  if (mapCluster) {
220
283
  t.cluster(mapCluster);
221
- }
222
- //展示比例尺
284
+ } //展示比例尺
285
+
286
+
223
287
  if (showControl) {
224
288
  t.showControl();
225
- }
226
- //添加地图类型控件
289
+ } //添加地图类型控件
290
+
291
+
227
292
  if (t.props.satelliteSwitch) {
228
293
  t.showMapTypeControl();
229
- }
230
- //画边界线
294
+ } //画边界线
295
+
296
+
231
297
  if (boundaryName instanceof Array && boundaryName.length > 0) {
232
298
  t.addBaiduBoundary(boundaryName);
233
- }
299
+ } //回调显示方法
300
+
234
301
 
235
- //回调显示方法
236
302
  if (t.props.showGraphicById) {
237
303
  t.props.showGraphicById(t.showGraphicById.bind(t));
238
- }
239
- //回调隐藏方法
304
+ } //回调隐藏方法
305
+
306
+
240
307
  if (t.props.hideGraphicById) {
241
308
  t.props.hideGraphicById(t.hideGraphicById.bind(t));
242
- }
243
- //设置区域限制
309
+ } //设置区域限制
310
+
311
+
244
312
  if (areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
245
313
  t.setAreaRestriction(areaRestriction);
246
- }
247
- // 画热力图
314
+ } // 画热力图
315
+
316
+
248
317
  if (heatMapData) {
249
318
  t.heatMapOverlay(heatMapData);
250
- }
251
- // 打开信息窗体
319
+ } // 打开信息窗体
320
+
321
+
252
322
  if (infoWindowData) {
253
323
  t.infoWindow(infoWindowData);
254
- }
255
- //添加海量点
324
+ } //添加海量点
325
+
326
+
256
327
  if (mapPointCollection instanceof Array) {
257
328
  t.addPointCollection(mapPointCollection);
258
- }
259
- //初始化地图拖拽开始事件
260
- t.dragMapStart();
261
- //初始化地图拖拽结束事件
262
- t.dragMapEnd();
263
- //初始化地图移动开始事件
264
- t.moveStart();
265
- //初始化地图移动结束事件
266
- t.moveEnd();
267
- //初始化地图zoom改变开始事件
268
- t.zoomStart();
269
- //初始化地图zoom改变结束事件
270
- t.zoomEnd();
271
- //初始化地图点击事件
329
+ } //初始化地图拖拽开始事件
330
+
331
+
332
+ t.dragMapStart(); //初始化地图拖拽结束事件
333
+
334
+ t.dragMapEnd(); //初始化地图移动开始事件
335
+
336
+ t.moveStart(); //初始化地图移动结束事件
337
+
338
+ t.moveEnd(); //初始化地图zoom改变开始事件
339
+
340
+ t.zoomStart(); //初始化地图zoom改变结束事件
341
+
342
+ t.zoomEnd(); //初始化地图点击事件
343
+
272
344
  t.clickMap();
273
345
  t.setState({
274
346
  mapCreated: true
275
347
  });
276
- }
277
- //地图方法
348
+ } //地图方法
349
+
278
350
  }, {
279
351
  key: "createMap",
280
352
  value: function createMap(divId) {
281
353
  var t = this;
282
354
  var _t$props2 = t.props,
283
- viewMode = _t$props2.viewMode,
284
- mapStyle = _t$props2.mapStyle,
285
- mapCenter = _t$props2.mapCenter,
286
- mapId = _t$props2.mapId,
287
- mapZoomLevel = _t$props2.mapZoomLevel,
288
- minZoom = _t$props2.minZoom,
289
- maxZoom = _t$props2.maxZoom;
290
- //缓存Map的对象,方便后期的功能操作
355
+ viewMode = _t$props2.viewMode,
356
+ mapStyle = _t$props2.mapStyle,
357
+ mapCenter = _t$props2.mapCenter,
358
+ mapId = _t$props2.mapId,
359
+ mapZoomLevel = _t$props2.mapZoomLevel,
360
+ minZoom = _t$props2.minZoom,
361
+ maxZoom = _t$props2.maxZoom; //缓存Map的对象,方便后期的功能操作
291
362
  //后期不会操作gis数据,直接通过state缓存.
363
+
292
364
  if (window.VtxMap) {
293
365
  window.VtxMap[mapId] = null;
294
366
  } else {
295
367
  window.VtxMap = {};
296
368
  }
369
+
297
370
  window.VtxMap[mapId] = t.state.gis = new AMap.Map(mapId.toString(), {
298
371
  viewMode: viewMode ? viewMode : '2D',
299
372
  resizeEnable: true,
@@ -303,17 +376,21 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
303
376
  center: mapCenter && mapCenter instanceof Array && mapCenter.length == 2 ? mapCenter : [116.400433, 39.906705],
304
377
  zooms: [minZoom || 3, maxZoom || 18]
305
378
  });
379
+
306
380
  if (mapStyle) {
307
381
  t.state.gis.setMapStyle(mapStyle);
308
- }
309
- //聚合点类对象
310
- t.clusterObj = new AMap.MarkerClusterer(t.state.gis, []);
311
- //比例尺控件对象
382
+ } //聚合点类对象
383
+
384
+
385
+ t.clusterObj = new AMap.MarkerClusterer(t.state.gis, []); //比例尺控件对象
386
+
312
387
  /*算出比例尺位置偏移量*/
388
+
313
389
  var offsetS = new AMap.Pixel(60, 17);
314
390
  var offsetT = new AMap.Pixel(25, 10);
315
391
  var zlt = 'RB';
316
392
  var zls = 'RB';
393
+
317
394
  if (t.props.showControl) {
318
395
  switch (t.props.showControl.location) {
319
396
  case 'tl':
@@ -322,30 +399,35 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
322
399
  offsetS = new AMap.Pixel(10, 17);
323
400
  offsetT = new AMap.Pixel(5, 10);
324
401
  break;
402
+
325
403
  case 'bl':
326
404
  zlt = 'LB';
327
405
  zls = 'LB';
328
406
  offsetS = new AMap.Pixel(60, 19);
329
407
  offsetT = new AMap.Pixel(5, 12);
330
408
  break;
409
+
331
410
  case 'tr':
332
411
  zlt = 'RT';
333
412
  zls = 'RB';
334
413
  offsetS = new AMap.Pixel(25, 17);
335
414
  offsetT = new AMap.Pixel(25, 10);
336
415
  break;
416
+
337
417
  case 'br':
338
418
  zlt = 'RB';
339
419
  zls = 'RB';
340
420
  offsetS = new AMap.Pixel(70, 17);
341
421
  offsetT = new AMap.Pixel(25, 10);
342
422
  break;
343
- }
344
- //默认是all
423
+ } //默认是all
424
+
425
+
345
426
  var tp = {
346
427
  ruler: true,
347
428
  direction: true
348
429
  };
430
+
349
431
  switch (t.props.showControl.type) {
350
432
  case 'small':
351
433
  tp = {
@@ -353,12 +435,14 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
353
435
  direction: true
354
436
  };
355
437
  break;
438
+
356
439
  case 'pan':
357
440
  tp = {
358
441
  ruler: false,
359
442
  direction: true
360
443
  };
361
444
  break;
445
+
362
446
  case 'zoom':
363
447
  tp = {
364
448
  ruler: false,
@@ -366,54 +450,59 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
366
450
  };
367
451
  break;
368
452
  }
453
+
369
454
  t.scale = new AMap.Scale({
370
455
  position: zls,
371
456
  offset: offsetS
372
- });
373
- //比例尺工具对象
457
+ }); //比例尺工具对象
458
+
374
459
  t.tool = new AMap.ToolBar(_objectSpread({
375
460
  position: zlt,
376
461
  offset: offsetT,
377
462
  locate: false
378
463
  }, tp));
379
- }
380
- //搜索服务
464
+ } //搜索服务
465
+
466
+
381
467
  var opts = {
382
468
  subdistrict: 1,
383
469
  //返回下一级行政区
384
470
  extensions: 'all',
385
471
  //返回行政区边界坐标组等具体信息
386
472
  level: 'district' //查询行政级别为 市
387
- };
388
- //实例化DistrictSearch
389
- t.districeSearch = new AMap.DistrictSearch(opts);
390
- //实例化RangingTool
473
+
474
+ }; //实例化DistrictSearch
475
+
476
+ t.districeSearch = new AMap.DistrictSearch(opts); //实例化RangingTool
477
+
391
478
  t.ruler = new AMap.RangingTool(t.state.gis);
392
479
  t.ruler.on('end', function (_ref) {
393
480
  var type = _ref.type,
394
- polyline = _ref.polyline,
395
- points = _ref.points,
396
- distance = _ref.distance;
481
+ polyline = _ref.polyline,
482
+ points = _ref.points,
483
+ distance = _ref.distance;
397
484
  var lnglats = points.map(function (item, index) {
398
485
  return [item.lng, item.lat];
399
- });
400
- //恢复鼠标默认样式
486
+ }); //恢复鼠标默认样式
487
+
401
488
  t.state.gis.setDefaultCursor();
402
489
  t.ruler.turnOff();
490
+
403
491
  if (typeof t.props.mapRangingTool === "function") {
404
492
  t.props.mapRangingTool({
405
493
  distance: distance,
406
494
  lnglats: lnglats
407
495
  });
408
496
  }
409
- });
410
- //绘制图元类
411
- t.mousetool = new AMap.MouseTool(t.state.gis);
412
- //绘制完后的回调
497
+ }); //绘制图元类
498
+
499
+ t.mousetool = new AMap.MouseTool(t.state.gis); //绘制完后的回调
500
+
413
501
  t.mousetool.on('draw', function (_ref2) {
414
502
  var _t$frameSelectProps$b;
503
+
415
504
  var type = _ref2.type,
416
- obj = _ref2.obj;
505
+ obj = _ref2.obj;
417
506
  var drawExtData = obj.getExtData();
418
507
  var backobj = {
419
508
  id: drawExtData.id,
@@ -423,11 +512,11 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
423
512
  geometry: {
424
513
  type: drawExtData.type == 'rectangle' ? 'polygon' : drawExtData.type
425
514
  }
426
- };
427
- //缓存绘制的图元信息
515
+ }; //缓存绘制的图元信息
516
+
428
517
  t.GM.setGraphic(drawExtData.id, obj);
429
- t.GM.setGraphicParam(drawExtData.id, backobj);
430
- //添加点击事件
518
+ t.GM.setGraphicParam(drawExtData.id, backobj); //添加点击事件
519
+
431
520
  obj.on('click', function (e) {
432
521
  t.clickGraphic(drawExtData.id, e);
433
522
  });
@@ -436,50 +525,57 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
436
525
  });
437
526
  obj.on('mouseout', function (e) {
438
527
  t.mouseOutGraphic(drawExtData.id, e);
439
- });
528
+ }); //区别点和圆的经纬度数据处理
440
529
 
441
- //区别点和圆的经纬度数据处理
442
530
  var _t$dealData = t.dealData(obj),
443
- lnglatAry = _t$dealData.lnglatAry,
444
- _extent = _t$dealData._extent,
445
- path = _t$dealData.path;
446
- //处理返回数据
531
+ lnglatAry = _t$dealData.lnglatAry,
532
+ _extent = _t$dealData._extent,
533
+ path = _t$dealData.path; //处理返回数据
534
+
535
+
447
536
  switch (drawExtData.type) {
448
537
  case 'point':
449
538
  backobj.geometry.x = obj.getPosition().getLng();
450
539
  backobj.geometry.y = obj.getPosition().getLat();
451
540
  break;
541
+
452
542
  case 'polyline':
453
543
  backobj.lnglatAry = lnglatAry;
454
544
  backobj.geometry.paths = path;
455
545
  backobj.geometry._extent = _extent;
456
546
  backobj.distance = obj.getLength();
457
547
  break;
548
+
458
549
  case 'polygon':
459
550
  backobj.area = obj.getArea();
460
551
  backobj.lnglatAry = lnglatAry;
461
552
  backobj.geometry.rings = path;
462
553
  backobj.geometry._extent = _extent;
463
554
  break;
555
+
464
556
  case 'rectangle':
465
557
  backobj.area = obj.getArea();
466
558
  backobj.lnglatAry = lnglatAry;
467
559
  backobj.geometry.rings = path;
468
560
  backobj.geometry._extent = _extent;
469
561
  break;
562
+
470
563
  case 'circle':
471
564
  backobj.geometry.x = obj.getCenter().getLng();
472
565
  backobj.geometry.y = obj.getCenter().getLat();
473
566
  backobj.geometry.radius = obj.getRadius();
474
567
  backobj.area = Math.PI * Math.pow(backobj.geometry.radius, 2);
475
568
  break;
476
- }
477
- //恢复鼠标默认样式
569
+ } //恢复鼠标默认样式
570
+
571
+
478
572
  t.state.gis.setDefaultCursor();
479
573
  t.mousetool.close();
574
+
480
575
  if ('drawEnd' in t.props) {
481
576
  t.props.drawEnd(backobj);
482
577
  }
578
+
483
579
  if (((_t$frameSelectProps$b = t.frameSelectProps[backobj.id]) === null || _t$frameSelectProps$b === void 0 ? void 0 : _t$frameSelectProps$b.callback) instanceof Function) {
484
580
  t.frameSelectProps[backobj.id].callback(backobj);
485
581
  }
@@ -496,41 +592,46 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
496
592
  }
497
593
  });
498
594
  t.initPropsForUser();
499
- }
500
- // 初始化对外方法
595
+ } // 初始化对外方法
596
+
501
597
  }, {
502
598
  key: "initPropsForUser",
503
599
  value: function initPropsForUser() {
504
600
  var t = this;
601
+
505
602
  t.state.gis["frameSelect"] = function () {
506
603
  var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
507
604
  var callback = arguments.length > 1 ? arguments[1] : undefined;
508
605
  return t.frameSelect(obj, callback);
509
606
  };
607
+
510
608
  t.state.gis["clearFrameSelect"] = function () {
511
609
  return t.clearFrameSelect();
512
610
  };
611
+
513
612
  t.state.gis["clearFrameSelectById"] = function (id) {
514
613
  return t.clearFrameSelectById(id);
515
614
  };
516
- }
517
- // 框选
615
+ } // 框选
616
+
518
617
  }, {
519
618
  key: "frameSelect",
520
619
  value: function frameSelect(_ref3, callback) {
521
620
  var geometryType = _ref3.geometryType,
522
- _ref3$parameter = _ref3.parameter,
523
- parameter = _ref3$parameter === void 0 ? {} : _ref3$parameter,
524
- _ref3$data = _ref3.data,
525
- data = _ref3$data === void 0 ? {} : _ref3$data;
621
+ _ref3$parameter = _ref3.parameter,
622
+ parameter = _ref3$parameter === void 0 ? {} : _ref3$parameter,
623
+ _ref3$data = _ref3.data,
624
+ data = _ref3$data === void 0 ? {} : _ref3$data;
625
+
526
626
  if (!['polygon', 'circle', 'rectangle'].includes(geometryType)) {
527
627
  message.warn("传入的类型不支持框选!");
528
628
  return false;
529
629
  }
630
+
530
631
  var t = this;
531
632
  var params = {},
532
- type = geometryType || 'polygon',
533
- id = data.id || "frameSelectFeature_".concat(Math.random());
633
+ type = geometryType || 'polygon',
634
+ id = data.id || "frameSelectFeature_".concat(Math.random());
534
635
  params.color = parameter.color || 'red';
535
636
  params.lineColor = parameter.lineColor || 'red';
536
637
  params.lineOpacity = parameter.lineOpacity || 1;
@@ -549,17 +650,18 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
549
650
  id: id,
550
651
  type: geometryType
551
652
  };
552
- }
553
- // 清除框选
653
+ } // 清除框选
654
+
554
655
  }, {
555
656
  key: "clearFrameSelect",
556
657
  value: function clearFrameSelect() {
557
658
  for (var key in this.frameSelectProps) {
558
659
  this.removeGraphic(this.frameSelectProps[key].id, this.frameSelectProps[key].type);
559
660
  }
661
+
560
662
  this.frameSelectProps = {};
561
- }
562
- // 清除框选ById
663
+ } // 清除框选ById
664
+
563
665
  }, {
564
666
  key: "clearFrameSelectById",
565
667
  value: function clearFrameSelectById(id) {
@@ -570,6 +672,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
570
672
  /*
571
673
  切换地图矢量图和卫星图背景
572
674
  */
675
+
573
676
  }, {
574
677
  key: "setMapType",
575
678
  value: function setMapType(type) {
@@ -581,58 +684,62 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
581
684
  map: this.state.gis
582
685
  });
583
686
  }
687
+
584
688
  switch (type) {
585
689
  case 'sl':
586
690
  this.satellite.hide();
587
691
  this.roadNet.hide();
588
692
  break;
693
+
589
694
  case 'wx':
590
695
  this.satellite.show();
591
696
  this.roadNet.show();
592
697
  break;
593
698
  }
594
- }
595
- //增加图片图层
699
+ } //增加图片图层
700
+
596
701
  }, {
597
702
  key: "imageUrlOverlay",
598
703
  value: function imageUrlOverlay(imageAry) {
599
704
  var t = this;
600
705
  imageAry.map(function (item, index) {
601
706
  var sw = item.sw,
602
- ne = item.ne,
603
- url = item.url,
604
- opacity = item.opacity,
605
- displayOnMinLevel = item.displayOnMinLevel,
606
- displayOnMaxLevel = item.displayOnMaxLevel;
707
+ ne = item.ne,
708
+ url = item.url,
709
+ opacity = item.opacity,
710
+ displayOnMinLevel = item.displayOnMinLevel,
711
+ displayOnMaxLevel = item.displayOnMaxLevel;
712
+
607
713
  if (!url) {
608
714
  console.warn("\u56FE\u7247\u56FE\u5C42url\u6570\u636E\u9519\u8BEF");
609
715
  return false;
610
716
  }
717
+
611
718
  if (sw && ne && Array.isArray(sw) && Array.isArray(ne) && sw[0] && sw[1] && ne[0] && ne[1]) {
612
719
  var swnep = new AMap.Bounds(sw, ne),
613
- imageUrlOverlay = new AMap.ImageLayer({
614
- url: url,
615
- zooms: [displayOnMinLevel || 3, displayOnMaxLevel || 18],
616
- bounds: swnep
617
- });
720
+ imageUrlOverlay = new AMap.ImageLayer({
721
+ url: url,
722
+ zooms: [displayOnMinLevel || 3, displayOnMaxLevel || 18],
723
+ bounds: swnep
724
+ });
618
725
  t.state.gis.setLayers([new AMap.TileLayer(), imageUrlOverlay]);
619
726
  } else {
620
727
  console.warn("\u533A\u57DF\u7ECF\u7EAC\u5EA6sw/ne\u6570\u636E\u9519\u8BEF");
621
728
  return false;
622
729
  }
623
730
  });
624
- }
625
- //清空地图所有图元
731
+ } //清空地图所有图元
732
+
626
733
  }, {
627
734
  key: "clearAll",
628
735
  value: function clearAll() {
629
- var t = this;
630
- //先清除所有标记
736
+ var t = this; //先清除所有标记
737
+
631
738
  t.clusterObj.clearMarkers();
632
- t.state.gis.clearMap();
633
- //清空所有缓存图元数据
634
- t.GM.clearAll();
635
- //清空历史数据记录
739
+ t.state.gis.clearMap(); //清空所有缓存图元数据
740
+
741
+ t.GM.clearAll(); //清空历史数据记录
742
+
636
743
  t.setState({
637
744
  pointIds: [],
638
745
  lineIds: [],
@@ -650,19 +757,24 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
650
757
  }
651
758
  /*set方法*/
652
759
  //设置地图中心位置 lng/经度 lat/纬度
760
+
653
761
  }, {
654
762
  key: "setCenter",
655
763
  value: function setCenter(gt) {
656
764
  var t = this;
765
+
766
+ if (!t.state.gis) {
767
+ return;
768
+ }
769
+
657
770
  if (gt && gt instanceof Array && gt.length == 2) {
658
- t.state.gis.setCenter(gt);
659
- // t.setState({center:gt});
771
+ t.state.gis.setCenter(gt); // t.setState({center:gt});
660
772
  } else {
661
- t.state.gis.setCenter([116.400433, 39.906705]);
662
- // t.setState({center:[117.468021,39.890092]});
773
+ t.state.gis.setCenter([116.400433, 39.906705]); // t.setState({center:[117.468021,39.890092]});
663
774
  }
664
775
  }
665
776
  /*地图区域限制*/
777
+
666
778
  }, {
667
779
  key: "setAreaRestriction",
668
780
  value: function setAreaRestriction(sw_ne) {
@@ -673,13 +785,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
673
785
  key: "clearAreaRestriction",
674
786
  value: function clearAreaRestriction() {
675
787
  this.state.gis.clearLimitBounds();
676
- }
677
- //展示路况信息
788
+ } //展示路况信息
789
+
678
790
  }, {
679
791
  key: "openTrafficInfo",
680
792
  value: function openTrafficInfo() {
681
- var t = this;
682
- //判断是否已经创建路况对象
793
+ var t = this; //判断是否已经创建路况对象
794
+
683
795
  if (this.trafficLayer) {
684
796
  this.trafficLayer.show();
685
797
  } else {
@@ -690,44 +802,51 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
690
802
  t.state.gis.add(trafficLayer);
691
803
  this.trafficLayer = trafficLayer;
692
804
  }
693
- }
694
- //隐藏路况信息
805
+ } //隐藏路况信息
806
+
695
807
  }, {
696
808
  key: "hideTrafficInfo",
697
809
  value: function hideTrafficInfo() {
698
810
  if (this.trafficLayer) {
699
811
  this.trafficLayer.hide();
700
812
  }
701
- }
702
- //设置指定图元展示 高德只有zoom和center全适应,单适应暂时无法实现
813
+ } //设置指定图元展示 高德只有zoom和center全适应,单适应暂时无法实现
814
+
703
815
  }, {
704
816
  key: "setVisiblePoints",
705
817
  value: function setVisiblePoints(obj) {
706
818
  var t = this;
707
819
  var ids = [];
820
+
708
821
  switch (obj.fitView) {
709
822
  case 'point':
710
823
  t.state.gis.setFitView(t.state.gis.getAllOverlays('marker'));
711
824
  break;
825
+
712
826
  case 'line':
713
827
  t.state.gis.setFitView(t.state.gis.getAllOverlays('polyline'));
714
828
  break;
829
+
715
830
  case 'polygon':
716
831
  t.state.gis.setFitView(t.state.gis.getAllOverlays('polygon'));
717
832
  break;
833
+
718
834
  case 'circle':
719
835
  t.state.gis.setFitView(t.state.gis.getAllOverlays('circle'));
720
836
  break;
837
+
721
838
  case 'all':
722
839
  var pts = [].concat(_toConsumableArray(t.state.gis.getAllOverlays('marker')), _toConsumableArray(t.state.gis.getAllOverlays('polyline')), _toConsumableArray(t.state.gis.getAllOverlays('polygon')), _toConsumableArray(t.state.gis.getAllOverlays('circle')));
723
840
  t.state.gis.setFitView(pts);
724
841
  break;
842
+
725
843
  default:
726
844
  if (obj.fitView instanceof Array) {
727
845
  ids = obj.fitView;
728
846
  } else if (typeof obj.fitView === 'string') {
729
847
  ids = obj.fitView.split(',');
730
848
  }
849
+
731
850
  if (ids[0] instanceof Array) {
732
851
  // let l = new AMap.LngLat(ids[0][0],ids[0][1]),
733
852
  // r = new AMap.LngLat(ids[1][0],ids[1][1]);
@@ -742,17 +861,18 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
742
861
  } else {
743
862
  t.state.gis.setFitView(this.GM.getMoreGraphic(ids));
744
863
  }
864
+
745
865
  break;
746
866
  }
747
- }
748
- //设置地图比例尺
867
+ } //设置地图比例尺
868
+
749
869
  }, {
750
870
  key: "setZoomLevel",
751
871
  value: function setZoomLevel(zoom) {
752
872
  var t = this;
753
873
  t.state.gis.setZoom(zoom);
754
- }
755
- //获取当前地图的中心位置
874
+ } //获取当前地图的中心位置
875
+
756
876
  }, {
757
877
  key: "getCurrentCenter",
758
878
  value: function getCurrentCenter() {
@@ -761,22 +881,22 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
761
881
  lat: t.state.gis.getCenter().lat,
762
882
  lng: t.state.gis.getCenter().lng
763
883
  };
764
- }
765
- //获取当前比例尺
884
+ } //获取当前比例尺
885
+
766
886
  }, {
767
887
  key: "getZoomLevel",
768
888
  value: function getZoomLevel() {
769
889
  var t = this;
770
890
  return t.state.gis.getZoom();
771
- }
772
- //获取当前地图边框左右边角经纬度,中心点位置,和比例尺,半径距离
891
+ } //获取当前地图边框左右边角经纬度,中心点位置,和比例尺,半径距离
892
+
773
893
  }, {
774
894
  key: "getMapExtent",
775
895
  value: function getMapExtent() {
776
896
  var t = this;
777
897
  var gis = t.state.gis;
778
898
  var northEast = (this.props.viewMode == '3D' ? gis.getBounds().toBounds() : gis.getBounds()).getNorthEast(),
779
- southWest = (this.props.viewMode == '3D' ? gis.getBounds().toBounds() : gis.getBounds()).getSouthWest();
899
+ southWest = (this.props.viewMode == '3D' ? gis.getBounds().toBounds() : gis.getBounds()).getSouthWest();
780
900
  var obj = {
781
901
  mapSize: gis.getSize(),
782
902
  nowCenter: t.getCurrentCenter(),
@@ -792,13 +912,14 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
792
912
  };
793
913
  obj.radius = t.calculatePointsDistance([obj.nowCenter.lng, obj.nowCenter.lat], [northEast.getLng(), northEast.getLat()]);
794
914
  return obj;
795
- }
796
- //聚合地图图元(arg为空时聚合全部点)
915
+ } //聚合地图图元(arg为空时聚合全部点)
916
+
797
917
  }, {
798
918
  key: "cluster",
799
919
  value: function cluster(arg) {
800
920
  var t = this;
801
921
  var ary = [];
922
+
802
923
  if (!arg) {
803
924
  var pointIds = t.state.pointIds;
804
925
  ary = pointIds;
@@ -809,6 +930,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
809
930
  ary = arg.split(',');
810
931
  }
811
932
  }
933
+
812
934
  ary = ary.filter(function (item, index) {
813
935
  return !(t.GM.getGraphicParam(item).attributes.config || {}).isAnimation;
814
936
  });
@@ -816,82 +938,103 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
816
938
  return !item && item != 0 ? false : true;
817
939
  });
818
940
  t.clusterObj.setMarkers(ms);
819
- }
820
- //展示比例尺
941
+ } // 清除聚合
942
+
943
+ }, {
944
+ key: "removeCluster",
945
+ value: function removeCluster(arg) {
946
+ var t = this;
947
+ var ids = arg !== null && arg !== void 0 ? arg : t.state.pointIds;
948
+ t.clusterObj.removeMarkers(t.clusterObj.getMarkers());
949
+ ids.map(function (id) {
950
+ t.GM.removeGraphic(id);
951
+ }); // 重新加点
952
+
953
+ t.addPoint(t.props.mapPoints);
954
+ } //展示比例尺
955
+
821
956
  }, {
822
957
  key: "showControl",
823
958
  value: function showControl(props) {
824
959
  var t = this,
825
- location = 'RT',
826
- offset = null,
827
- scaleOffset = null;
960
+ location = 'RT',
961
+ offset = null,
962
+ scaleOffset = null;
828
963
  var config = props || t.props;
964
+
829
965
  if (t.scaleControl) {
830
966
  t.state.gis.removeControl(t.scaleControl);
831
967
  }
968
+
832
969
  if (t.navigationControl) {
833
970
  t.state.gis.removeControl(t.navigationControl);
834
971
  }
972
+
835
973
  if (config.showControl.location) {
836
974
  location = t.AnchorConstant[config.showControl.location];
837
975
  }
976
+
838
977
  if (config.showControl.offset && config.showControl.offset.length > 0) {
839
978
  offset = new AMap.Pixel(config.showControl.offset[0], config.showControl.offset[1]);
840
979
  scaleOffset = new AMap.Pixel(config.showControl.offset[0] + 70, config.showControl.offset[1]);
841
- }
842
- // 添加比例尺
980
+ } // 添加比例尺
981
+
982
+
843
983
  var control = new AMap.Scale({
844
984
  position: location,
845
985
  offset: scaleOffset
846
986
  });
847
987
  t.state.gis.addControl(control);
848
- t.scaleControl = control;
849
- // 包含平移和缩放按钮
988
+ t.scaleControl = control; // 包含平移和缩放按钮
989
+
850
990
  var navigation = new AMap.ToolBar({
851
991
  position: location,
852
992
  offset: offset
853
993
  });
854
994
  t.state.gis.addControl(navigation);
855
995
  t.navigationControl = navigation;
856
- }
857
- // 移除比例尺
996
+ } // 移除比例尺
997
+
858
998
  }, {
859
999
  key: "removeControl",
860
1000
  value: function removeControl() {
861
1001
  var t = this;
1002
+
862
1003
  if (t.scaleControl) {
863
1004
  t.state.gis.removeControl(t.scaleControl);
864
1005
  t.scaleControl = null;
865
1006
  }
1007
+
866
1008
  if (t.navigationControl) {
867
1009
  t.state.gis.removeControl(t.navigationControl);
868
1010
  t.navigationControl = null;
869
1011
  }
870
- }
871
- //展示地图切换控件
1012
+ } //展示地图切换控件
1013
+
872
1014
  }, {
873
1015
  key: "showMapTypeControl",
874
1016
  value: function showMapTypeControl(props) {
875
1017
  var t = this,
876
- location = 'RT',
877
- offset = null;
1018
+ location = 'RT',
1019
+ offset = null;
878
1020
  var config = props || t.props;
1021
+
879
1022
  if (t.mapTypeControl) {
880
1023
  t.state.gis.removeControl(t.mapTypeControl);
881
1024
  }
1025
+
882
1026
  if (config.satelliteSwitch.location) {
883
1027
  location = t.AnchorConstant[config.satelliteSwitch.location];
884
- }
1028
+ } // 地图切换控件
1029
+
885
1030
 
886
- // 地图切换控件
887
1031
  var control = new AMap.MapType({
888
1032
  position: location,
889
1033
  offset: offset
890
1034
  });
891
1035
  t.state.gis.addControl(control);
892
- t.mapTypeControl = control;
1036
+ t.mapTypeControl = control; // TODO,MapType没有这些属性,所以下面定位和偏移不生效,手动修改
893
1037
 
894
- // TODO,MapType没有这些属性,所以下面定位和偏移不生效,手动修改
895
1038
  function reloaction() {
896
1039
  if (location == 'RT') {
897
1040
  $('div.amap-maptypecontrol').css({
@@ -922,6 +1065,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
922
1065
  top: 'inherit'
923
1066
  });
924
1067
  }
1068
+
925
1069
  if (config.satelliteSwitch.offset && config.satelliteSwitch.offset.length > 0) {
926
1070
  if (location == 'RT') {
927
1071
  $('div.amap-maptypecontrol').css({
@@ -954,39 +1098,47 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
954
1098
  }
955
1099
  }
956
1100
  }
1101
+
957
1102
  if ($('div.amap-maptypecontrol').length > 0) {
958
1103
  reloaction();
959
1104
  } else {
960
1105
  var timer = setInterval(function () {
961
1106
  console.log(123);
1107
+
962
1108
  if ($('div.amap-maptypecontrol').length > 0) {
963
1109
  clearInterval(timer);
964
1110
  reloaction();
965
1111
  }
966
1112
  }, 500);
967
1113
  }
968
- }
969
- //获取图元数据
1114
+ } //获取图元数据
1115
+
970
1116
  }, {
971
1117
  key: "getGraphic",
972
1118
  value: function getGraphic(id) {
973
1119
  var t = this;
1120
+
974
1121
  if (!id) {
975
1122
  return false;
976
1123
  }
1124
+
977
1125
  var gp = t.GM.getGraphicParam(id);
978
1126
  var gg = t.GM.getGraphic(id);
1127
+
979
1128
  if (!gg) {
980
1129
  return false;
981
1130
  }
1131
+
982
1132
  var p = {},
983
- pts = [],
984
- lng = 0,
985
- lat = 0;
1133
+ pts = [],
1134
+ lng = 0,
1135
+ lat = 0;
1136
+
986
1137
  var _t$dealData2 = t.dealData(gg),
987
- lnglatAry = _t$dealData2.lnglatAry,
988
- _extent = _t$dealData2._extent,
989
- path = _t$dealData2.path;
1138
+ lnglatAry = _t$dealData2.lnglatAry,
1139
+ _extent = _t$dealData2._extent,
1140
+ path = _t$dealData2.path;
1141
+
990
1142
  switch (gp.geometryType) {
991
1143
  case 'point':
992
1144
  lng = gg.getPosition().getLng();
@@ -1007,6 +1159,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1007
1159
  })
1008
1160
  });
1009
1161
  break;
1162
+
1010
1163
  case 'polyline':
1011
1164
  pts = gg.getPath().map(function (item, index) {
1012
1165
  return [item.lng, item.lat];
@@ -1026,6 +1179,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1026
1179
  })
1027
1180
  });
1028
1181
  break;
1182
+
1029
1183
  case 'polygon':
1030
1184
  pts = gg.getPath().map(function (item, index) {
1031
1185
  return [item.lng, item.lat];
@@ -1045,6 +1199,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1045
1199
  })
1046
1200
  });
1047
1201
  break;
1202
+
1048
1203
  case 'circle':
1049
1204
  lng = gg.getCenter().getLng();
1050
1205
  lat = gg.getCenter().getLat();
@@ -1069,23 +1224,24 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1069
1224
  });
1070
1225
  break;
1071
1226
  }
1227
+
1072
1228
  return p;
1073
- }
1074
- //显示隐藏的图元
1229
+ } //显示隐藏的图元
1230
+
1075
1231
  }, {
1076
1232
  key: "showGraphicById",
1077
1233
  value: function showGraphicById(id) {
1078
1234
  var t = this;
1079
1235
  t.GM.getGraphic(id).show();
1080
- }
1081
- //隐藏图元
1236
+ } //隐藏图元
1237
+
1082
1238
  }, {
1083
1239
  key: "hideGraphicById",
1084
1240
  value: function hideGraphicById(id) {
1085
1241
  var t = this;
1086
1242
  t.GM.getGraphic(id).hide();
1087
- }
1088
- //画出对应边界线 name区域名
1243
+ } //画出对应边界线 name区域名
1244
+
1089
1245
  }, {
1090
1246
  key: "addBaiduBoundary",
1091
1247
  value: function addBaiduBoundary(bdNames) {
@@ -1113,6 +1269,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1113
1269
  key: "removeBaiduBoundary",
1114
1270
  value: function removeBaiduBoundary(removedBDNames) {
1115
1271
  var _this2 = this;
1272
+
1116
1273
  var removedBDIds = this.state.boundaryInfo.filter(function (item) {
1117
1274
  return removedBDNames.indexOf(item.name) > -1;
1118
1275
  }).map(function (item) {
@@ -1138,28 +1295,33 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1138
1295
  visible: true,
1139
1296
  opacity: 0.7
1140
1297
  };
1298
+
1141
1299
  if (d.config) {
1142
1300
  cg = _objectSpread(_objectSpread({}, cg), d.config);
1143
1301
  }
1302
+
1144
1303
  var option = {
1145
1304
  radius: cg.radius,
1146
1305
  opacity: [0, cg.opacity]
1147
1306
  };
1307
+
1148
1308
  if (cg.gradient) {
1149
1309
  option.gradient = cg.gradient;
1150
1310
  }
1311
+
1151
1312
  t.heatmap.setOptions(option);
1152
1313
  t.heatmap.setDataSet({
1153
1314
  max: cg.max,
1154
1315
  data: d.data || []
1155
1316
  });
1317
+
1156
1318
  if (cg.visible) {
1157
1319
  t.heatmap.show();
1158
1320
  } else {
1159
1321
  t.heatmap.hide();
1160
1322
  }
1161
- }
1162
- // 信息窗体
1323
+ } // 信息窗体
1324
+
1163
1325
  }, {
1164
1326
  key: "infoWindow",
1165
1327
  value: function infoWindow() {
@@ -1169,37 +1331,43 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1169
1331
  width: 300,
1170
1332
  height: 172
1171
1333
  };
1334
+
1172
1335
  if (d.config) {
1173
1336
  cg = _objectSpread(_objectSpread({}, cg), d.config);
1174
1337
  }
1338
+
1175
1339
  var sContent = document.createElement('div');
1176
1340
  var infowindow = new AMap.InfoWindow({
1177
1341
  // isCustom: true,
1178
1342
  content: sContent
1179
1343
  });
1180
1344
  infowindow.setSize(new AMap.Size(cg.width, cg.height + 20));
1345
+
1181
1346
  if (d.onClose instanceof Function) {
1182
1347
  infowindow.on("close", function (e) {
1183
1348
  d.onClose(e);
1184
1349
  });
1185
1350
  }
1351
+
1186
1352
  if (d.lat && d.lng && d.content) {
1187
1353
  (0, _reactDom.render)(d.content, sContent);
1188
1354
  infowindow.open(t.state.gis, [d.lng, d.lat]);
1189
1355
  } else {
1190
1356
  infowindow.close();
1191
1357
  }
1192
- }
1193
- //添加海量点
1358
+ } //添加海量点
1359
+
1194
1360
  }, {
1195
1361
  key: "addPointCollection",
1196
1362
  value: function addPointCollection() {
1197
1363
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1198
1364
  var t = this;
1365
+
1199
1366
  if (!$("#".concat(t.state.mapId, " .amap-layers")).length) {
1200
1367
  if (t.pointCollectTimer) {
1201
1368
  clearTimeout(t.pointCollectTimer);
1202
1369
  }
1370
+
1203
1371
  t.pointCollectTimer = setTimeout(function () {
1204
1372
  t.addPointCollection(data);
1205
1373
  }, 50);
@@ -1214,6 +1382,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1214
1382
  pointCollectionHtml.className = 'vtx_gmap_html_pointCollection_a';
1215
1383
  $($("#".concat(t.state.mapId, " .amap-layers"))[0]).append(pointCollectionHtml);
1216
1384
  } else {}
1385
+
1217
1386
  data.map(function (item, index) {
1218
1387
  var d = item || {};
1219
1388
  var points = (d.points || []).map(function (d, i) {
@@ -1237,8 +1406,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1237
1406
  VotexpointCollection.draw();
1238
1407
  });
1239
1408
  }
1240
- }
1241
- //更新海量点
1409
+ } //更新海量点
1410
+
1242
1411
  }, {
1243
1412
  key: "updatePointCollection",
1244
1413
  value: function updatePointCollection() {
@@ -1263,8 +1432,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1263
1432
  }
1264
1433
  });
1265
1434
  });
1266
- }
1267
- //删除海量点
1435
+ } //删除海量点
1436
+
1268
1437
  }, {
1269
1438
  key: "clearPointCollection",
1270
1439
  value: function clearPointCollection() {
@@ -1277,8 +1446,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1277
1446
  }
1278
1447
  });
1279
1448
  });
1280
- }
1281
- //删除全部海量点
1449
+ } //删除全部海量点
1450
+
1282
1451
  }, {
1283
1452
  key: "clearAllPointCollection",
1284
1453
  value: function clearAllPointCollection() {
@@ -1286,26 +1455,31 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1286
1455
  t.morepoints.map(function (item, index) {
1287
1456
  item.value.clear();
1288
1457
  });
1289
- }
1290
- //添加点
1458
+ } //添加点
1459
+
1291
1460
  }, {
1292
1461
  key: "addPoint",
1293
1462
  value: function addPoint(mapPoints, type) {
1294
1463
  var _this3 = this;
1464
+
1295
1465
  var t = this;
1296
1466
  var ps = [];
1467
+
1297
1468
  var psids = _toConsumableArray(t.state.pointIds);
1469
+
1298
1470
  mapPoints.map(function (item, index) {
1299
1471
  //如果id重复,直接跳过不执行.
1300
1472
  if (_this3.GM.isRepetition(item.id)) {
1301
1473
  console.warn("\u52A0\u70B9id: ".concat(item.id, " \u91CD\u590D"));
1302
1474
  return false;
1303
- }
1304
- //点位数据不符合,直接跳过
1475
+ } //点位数据不符合,直接跳过
1476
+
1477
+
1305
1478
  if (!item.longitude || !item.latitude) {
1306
1479
  console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
1307
1480
  return false;
1308
1481
  }
1482
+
1309
1483
  var cg = {
1310
1484
  width: 30,
1311
1485
  height: 30,
@@ -1316,12 +1490,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1316
1490
  markerContentY: -42,
1317
1491
  zIndex: 100,
1318
1492
  deg: 0
1319
- };
1320
- //初始化默认数据
1493
+ }; //初始化默认数据
1494
+
1321
1495
  if (item.config) {
1322
1496
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1323
- }
1324
- //覆盖物参数
1497
+ } //覆盖物参数
1498
+
1499
+
1325
1500
  var markerOption = {
1326
1501
  position: new AMap.LngLat(item.longitude, item.latitude),
1327
1502
  offset: new AMap.Pixel(cg.markerContentX, cg.markerContentY),
@@ -1334,14 +1509,16 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1334
1509
  id: item.id
1335
1510
  }
1336
1511
  };
1512
+
1337
1513
  if (cg.BAnimationType == 0) {
1338
1514
  markerOption.animation = 'AMAP_ANIMATION_BOUNCE';
1339
1515
  } else if (cg.BAnimationType == 1) {
1340
1516
  markerOption.animation = 'AMAP_ANIMATION_DROP';
1341
1517
  } else {
1342
1518
  markerOption.animation = 'AMAP_ANIMATION_NONE';
1343
- }
1344
- //判断html还是图片
1519
+ } //判断html还是图片
1520
+
1521
+
1345
1522
  if (!!item.markerContent) {
1346
1523
  markerOption.content = item.markerContent;
1347
1524
  } else {
@@ -1352,23 +1529,24 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1352
1529
  size: new AMap.Size(cg.width, cg.height),
1353
1530
  image: item.url,
1354
1531
  imageSize: new AMap.Size(cg.width, cg.height)
1355
- });
1356
- // }else{
1532
+ }); // }else{
1357
1533
  // markerOption.icon = item.url;
1358
1534
  // }
1359
1535
  }
1360
- }
1361
- //是否展示label
1536
+ } //是否展示label
1537
+
1538
+
1362
1539
  if (item.canShowLabel) {
1363
1540
  var labelClass = item.labelClass || 'label-content';
1364
1541
  markerOption.label = {
1365
1542
  content: "<div class='".concat(labelClass, "'>").concat(cg.labelContent, "</div>"),
1366
1543
  offset: new AMap.Pixel(cg.labelPixelX, cg.labelPixelY)
1367
1544
  };
1368
- }
1369
- //获得覆盖物对象
1370
- var marker = new AMap.Marker(markerOption);
1371
- //添加点击事件
1545
+ } //获得覆盖物对象
1546
+
1547
+
1548
+ var marker = new AMap.Marker(markerOption); //添加点击事件
1549
+
1372
1550
  marker.on('click', function (e) {
1373
1551
  t.clickGraphic(item.id, e);
1374
1552
  });
@@ -1379,8 +1557,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1379
1557
  t.mouseOutGraphic(item.id, e);
1380
1558
  });
1381
1559
  ps.push(marker);
1382
- psids.push(item.id);
1383
- //缓存图元的数据,偏于后期操作
1560
+ psids.push(item.id); //缓存图元的数据,偏于后期操作
1561
+
1384
1562
  _this3.GM.setGraphic(item.id, marker).setGraphicParam(item.id, {
1385
1563
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1386
1564
  other: item
@@ -1392,21 +1570,22 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1392
1570
  y: item.latitude
1393
1571
  }
1394
1572
  });
1395
- });
1396
- //统一加点
1573
+ }); //统一加点
1574
+
1397
1575
  t.state.gis.add(ps);
1576
+
1398
1577
  if (type !== 'defined') {
1399
- t.state.pointIds = psids;
1400
- // t.setState({
1578
+ t.state.pointIds = psids; // t.setState({
1401
1579
  // pointIds: psids
1402
1580
  // })
1403
1581
  }
1404
- }
1405
- //更新点
1582
+ } //更新点
1583
+
1406
1584
  }, {
1407
1585
  key: "updatePoint",
1408
1586
  value: function updatePoint(mapPoints) {
1409
1587
  var _this4 = this;
1588
+
1410
1589
  var t = this;
1411
1590
  mapPoints.map(function (item, index) {
1412
1591
  //判断图元是否存在.
@@ -1415,10 +1594,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1415
1594
  if (!item.longitude || !item.latitude) {
1416
1595
  console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
1417
1596
  return false;
1418
- }
1419
- //获取原有的图元
1597
+ } //获取原有的图元
1598
+
1599
+
1420
1600
  var gc = _this4.GM.getGraphic(item.id),
1421
- isuserUrlLeft = false;
1601
+ isuserUrlLeft = false;
1602
+
1422
1603
  var cg = {
1423
1604
  width: 30,
1424
1605
  height: 30,
@@ -1429,56 +1610,66 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1429
1610
  zIndex: gc.getzIndex(),
1430
1611
  labelClass: 'label-content'
1431
1612
  };
1613
+
1432
1614
  if (item.config) {
1433
1615
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1434
- }
1435
- //是否展示label
1616
+ } //是否展示label
1617
+
1618
+
1436
1619
  if (item.canShowLabel) {
1437
1620
  cg.labelPixelX = cg.labelPixelX || gc.getLabel() ? gc.getLabel().offset.getX() : 0;
1438
1621
  cg.labelPixelY = cg.labelPixelY || gc.getLabel() ? gc.getLabel().offset.getY() : 34;
1439
1622
  cg.labelContent = cg.labelContent || gc.getLabel().offset.content;
1440
- var labelClass = item.labelClass || 'label-content';
1441
- //更新label
1623
+ var labelClass = item.labelClass || 'label-content'; //更新label
1624
+
1442
1625
  gc.setLabel({
1443
1626
  content: "<div class='".concat(labelClass, "'>").concat(cg.labelContent, "</div>"),
1444
1627
  offset: new AMap.Pixel(cg.labelPixelX, cg.labelPixelY)
1445
1628
  });
1446
- }
1447
- //更新偏移量
1448
- gc.setOffset(new AMap.Pixel(cg.markerContentX, cg.markerContentY));
1449
- //设置偏转角度
1450
- gc.setAngle(cg.deg);
1451
- //设置点的标记添加顺序
1452
- gc.setzIndex(cg.zIndex);
1453
- //更新经纬度
1629
+ } //更新偏移量
1630
+
1631
+
1632
+ gc.setOffset(new AMap.Pixel(cg.markerContentX, cg.markerContentY)); //设置偏转角度
1633
+
1634
+ gc.setAngle(cg.deg); //设置点的标记添加顺序
1635
+
1636
+ gc.setzIndex(cg.zIndex); //更新经纬度
1637
+
1454
1638
  if (!item.config.isAnimation) {
1455
1639
  gc.setPosition(new AMap.LngLat(item.longitude, item.latitude));
1456
1640
  } else {
1457
1641
  var distance = t.calculatePointsDistance([item.longitude, item.latitude], [gc.getPosition().getLng(), gc.getPosition().getLat()]);
1642
+
1458
1643
  if (distance > 0) {
1459
1644
  var delay = item.config.animationDelay || 3;
1460
1645
  var speed = distance / delay * 3600 / 1000;
1646
+
1461
1647
  if (cg.autoRotation) {
1462
1648
  var ddeg = t.rotateDeg(gc.getPosition(), [item.longitude, item.latitude]);
1649
+
1463
1650
  if (item.urlleft && ddeg < -90 && ddeg > -270) {
1464
1651
  ddeg += 180;
1465
1652
  isuserUrlLeft = true;
1466
1653
  }
1654
+
1467
1655
  gc.setAngle(ddeg);
1468
1656
  }
1657
+
1469
1658
  gc.moveTo(new AMap.LngLat(item.longitude, item.latitude), speed, function (k) {
1470
1659
  return k;
1471
1660
  });
1472
1661
  }
1473
1662
  }
1663
+
1474
1664
  if (item.config.BAnimationType == 0) {
1475
1665
  gc.setAnimation('AMAP_ANIMATION_BOUNCE');
1476
1666
  } else if (item.config.BAnimationType == 1) {
1477
1667
  gc.setAnimation('AMAP_ANIMATION_DROP');
1478
1668
  } else {
1479
1669
  gc.setAnimation('AMAP_ANIMATION_NONE');
1480
- }
1481
- //判断html还是图片
1670
+ } //判断html还是图片
1671
+
1672
+
1482
1673
  if (!!item.markerContent) {
1483
1674
  gc.setContent(item.markerContent);
1484
1675
  } else {
@@ -1491,13 +1682,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1491
1682
  size: new AMap.Size(cg.width, cg.height),
1492
1683
  image: item.url,
1493
1684
  imageSize: new AMap.Size(cg.width, cg.height)
1494
- }));
1495
- // }else{
1685
+ })); // }else{
1496
1686
  // gc.setIcon(item.url);
1497
1687
  // }
1498
1688
  }
1499
1689
  }
1500
1690
  }
1691
+
1501
1692
  _this4.GM.setGraphicParam(item.id, {
1502
1693
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1503
1694
  other: item
@@ -1514,27 +1705,32 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1514
1705
  return false;
1515
1706
  }
1516
1707
  });
1517
- }
1518
- //添加线
1708
+ } //添加线
1709
+
1519
1710
  }, {
1520
1711
  key: "addLine",
1521
1712
  value: function addLine(mapLines, type) {
1522
1713
  var _this5 = this;
1714
+
1523
1715
  var t = this;
1524
1716
  var ls = [];
1525
- var lsids = _toConsumableArray(t.state.lineIds);
1526
- //遍历添加线(图元)
1717
+
1718
+ var lsids = _toConsumableArray(t.state.lineIds); //遍历添加线(图元)
1719
+
1720
+
1527
1721
  mapLines.map(function (item, index) {
1528
1722
  //如果id重复,直接跳过不执行.
1529
1723
  if (_this5.GM.isRepetition(item.id)) {
1530
1724
  console.warn("\u591A\u6298\u7EBFid: ".concat(item.id, " \u91CD\u590D"));
1531
1725
  return false;
1532
- }
1533
- //多折线点位数据不符合,直接跳过
1726
+ } //多折线点位数据不符合,直接跳过
1727
+
1728
+
1534
1729
  if (!(item.paths && item.paths.length >= 2)) {
1535
1730
  console.warn("\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF");
1536
1731
  return false;
1537
1732
  }
1733
+
1538
1734
  var cg = {
1539
1735
  color: '#277ffa',
1540
1736
  pellucidity: 0.9,
@@ -1542,9 +1738,11 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1542
1738
  lineType: 'solid',
1543
1739
  isHidden: false
1544
1740
  };
1741
+
1545
1742
  if (item.config) {
1546
1743
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1547
1744
  }
1745
+
1548
1746
  var lineOption = {
1549
1747
  strokeColor: cg.color,
1550
1748
  strokeOpacity: cg.pellucidity,
@@ -1556,8 +1754,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1556
1754
  cursor: 'pointer',
1557
1755
  bubble: true
1558
1756
  };
1559
- var polyline = new AMap.Polyline(lineOption);
1560
- //添加点击事件
1757
+ var polyline = new AMap.Polyline(lineOption); //添加点击事件
1758
+
1561
1759
  polyline.on('click', function (e) {
1562
1760
  t.clickGraphic(item.id, e);
1563
1761
  });
@@ -1566,11 +1764,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1566
1764
  });
1567
1765
  polyline.on('mouseout', function (e) {
1568
1766
  t.mouseOutGraphic(item.id, e);
1569
- });
1570
- //缓存图元的数据,便于后期操作
1767
+ }); //缓存图元的数据,便于后期操作
1768
+
1571
1769
  var pts = item.paths.map(function (itt, ind) {
1572
1770
  return _toConsumableArray(itt);
1573
1771
  });
1772
+
1574
1773
  _this5.GM.setGraphic(item.id, polyline).setGraphicParam(item.id, {
1575
1774
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1576
1775
  paths: pts,
@@ -1582,19 +1781,20 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1582
1781
  paths: pts
1583
1782
  }
1584
1783
  });
1784
+
1585
1785
  ls.push(polyline);
1586
- lsids.push(item.id);
1587
- //添加线
1786
+ lsids.push(item.id); //添加线
1588
1787
  // polyline.setMap(t.state.gis);
1589
1788
  //根据参数判断是否显示多折线
1789
+
1590
1790
  if (cg.isHidden) {
1591
1791
  polyline.hide();
1592
1792
  } else {
1593
1793
  polyline.show();
1594
- }
1595
- //state中缓存 line的id...用于数据判断
1596
- t.state.lineIds.push(item.id);
1597
- // polyline.on('click', function(e) {
1794
+ } //state中缓存 line的id...用于数据判断
1795
+
1796
+
1797
+ t.state.lineIds.push(item.id); // polyline.on('click', function(e) {
1598
1798
  // let obj = {
1599
1799
  // type: 'polyline',
1600
1800
  // attributes: {...item.other,...{config:item.config}},
@@ -1606,20 +1806,21 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1606
1806
  // });
1607
1807
  });
1608
1808
  t.state.gis.add(ls);
1809
+
1609
1810
  if (type !== 'defined') {
1610
- t.state.lineIds = lsids;
1611
- // t.setState({
1811
+ t.state.lineIds = lsids; // t.setState({
1612
1812
  // lineIds: lsids
1613
1813
  // });
1614
1814
  }
1615
- }
1616
- //更新线
1815
+ } //更新线
1816
+
1617
1817
  }, {
1618
1818
  key: "updateLine",
1619
1819
  value: function updateLine(mapLines) {
1620
1820
  var _this6 = this;
1621
- var t = this;
1622
- //遍历添加线(图元)
1821
+
1822
+ var t = this; //遍历添加线(图元)
1823
+
1623
1824
  mapLines.map(function (item, index) {
1624
1825
  //判断图元是否存在.
1625
1826
  if (_this6.GM.isRepetition(item.id)) {
@@ -1627,28 +1828,32 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1627
1828
  if (!(item.paths && item.paths.length >= 2)) {
1628
1829
  console.warn("\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF");
1629
1830
  return false;
1630
- }
1631
- //获取原有的图元
1831
+ } //获取原有的图元
1832
+
1833
+
1632
1834
  var gc = _this6.GM.getGraphic(item.id);
1633
- var op = gc.getOptions();
1634
- //根据参数判断是否显示多折线
1835
+
1836
+ var op = gc.getOptions(); //根据参数判断是否显示多折线
1837
+
1635
1838
  if (item.config && item.config.isHidden) {
1636
1839
  gc.hide();
1637
1840
  } else {
1638
1841
  gc.show();
1639
- }
1640
- //获取原有的线属性,转换key值
1842
+ } //获取原有的线属性,转换key值
1843
+
1844
+
1641
1845
  var cg = {
1642
1846
  color: op.strokeColor,
1643
1847
  pellucidity: op.strokeOpacity,
1644
1848
  lineWidth: op.strokeWeight,
1645
1849
  lineType: op.strokeStyle
1646
- };
1647
- //重新初始化值
1850
+ }; //重新初始化值
1851
+
1648
1852
  if (item.config) {
1649
1853
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1650
- }
1651
- //重新赋值
1854
+ } //重新赋值
1855
+
1856
+
1652
1857
  var lineOption = {
1653
1858
  strokeColor: cg.color,
1654
1859
  strokeOpacity: cg.pellucidity,
@@ -1662,6 +1867,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1662
1867
  var pts = item.paths.map(function (itt, ind) {
1663
1868
  return _toConsumableArray(itt);
1664
1869
  });
1870
+
1665
1871
  _this6.GM.setGraphicParam(item.id, {
1666
1872
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1667
1873
  paths: pts,
@@ -1672,47 +1878,55 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1672
1878
  type: 'polyline',
1673
1879
  paths: pts
1674
1880
  }
1675
- });
1676
- //更新线
1881
+ }); //更新线
1882
+
1883
+
1677
1884
  gc.setOptions(lineOption);
1678
1885
  } else {
1679
1886
  console.warn("\u66F4\u65B0\u7684\u591A\u6298\u7EBFid\u4E0D\u5B58\u5728!");
1680
1887
  return false;
1681
1888
  }
1682
1889
  });
1683
- }
1684
- //添加面
1890
+ } //添加面
1891
+
1685
1892
  }, {
1686
1893
  key: "addPolygon",
1687
1894
  value: function addPolygon(mapPolygons) {
1688
1895
  var _this7 = this;
1896
+
1689
1897
  var t = this;
1690
1898
  var pgs = [];
1691
- var pgsids = _toConsumableArray(t.state.polygonIds);
1692
- //遍历添加面(图元)
1899
+
1900
+ var pgsids = _toConsumableArray(t.state.polygonIds); //遍历添加面(图元)
1901
+
1902
+
1693
1903
  mapPolygons.map(function (item, index) {
1694
1904
  //如果id重复,直接跳过不执行.
1695
1905
  if (_this7.GM.isRepetition(item.id)) {
1696
1906
  console.warn("\u591A\u8FB9\u5F62id: ".concat(item.id, " \u91CD\u590D"));
1697
1907
  return false;
1698
- }
1699
- //多边形点位数据不符合,直接跳过
1908
+ } //多边形点位数据不符合,直接跳过
1909
+
1910
+
1700
1911
  if (!(item.rings && item.rings.length >= 3)) {
1701
1912
  console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
1702
1913
  return false;
1703
1914
  }
1915
+
1704
1916
  var cg = {
1705
1917
  lineType: 'solid',
1706
1918
  lineWidth: 5,
1707
1919
  lineColor: '#277ffa',
1708
1920
  lineOpacity: 1,
1709
1921
  color: '#fff',
1710
- pellucidity: 0.5
1711
- // isHidden: false //后期跟百度一起加
1922
+ pellucidity: 0.5 // isHidden: false //后期跟百度一起加
1923
+
1712
1924
  };
1925
+
1713
1926
  if (item.config) {
1714
1927
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1715
1928
  }
1929
+
1716
1930
  var polygonOption = {
1717
1931
  strokeColor: cg.lineColor,
1718
1932
  strokeOpacity: cg.lineOpacity,
@@ -1726,8 +1940,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1726
1940
  cursor: 'pointer',
1727
1941
  bubble: true
1728
1942
  };
1729
- var polygon = new AMap.Polygon(polygonOption);
1730
- //添加点击事件
1943
+ var polygon = new AMap.Polygon(polygonOption); //添加点击事件
1944
+
1731
1945
  polygon.on('click', function (e) {
1732
1946
  t.clickGraphic(item.id, e);
1733
1947
  });
@@ -1736,11 +1950,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1736
1950
  });
1737
1951
  polygon.on('mouseout', function (e) {
1738
1952
  t.mouseOutGraphic(item.id, e);
1739
- });
1740
- //缓存图元的数据,便于后期操作
1953
+ }); //缓存图元的数据,便于后期操作
1954
+
1741
1955
  var pts = item.rings.map(function (itt, ind) {
1742
1956
  return _toConsumableArray(itt);
1743
1957
  });
1958
+
1744
1959
  _this7.GM.setGraphic(item.id, polygon).setGraphicParam(item.id, {
1745
1960
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1746
1961
  rings: pts,
@@ -1752,20 +1967,21 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1752
1967
  rings: pts
1753
1968
  }
1754
1969
  });
1970
+
1755
1971
  pgs.push(polygon);
1756
1972
  pgsids.push(item.id);
1757
1973
  });
1758
1974
  t.state.gis.add(pgs);
1759
- t.state.polygonIds = pgsids;
1760
- // t.setState({
1975
+ t.state.polygonIds = pgsids; // t.setState({
1761
1976
  // polygonIds: pgsids
1762
1977
  // })
1763
- }
1764
- //更新面
1978
+ } //更新面
1979
+
1765
1980
  }, {
1766
1981
  key: "updatePolygon",
1767
1982
  value: function updatePolygon(mapPolygons) {
1768
1983
  var _this8 = this;
1984
+
1769
1985
  var t = this;
1770
1986
  mapPolygons.map(function (item, index) {
1771
1987
  //判断图元是否存在.
@@ -1774,17 +1990,19 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1774
1990
  if (!(item.rings && item.rings.length >= 3)) {
1775
1991
  console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
1776
1992
  return false;
1777
- }
1778
- //获取原有的图元
1993
+ } //获取原有的图元
1994
+
1995
+
1779
1996
  var gc = _this8.GM.getGraphic(item.id);
1780
- var op = gc.getOptions();
1781
- //根据参数判断是否显示面
1997
+
1998
+ var op = gc.getOptions(); //根据参数判断是否显示面
1782
1999
  // if(item.config && item.config.isHidden){
1783
2000
  // gc.hide();
1784
2001
  // }else{
1785
2002
  // gc.show();
1786
2003
  // }
1787
2004
  //获取原有的面属性,转换key值
2005
+
1788
2006
  var cg = {
1789
2007
  lineType: op.strokeStyle,
1790
2008
  lineWidth: op.strokeWeight,
@@ -1792,12 +2010,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1792
2010
  lineOpacity: op.strokeOpacity,
1793
2011
  color: op.fillColor,
1794
2012
  pellucidity: op.fillOpacity
1795
- };
1796
- //重新初始化值
2013
+ }; //重新初始化值
2014
+
1797
2015
  if (item.config) {
1798
2016
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1799
- }
1800
- //重新赋值
2017
+ } //重新赋值
2018
+
2019
+
1801
2020
  var polygonOption = {
1802
2021
  strokeColor: cg.lineColor,
1803
2022
  strokeOpacity: cg.lineOpacity,
@@ -1813,6 +2032,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1813
2032
  var pts = item.rings.map(function (itt, ind) {
1814
2033
  return _toConsumableArray(itt);
1815
2034
  });
2035
+
1816
2036
  _this8.GM.setGraphicParam(item.id, {
1817
2037
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1818
2038
  rings: pts,
@@ -1823,47 +2043,55 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1823
2043
  type: 'polygon',
1824
2044
  rings: pts
1825
2045
  }
1826
- });
1827
- //更新线
2046
+ }); //更新线
2047
+
2048
+
1828
2049
  gc.setOptions(polygonOption);
1829
2050
  } else {
1830
2051
  console.warn("\u66F4\u65B0\u7684\u591A\u8FB9\u5F62id\u4E0D\u5B58\u5728!");
1831
2052
  return false;
1832
2053
  }
1833
2054
  });
1834
- }
1835
- //添加圆 circle
2055
+ } //添加圆 circle
2056
+
1836
2057
  }, {
1837
2058
  key: "addCircle",
1838
2059
  value: function addCircle(mapCircles) {
1839
2060
  var _this9 = this;
2061
+
1840
2062
  var t = this;
1841
2063
  var ccs = [];
2064
+
1842
2065
  var ccsids = _toConsumableArray(t.state.circleIds);
2066
+
1843
2067
  mapCircles.map(function (item, index) {
1844
2068
  //如果id重复,直接跳过不执行.
1845
2069
  if (_this9.GM.isRepetition(item.id)) {
1846
2070
  console.warn("\u5706id: ".concat(item.id, " \u91CD\u590D"));
1847
2071
  return false;
1848
- }
1849
- //圆 点位数据不符合,直接跳过
2072
+ } //圆 点位数据不符合,直接跳过
2073
+
2074
+
1850
2075
  if (!item.longitude || !item.latitude) {
1851
2076
  console.warn("\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
1852
2077
  return false;
1853
2078
  }
2079
+
1854
2080
  var cg = {
1855
2081
  lineType: 'solid',
1856
2082
  lineWidth: 5,
1857
2083
  lineColor: '#277ffa',
1858
2084
  lineOpacity: 1,
1859
2085
  color: '#fff',
1860
- pellucidity: 0.5
1861
- // isHidden: false //后期跟百度一起加
2086
+ pellucidity: 0.5 // isHidden: false //后期跟百度一起加
2087
+
1862
2088
  };
2089
+
1863
2090
  if (item.config) {
1864
2091
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1865
- }
1866
- //初始化配置数据
2092
+ } //初始化配置数据
2093
+
2094
+
1867
2095
  var circleOption = {
1868
2096
  strokeColor: cg.lineColor,
1869
2097
  strokeOpacity: cg.lineOpacity,
@@ -1875,10 +2103,10 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1875
2103
  radius: item.radius,
1876
2104
  cursor: 'pointer',
1877
2105
  bubble: true
1878
- };
1879
- //创建圆对象
1880
- var circle = new AMap.Circle(circleOption);
1881
- //添加点击事件
2106
+ }; //创建圆对象
2107
+
2108
+ var circle = new AMap.Circle(circleOption); //添加点击事件
2109
+
1882
2110
  circle.on('click', function (e) {
1883
2111
  t.clickGraphic(item.id, e);
1884
2112
  });
@@ -1887,8 +2115,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1887
2115
  });
1888
2116
  circle.on('mouseout', function (e) {
1889
2117
  t.mouseOutGraphic(item.id, e);
1890
- });
1891
- //缓存图元的数据,便于后期操作
2118
+ }); //缓存图元的数据,便于后期操作
2119
+
1892
2120
  _this9.GM.setGraphic(item.id, circle).setGraphicParam(item.id, {
1893
2121
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1894
2122
  other: item
@@ -1901,20 +2129,21 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1901
2129
  radius: item.radius
1902
2130
  }
1903
2131
  });
2132
+
1904
2133
  ccs.push(circle);
1905
2134
  ccsids.push(item.id);
1906
2135
  });
1907
2136
  t.state.gis.add(ccs);
1908
- t.state.circleIds = ccsids;
1909
- // t.setState({
2137
+ t.state.circleIds = ccsids; // t.setState({
1910
2138
  // circleIds: ccsids
1911
2139
  // })
1912
- }
1913
- //更新圆
2140
+ } //更新圆
2141
+
1914
2142
  }, {
1915
2143
  key: "updateCircle",
1916
2144
  value: function updateCircle(mapCircles) {
1917
2145
  var _this10 = this;
2146
+
1918
2147
  var t = this;
1919
2148
  mapCircles.map(function (item, index) {
1920
2149
  //判断图元是否存在.
@@ -1923,11 +2152,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1923
2152
  if (!item.longitude || !item.latitude) {
1924
2153
  console.warn("\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
1925
2154
  return false;
1926
- }
1927
- //获取原有的图元
2155
+ } //获取原有的图元
2156
+
2157
+
1928
2158
  var gc = _this10.GM.getGraphic(item.id);
1929
- var op = gc.getOptions();
1930
- //获取原有的面属性,转换key值
2159
+
2160
+ var op = gc.getOptions(); //获取原有的面属性,转换key值
2161
+
1931
2162
  var cg = {
1932
2163
  lineType: op.strokeStyle,
1933
2164
  lineWidth: op.strokeWeight,
@@ -1935,12 +2166,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1935
2166
  lineOpacity: op.strokeOpacity,
1936
2167
  color: op.fillColor,
1937
2168
  pellucidity: op.fillOpacity
1938
- };
1939
- //重新初始化值
2169
+ }; //重新初始化值
2170
+
1940
2171
  if (item.config) {
1941
2172
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1942
- }
1943
- //重新赋值
2173
+ } //重新赋值
2174
+
2175
+
1944
2176
  var circleOption = {
1945
2177
  strokeColor: cg.lineColor,
1946
2178
  strokeOpacity: cg.lineOpacity,
@@ -1951,8 +2183,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1951
2183
  center: new AMap.LngLat(item.longitude, item.latitude) || op.center,
1952
2184
  radius: !item.radius && item != 0 ? op.radius : item.radius,
1953
2185
  cursor: 'pointer'
1954
- };
1955
- //缓存图元的数据,便于后期操作
2186
+ }; //缓存图元的数据,便于后期操作
2187
+
1956
2188
  _this10.GM.setGraphicParam(item.id, {
1957
2189
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1958
2190
  other: item
@@ -1964,8 +2196,9 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1964
2196
  y: item.latitude,
1965
2197
  radius: item.radius
1966
2198
  }
1967
- });
1968
- //更新线
2199
+ }); //更新线
2200
+
2201
+
1969
2202
  gc.setOptions(circleOption);
1970
2203
  } else {
1971
2204
  console.warn("\u66F4\u65B0\u7684\u5706id\u4E0D\u5B58\u5728!");
@@ -1974,30 +2207,36 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
1974
2207
  });
1975
2208
  }
1976
2209
  /*根据图元id,使图元变成可编辑状态*/
2210
+
1977
2211
  }, {
1978
2212
  key: "doEdit",
1979
2213
  value: function doEdit(id) {
1980
2214
  var t = this;
1981
2215
  var ms = t.getGraphic(id);
2216
+
1982
2217
  if (!ms) {
1983
2218
  return false;
1984
2219
  }
2220
+
1985
2221
  if (!!t.state.editId) {
1986
2222
  t.endEdit();
1987
2223
  }
2224
+
1988
2225
  switch (ms.geometryType) {
1989
2226
  case 'point':
1990
2227
  ms.mapLayer.setDraggable(true);
1991
2228
  ms.mapLayer.on('dragend', t.editGraphicChange, t);
1992
2229
  break;
1993
- case 'polyline':
1994
- // break;
2230
+
2231
+ case 'polyline': // break;
2232
+
1995
2233
  case 'polygon':
1996
2234
  case 'rectangle':
1997
2235
  t.polyEdit = new AMap.PolyEditor(t.state.gis, ms.mapLayer);
1998
2236
  t.polyEdit.open();
1999
2237
  t.polyEdit.on('adjust', t.editGraphicChange, t);
2000
2238
  break;
2239
+
2001
2240
  case 'circle':
2002
2241
  t.circleEdit = new AMap.CircleEditor(t.state.gis, ms.mapLayer);
2003
2242
  t.circleEdit.open();
@@ -2005,34 +2244,40 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2005
2244
  t.circleEdit.on('adjust', t.editGraphicChange, t);
2006
2245
  break;
2007
2246
  }
2247
+
2008
2248
  t.setState({
2009
2249
  editId: id
2010
2250
  });
2011
- }
2012
- //关闭编辑
2251
+ } //关闭编辑
2252
+
2013
2253
  }, {
2014
2254
  key: "endEdit",
2015
2255
  value: function endEdit() {
2016
2256
  var t = this;
2017
2257
  var ms = t.getGraphic(t.state.editId);
2258
+
2018
2259
  switch (ms.geometryType) {
2019
2260
  case 'point':
2020
2261
  ms.mapLayer.setDraggable(false);
2021
2262
  ms.mapLayer.off('dragend', t.editGraphicChange, t);
2022
2263
  break;
2264
+
2023
2265
  case 'polyline':
2024
2266
  case 'polygon':
2025
2267
  case 'rectangle':
2026
2268
  t.polyEdit.close();
2027
2269
  t.polyEdit.off('adjust', t.editGraphicChange, t);
2028
2270
  break;
2271
+
2029
2272
  case 'circle':
2030
2273
  t.circleEdit.close();
2031
2274
  t.circleEdit.off('move', t.editGraphicChange, t);
2032
2275
  t.circleEdit.off('adjust', t.editGraphicChange, t);
2033
2276
  break;
2034
2277
  }
2278
+
2035
2279
  var editGraphic = t.state.editGraphic;
2280
+
2036
2281
  if (editGraphic) {
2037
2282
  t.setState({
2038
2283
  editId: '',
@@ -2041,8 +2286,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2041
2286
  t.props.editGraphicChange(editGraphic);
2042
2287
  });
2043
2288
  }
2044
- }
2045
- //编辑变动后
2289
+ } //编辑变动后
2290
+
2046
2291
  }, {
2047
2292
  key: "editGraphicChange",
2048
2293
  value: function editGraphicChange(e) {
@@ -2052,38 +2297,46 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2052
2297
  id: t.state.editId,
2053
2298
  e: e
2054
2299
  };
2300
+
2055
2301
  switch (ms.geometryType) {
2056
2302
  case 'point':
2057
2303
  obj.geometry = ms.geometry;
2058
2304
  obj.param = ms;
2059
2305
  break;
2306
+
2060
2307
  case 'polyline':
2061
2308
  obj.geometry = ms.geometry;
2062
2309
  obj.param = ms;
2063
2310
  obj.distance = ms.mapLayer.getLength();
2064
2311
  break;
2312
+
2065
2313
  case 'polygon':
2066
2314
  case 'rectangle':
2067
2315
  obj.geometry = ms.geometry;
2068
2316
  obj.param = ms;
2069
2317
  obj.area = e.target.getArea();
2070
2318
  break;
2319
+
2071
2320
  case 'circle':
2072
2321
  if (!('lnglat' in e)) {
2073
2322
  obj.e.lnglat = new AMap.LngLat(ms.geometry.x, ms.geometry.y);
2074
2323
  }
2324
+
2075
2325
  if (!('radius' in e)) {
2076
2326
  obj.e.radius = ms.geometry.radius;
2077
2327
  }
2328
+
2078
2329
  obj.geometry = ms.geometry;
2079
2330
  obj.param = ms;
2080
2331
  obj.area = Math.pow(ms.geometry.radius, 2) * Math.PI;
2081
2332
  break;
2082
2333
  }
2334
+
2083
2335
  if (ms.geometryType == 'circle') {
2084
2336
  if (t.editTimeout) {
2085
2337
  clearTimeout(t.editTimeout);
2086
2338
  }
2339
+
2087
2340
  t.editTimeout = setTimeout(function () {
2088
2341
  t.setState({
2089
2342
  editGraphic: obj
@@ -2098,12 +2351,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2098
2351
  t.props.editGraphicChange(obj);
2099
2352
  });
2100
2353
  }
2101
- }
2102
- //点击图元事件
2354
+ } //点击图元事件
2355
+
2103
2356
  }, {
2104
2357
  key: "clickGraphic",
2105
2358
  value: function clickGraphic(id, e) {
2106
2359
  var t = this;
2360
+
2107
2361
  if (typeof t.props.clickGraphic === "function") {
2108
2362
  var param = t.getGraphic(id);
2109
2363
  var obj = {
@@ -2121,40 +2375,43 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2121
2375
  };
2122
2376
  t.props.clickGraphic(obj);
2123
2377
  }
2124
- }
2125
- //拖拽地图开始
2378
+ } //拖拽地图开始
2379
+
2126
2380
  }, {
2127
2381
  key: "dragMapStart",
2128
2382
  value: function dragMapStart() {
2129
2383
  var t = this;
2384
+
2130
2385
  if (typeof t.props.dragMapStart === "function") {
2131
2386
  t.state.gis.on('dragstart', function (e) {
2132
2387
  var obj = t.getMapExtent();
2133
- obj.e = e;
2134
- //处理下数据,符合拖拽事件
2388
+ obj.e = e; //处理下数据,符合拖拽事件
2389
+
2135
2390
  t.props.dragMapStart(obj);
2136
2391
  });
2137
2392
  }
2138
- }
2139
- //拖拽地图结束事件
2393
+ } //拖拽地图结束事件
2394
+
2140
2395
  }, {
2141
2396
  key: "dragMapEnd",
2142
2397
  value: function dragMapEnd() {
2143
2398
  var t = this;
2399
+
2144
2400
  if (typeof t.props.dragMapEnd === "function") {
2145
2401
  t.state.gis.on('dragend', function (e) {
2146
2402
  var obj = t.getMapExtent();
2147
- obj.e = e;
2148
- //处理下数据,符合拖拽事件
2403
+ obj.e = e; //处理下数据,符合拖拽事件
2404
+
2149
2405
  t.props.dragMapEnd(obj);
2150
2406
  });
2151
2407
  }
2152
- }
2153
- //地图移动开始事件
2408
+ } //地图移动开始事件
2409
+
2154
2410
  }, {
2155
2411
  key: "moveStart",
2156
2412
  value: function moveStart() {
2157
2413
  var t = this;
2414
+
2158
2415
  if (typeof t.props.moveStart === "function") {
2159
2416
  t.state.gis.on('movestart', function (e) {
2160
2417
  t.htmlXY = _objectSpread({
@@ -2168,20 +2425,22 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2168
2425
  display: 'none'
2169
2426
  });
2170
2427
  t.updatePointCollection(t.props.mapPointCollection);
2428
+
2171
2429
  if (t.stopMove) {
2172
2430
  var obj = t.getMapExtent();
2173
- obj.e = e;
2174
- //处理下数据,符合拖拽事件
2431
+ obj.e = e; //处理下数据,符合拖拽事件
2432
+
2175
2433
  t.props.moveStart(obj);
2176
2434
  }
2177
2435
  });
2178
2436
  }
2179
- }
2180
- //地图移动结束事件
2437
+ } //地图移动结束事件
2438
+
2181
2439
  }, {
2182
2440
  key: "moveEnd",
2183
2441
  value: function moveEnd() {
2184
2442
  var t = this;
2443
+
2185
2444
  if (typeof t.props.moveEnd === "function") {
2186
2445
  t.state.gis.on('moveend', function (e) {
2187
2446
  t.htmlXY.isCount = false;
@@ -2191,22 +2450,24 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2191
2450
  display: 'block'
2192
2451
  });
2193
2452
  t.updatePointCollection(t.props.mapPointCollection);
2453
+
2194
2454
  if (t.stopMove) {
2195
2455
  var obj = t.getMapExtent();
2196
- obj.e = e;
2197
- //处理下数据,符合拖拽事件
2456
+ obj.e = e; //处理下数据,符合拖拽事件
2457
+
2198
2458
  t.props.moveEnd(obj);
2199
2459
  } else {
2200
2460
  t.stopMove = true;
2201
2461
  }
2202
2462
  });
2203
2463
  }
2204
- }
2205
- //地图更改缩放级别开始时触发触发此事件
2464
+ } //地图更改缩放级别开始时触发触发此事件
2465
+
2206
2466
  }, {
2207
2467
  key: "zoomStart",
2208
2468
  value: function zoomStart() {
2209
2469
  var t = this;
2470
+
2210
2471
  if (typeof t.props.zoomStart === "function") {
2211
2472
  t.state.gis.on('zoomstart', function (e) {
2212
2473
  $("#".concat(t.pointCollectionId)).css({
@@ -2218,12 +2479,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2218
2479
  t.props.zoomStart(obj);
2219
2480
  });
2220
2481
  }
2221
- }
2222
- //地图更改缩放级别结束时触发触发此事件
2482
+ } //地图更改缩放级别结束时触发触发此事件
2483
+
2223
2484
  }, {
2224
2485
  key: "zoomEnd",
2225
2486
  value: function zoomEnd() {
2226
2487
  var t = this;
2488
+
2227
2489
  if (typeof t.props.zoomEnd === "function") {
2228
2490
  t.state.gis.on('zoomend', function (e) {
2229
2491
  $("#".concat(t.pointCollectionId)).css({
@@ -2234,12 +2496,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2234
2496
  t.props.zoomEnd(obj);
2235
2497
  });
2236
2498
  }
2237
- }
2238
- //图元鼠标悬浮事件
2499
+ } //图元鼠标悬浮事件
2500
+
2239
2501
  }, {
2240
2502
  key: "mouseOverGraphic",
2241
2503
  value: function mouseOverGraphic(id, e) {
2242
2504
  var t = this;
2505
+
2243
2506
  if (typeof t.props.mouseOverGraphic === 'function') {
2244
2507
  var obj = {
2245
2508
  e: e,
@@ -2251,12 +2514,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2251
2514
  };
2252
2515
  t.props.mouseOverGraphic(obj);
2253
2516
  }
2254
- }
2255
- //图元鼠标移开事件
2517
+ } //图元鼠标移开事件
2518
+
2256
2519
  }, {
2257
2520
  key: "mouseOutGraphic",
2258
2521
  value: function mouseOutGraphic(id, e) {
2259
2522
  var t = this;
2523
+
2260
2524
  if (typeof t.props.mouseOutGraphic === "function") {
2261
2525
  var obj = {
2262
2526
  e: e,
@@ -2268,12 +2532,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2268
2532
  };
2269
2533
  t.props.mouseOutGraphic(obj);
2270
2534
  }
2271
- }
2272
- //地图点击事件
2535
+ } //地图点击事件
2536
+
2273
2537
  }, {
2274
2538
  key: "clickMap",
2275
2539
  value: function clickMap() {
2276
2540
  var t = this;
2541
+
2277
2542
  if (typeof t.props.clickMap === "function") {
2278
2543
  t.state.gis.on('click', function (e) {
2279
2544
  var obj = t.getMapExtent();
@@ -2286,14 +2551,14 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2286
2551
  t.props.clickMap(obj);
2287
2552
  });
2288
2553
  }
2289
- }
2290
- //测距
2554
+ } //测距
2555
+
2291
2556
  }, {
2292
2557
  key: "vtxRangingTool",
2293
2558
  value: function vtxRangingTool() {
2294
2559
  var t = this;
2295
- t.ruler.turnOn();
2296
- //引用百度测距样式
2560
+ t.ruler.turnOn(); //引用百度测距样式
2561
+
2297
2562
  t.state.gis.setDefaultCursor(this.csr);
2298
2563
  }
2299
2564
  /*
@@ -2302,27 +2567,31 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2302
2567
  parameter 样式 默认null 对象{}写入方式跟add方法一样(对应点线圆面)
2303
2568
  data //初始化数据 默认{id:'add'}
2304
2569
  */
2570
+
2305
2571
  }, {
2306
2572
  key: "draw",
2307
2573
  value: function draw(obj) {
2308
2574
  var t = this,
2309
- drawParam = {};
2310
- //初始化参数
2575
+ drawParam = {}; //初始化参数
2576
+
2311
2577
  drawParam.geometryType = obj.geometryType || 'point';
2312
2578
  drawParam.parameter = obj.parameter ? _objectSpread({}, obj.parameter) : {};
2313
2579
  drawParam.data = obj.data ? _objectSpread({}, obj.data) : {};
2314
- drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime());
2315
- //判断id是否存在
2580
+ drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime()); //判断id是否存在
2581
+
2316
2582
  var len = t.state.drawIds[drawParam.geometryType].indexOf(drawParam.data.id);
2583
+
2317
2584
  if (len > -1) {
2318
2585
  //如果id存在 删除存在的图元,清除drawId中的id数据
2319
2586
  t.removeGraphic(drawParam.data.id);
2320
2587
  t.state.drawIds[drawParam.geometryType].splice(len, 1);
2321
- }
2322
- //引用百度测距样式
2588
+ } //引用百度测距样式
2589
+
2590
+
2323
2591
  t.state.gis.setDefaultCursor('crosshair');
2324
2592
  var param = {};
2325
2593
  var paramgcr = {};
2594
+
2326
2595
  if (drawParam.geometryType == 'polygon' || drawParam.geometryType == 'circle' || drawParam.geometryType == 'rectangle') {
2327
2596
  paramgcr.fillColor = drawParam.parameter.color;
2328
2597
  paramgcr.strokeColor = drawParam.parameter.lineColor;
@@ -2345,6 +2614,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2345
2614
  type: drawParam.geometryType
2346
2615
  };
2347
2616
  }
2617
+
2348
2618
  switch (drawParam.geometryType) {
2349
2619
  case 'point':
2350
2620
  param.icon = new AMap.Icon({
@@ -2366,6 +2636,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2366
2636
  };
2367
2637
  t.mousetool.marker(param);
2368
2638
  break;
2639
+
2369
2640
  case 'polyline':
2370
2641
  param.strokeColor = drawParam.parameter.color;
2371
2642
  param.strokeOpacity = drawParam.parameter.pellucidity;
@@ -2385,58 +2656,68 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2385
2656
  };
2386
2657
  t.mousetool.polyline(param);
2387
2658
  break;
2659
+
2388
2660
  case 'polygon':
2389
2661
  t.mousetool.polygon(paramgcr);
2390
2662
  break;
2663
+
2391
2664
  case 'circle':
2392
2665
  t.mousetool.circle(paramgcr);
2393
2666
  break;
2667
+
2394
2668
  case 'rectangle':
2395
2669
  t.mousetool.rectangle(paramgcr);
2396
2670
  break;
2397
- }
2398
- //保存绘制图元的id便于后期比对
2671
+ } //保存绘制图元的id便于后期比对
2672
+
2673
+
2399
2674
  t.state.drawIds[drawParam.geometryType].push(drawParam.data.id);
2400
- }
2401
- //关闭绘制图元
2675
+ } //关闭绘制图元
2676
+
2402
2677
  }, {
2403
2678
  key: "closeDraw",
2404
2679
  value: function closeDraw() {
2405
- var t = this;
2406
- //恢复鼠标默认样式
2680
+ var t = this; //恢复鼠标默认样式
2681
+
2407
2682
  t.state.gis.setDefaultCursor();
2408
2683
  t.mousetool.close();
2409
- }
2410
- //处理线和面的 经纬度数据
2684
+ } //处理线和面的 经纬度数据
2685
+
2411
2686
  }, {
2412
2687
  key: "dealData",
2413
2688
  value: function dealData(ms) {
2414
2689
  //区别点和圆的经纬度数据处理
2415
2690
  var lnglatAry = [],
2416
- _extent = {
2417
- xmax: 0,
2418
- xmin: 0,
2419
- ymax: 0,
2420
- ymin: 0
2421
- },
2422
- path = [];
2691
+ _extent = {
2692
+ xmax: 0,
2693
+ xmin: 0,
2694
+ ymax: 0,
2695
+ ymin: 0
2696
+ },
2697
+ path = [];
2698
+
2423
2699
  if ('getPath' in ms) {
2424
2700
  path = ms.getPath();
2425
2701
  path = path.map(function (item, index) {
2426
2702
  var lng = item.lng,
2427
- lat = item.lat;
2703
+ lat = item.lat;
2704
+
2428
2705
  if (lng > _extent.xmax) {
2429
2706
  _extent.xmax = lng;
2430
2707
  }
2708
+
2431
2709
  if (lng < _extent.xmin || _extent.xmin == 0) {
2432
2710
  _extent.xmin = lng;
2433
2711
  }
2712
+
2434
2713
  if (lat > _extent.ymax) {
2435
2714
  _extent.ymax = lat;
2436
2715
  }
2716
+
2437
2717
  if (lat < _extent.ymin || _extent.ymin == 0) {
2438
2718
  _extent.ymin = lat;
2439
2719
  }
2720
+
2440
2721
  lnglatAry.push({
2441
2722
  lngX: lng,
2442
2723
  latX: lat
@@ -2444,107 +2725,132 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2444
2725
  return [lng, lat];
2445
2726
  });
2446
2727
  }
2728
+
2447
2729
  return {
2448
2730
  lnglatAry: lnglatAry,
2449
2731
  _extent: _extent,
2450
2732
  path: path
2451
2733
  };
2452
- }
2453
- //删除图元
2734
+ } //删除图元
2735
+
2454
2736
  }, {
2455
2737
  key: "removeGraphic",
2456
2738
  value: function removeGraphic(id, type) {
2457
2739
  var t = this;
2740
+
2458
2741
  if (!!this.GM.getGraphic(id)) {
2459
2742
  if ((t.GM.getGraphicParam(id).attributes.config || {}).isAnimation) {
2460
2743
  this.GM.getGraphic(id).stopMove();
2461
- }
2462
- //清除聚合点 避免异常
2463
- t.clusterObj.removeMarker(this.GM.getGraphic(id));
2464
- //清除地图中图元
2465
- this.GM.getGraphic(id).setMap();
2466
- //清除对应id的图元数据缓存
2744
+ } //清除聚合点 避免异常
2745
+
2746
+
2747
+ t.clusterObj.removeMarker(this.GM.getGraphic(id)); //清除地图中图元
2748
+
2749
+ this.GM.getGraphic(id).setMap(); //清除对应id的图元数据缓存
2750
+
2467
2751
  this.GM.removeGraphic(id);
2468
2752
  } else {
2469
2753
  return false;
2470
- }
2471
- //清除 state中id的缓存
2754
+ } //清除 state中id的缓存
2755
+
2756
+
2472
2757
  var ids = [];
2758
+
2473
2759
  switch (type) {
2474
2760
  case 'point':
2475
2761
  ids = t.state.pointIds;
2476
2762
  break;
2763
+
2477
2764
  case 'line':
2478
2765
  ids = t.state.lineIds;
2479
2766
  break;
2767
+
2480
2768
  case 'polygon':
2481
2769
  ids = t.state.polygonIds;
2482
2770
  break;
2771
+
2483
2772
  case 'circle':
2484
2773
  ids = t.state.circleIds;
2485
2774
  break;
2775
+
2486
2776
  case 'draw':
2487
2777
  if (t.state.drawIds.point.indexOf(id) > -1) {
2488
2778
  t.state.drawIds.point.splice(t.state.drawIds.point.indexOf(id), 1);
2489
2779
  }
2780
+
2490
2781
  if (t.state.drawIds.polyline.indexOf(id) > -1) {
2491
2782
  t.state.drawIds.polyline.splice(t.state.drawIds.polyline.indexOf(id), 1);
2492
2783
  }
2784
+
2493
2785
  if (t.state.drawIds.polygon.indexOf(id) > -1) {
2494
2786
  t.state.drawIds.polygon.splice(t.state.drawIds.polygon.indexOf(id), 1);
2495
2787
  }
2788
+
2496
2789
  if (t.state.drawIds.circle.indexOf(id) > -1) {
2497
2790
  t.state.drawIds.circle.splice(t.state.drawIds.circle.indexOf(id), 1);
2498
2791
  }
2792
+
2499
2793
  if (t.state.drawIds.rectangle.indexOf(id) > -1) {
2500
2794
  t.state.drawIds.rectangle.splice(t.state.drawIds.rectangle.indexOf(id), 1);
2501
2795
  }
2796
+
2502
2797
  break;
2798
+
2503
2799
  default:
2504
2800
  if (t.state.pointIds.indexOf(id) > -1) {
2505
2801
  t.state.pointIds.splice(t.state.pointIds.indexOf(id), 1);
2506
2802
  }
2803
+
2507
2804
  if (t.state.lineIds.indexOf(id) > -1) {
2508
2805
  t.state.lineIds.splice(t.state.lineIds.indexOf(id), 1);
2509
2806
  }
2807
+
2510
2808
  if (t.state.polygonIds.indexOf(id) > -1) {
2511
2809
  t.state.polygonIds.splice(t.state.polygonIds.indexOf(id), 1);
2512
2810
  }
2811
+
2513
2812
  if (t.state.circleIds.indexOf(id) > -1) {
2514
2813
  t.state.circleIds.splice(t.state.circleIds.indexOf(id), 1);
2515
2814
  }
2815
+
2516
2816
  break;
2517
2817
  }
2818
+
2518
2819
  if (id == t.state.editId) {
2519
2820
  t.state.editId = '';
2520
2821
  }
2822
+
2521
2823
  if (ids.indexOf(id) != -1) {
2522
2824
  ids.splice(ids.indexOf(id), 1);
2523
2825
  }
2524
- }
2525
- //点位角度旋转(以指向东(右)为0°)
2826
+ } //点位角度旋转(以指向东(右)为0°)
2827
+
2526
2828
  }, {
2527
2829
  key: "rotateDeg",
2528
2830
  value: function rotateDeg(sp, ep) {
2529
2831
  var t = this;
2530
2832
  var spLngLat = sp;
2833
+
2531
2834
  if (Array.isArray(sp)) {
2532
2835
  spLngLat = new AMap.LngLat(sp[0], sp[1]);
2533
2836
  }
2837
+
2534
2838
  var s = t.state.gis.lngLatToContainer(spLngLat),
2535
- //获取当前点位的经纬度
2536
- e = t.state.gis.lngLatToContainer(new AMap.LngLat(ep[0], ep[1])),
2537
- deg = 0;
2839
+ //获取当前点位的经纬度
2840
+ e = t.state.gis.lngLatToContainer(new AMap.LngLat(ep[0], ep[1])),
2841
+ deg = 0;
2842
+
2538
2843
  if (e.x != s.x) {
2539
2844
  var tan = (e.y - s.y) / (e.x - s.x),
2540
- atan = Math.atan(tan);
2541
- deg = atan * 360 / (2 * Math.PI);
2542
- //degree correction;
2845
+ atan = Math.atan(tan);
2846
+ deg = atan * 360 / (2 * Math.PI); //degree correction;
2847
+
2543
2848
  if (e.x < s.x) {
2544
2849
  deg = -deg + 90 + 90;
2545
2850
  } else {
2546
2851
  deg = -deg;
2547
2852
  }
2853
+
2548
2854
  deg = -deg;
2549
2855
  } else {
2550
2856
  var disy = e.y - s.y;
@@ -2553,39 +2859,43 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2553
2859
  if (disy == 0) bias = 0;
2554
2860
  deg = -bias * 90;
2555
2861
  }
2862
+
2556
2863
  return deg;
2557
- }
2558
- //对比对象数据是否相等
2864
+ } //对比对象数据是否相等
2865
+
2559
2866
  }, {
2560
2867
  key: "deepEqual",
2561
2868
  value: function deepEqual(a, b) {
2562
2869
  return _immutable["default"].is(_immutable["default"].fromJS(a), _immutable["default"].fromJS(b));
2563
- }
2564
- //计算2点间距离 单位m 精确到个位
2870
+ } //计算2点间距离 单位m 精确到个位
2871
+
2565
2872
  }, {
2566
2873
  key: "calculatePointsDistance",
2567
2874
  value: function calculatePointsDistance(f, s) {
2568
2875
  var lnglat1 = new AMap.LngLat(f[0], f[1]);
2569
2876
  var lnglat2 = new AMap.LngLat(s[0], s[1]);
2570
2877
  return Math.round(lnglat1.distance(lnglat2));
2571
- }
2572
- //计算多个点的距离(常用于线计算)
2878
+ } //计算多个点的距离(常用于线计算)
2879
+
2573
2880
  }, {
2574
2881
  key: "calculateDistance",
2575
2882
  value: function calculateDistance(ps) {
2576
2883
  var t = this,
2577
- totalDistance = 0;
2884
+ totalDistance = 0;
2885
+
2578
2886
  if (ps.length < 0) {
2579
2887
  return false;
2580
2888
  }
2889
+
2581
2890
  for (var i = 0; i < ps.length; i++) {
2582
2891
  if (i < ps.length - 1) {
2583
2892
  totalDistance += t.calculatePointsDistance(ps[i], ps[i + 1]);
2584
2893
  }
2585
2894
  }
2895
+
2586
2896
  return Math.round(totalDistance * 100) / 100;
2587
- }
2588
- //数据解析(分析,新增,更新,删除对应的数据)
2897
+ } //数据解析(分析,新增,更新,删除对应的数据)
2898
+
2589
2899
  }, {
2590
2900
  key: "dataMatch",
2591
2901
  value: function dataMatch(oldData, newData, type) {
@@ -2616,13 +2926,14 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2616
2926
  updatedData: updatedData,
2617
2927
  replacedData: replacedData
2618
2928
  };
2619
- }
2620
- //处理需要增加图元的数据(避免意外问题)
2929
+ } //处理需要增加图元的数据(避免意外问题)
2930
+
2621
2931
  }, {
2622
2932
  key: "dealAdd",
2623
2933
  value: function dealAdd(ary, ids) {
2624
2934
  var ads = [],
2625
- otherupds = [];
2935
+ otherupds = [];
2936
+
2626
2937
  for (var i = 0; i < ary.length; i++) {
2627
2938
  if (ids.indexOf(ary[i].id) > -1) {
2628
2939
  otherupds.push(ary[i]);
@@ -2630,17 +2941,19 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2630
2941
  ads.push(ary[i]);
2631
2942
  }
2632
2943
  }
2944
+
2633
2945
  return {
2634
2946
  ads: ads,
2635
2947
  otherupds: otherupds
2636
2948
  };
2637
- }
2638
- //处理需要更新图元的数据(避免意外问题)
2949
+ } //处理需要更新图元的数据(避免意外问题)
2950
+
2639
2951
  }, {
2640
2952
  key: "dealUpdate",
2641
2953
  value: function dealUpdate(ary, ids) {
2642
2954
  var upds = [],
2643
- otherads = [];
2955
+ otherads = [];
2956
+
2644
2957
  for (var i = 0; i < ary.length; i++) {
2645
2958
  if (ids.indexOf(ary[i].id) > -1) {
2646
2959
  upds.push(ary[i]);
@@ -2648,6 +2961,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2648
2961
  otherads.push(ary[i]);
2649
2962
  }
2650
2963
  }
2964
+
2651
2965
  return {
2652
2966
  upds: upds,
2653
2967
  otherads: otherads
@@ -2710,6 +3024,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2710
3024
  value: function componentWillUnmount() {
2711
3025
  //关闭moveTo定时
2712
3026
  var t = this;
3027
+
2713
3028
  for (var i in t.GM.allParam) {
2714
3029
  if (t.GM.allParam[i].geometryType == 'point') {
2715
3030
  if (t.GM.getGraphic[i]) {
@@ -2717,9 +3032,11 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2717
3032
  }
2718
3033
  }
2719
3034
  }
3035
+
2720
3036
  if (t.pointCollectTimer) {
2721
3037
  clearTimeout(t.pointCollectTimer);
2722
3038
  }
3039
+
2723
3040
  window.VtxMap[t.state.mapId] = null;
2724
3041
  }
2725
3042
  }, {
@@ -2727,15 +3044,15 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2727
3044
  value: function componentDidUpdate(prevProps, prevState) {
2728
3045
  //重新渲染结束
2729
3046
  var t = this;
2730
- var props = t.props;
2731
- // 等待地图加载
2732
- if (!t.state.mapCreated) return;
3047
+ var props = t.props; // 等待地图加载
3048
+
3049
+ if (!t.state.mapCreated) return; //回调显示方法
2733
3050
 
2734
- //回调显示方法
2735
3051
  if (props.showGraphicById) {
2736
3052
  props.showGraphicById(t.showGraphicById.bind(t));
2737
- }
2738
- //回调隐藏方法
3053
+ } //回调隐藏方法
3054
+
3055
+
2739
3056
  if (props.hideGraphicById) {
2740
3057
  props.hideGraphicById(t.hideGraphicById.bind(t));
2741
3058
  }
@@ -2744,81 +3061,86 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2744
3061
  key: "componentWillReceiveProps",
2745
3062
  value: function componentWillReceiveProps(nextProps, prevProps) {
2746
3063
  //已加载组件,收到新的参数时调用
2747
- var t = this;
2748
- //点/线旧数据
3064
+ var t = this; //点/线旧数据
3065
+
2749
3066
  var _t$state = t.state,
2750
- pointIds = _t$state.pointIds,
2751
- lineIds = _t$state.lineIds,
2752
- polygonIds = _t$state.polygonIds,
2753
- circleIds = _t$state.circleIds,
2754
- drawIds = _t$state.drawIds;
3067
+ pointIds = _t$state.pointIds,
3068
+ lineIds = _t$state.lineIds,
3069
+ polygonIds = _t$state.polygonIds,
3070
+ circleIds = _t$state.circleIds,
3071
+ drawIds = _t$state.drawIds;
2755
3072
  var point = drawIds.point,
2756
- polyline = drawIds.polyline,
2757
- polygon = drawIds.polygon,
2758
- circle = drawIds.circle,
2759
- rectangle = drawIds.rectangle;
2760
- //点/线新数据
3073
+ polyline = drawIds.polyline,
3074
+ polygon = drawIds.polygon,
3075
+ circle = drawIds.circle,
3076
+ rectangle = drawIds.rectangle; //点/线新数据
3077
+
2761
3078
  var _nextProps$mapPoints = nextProps.mapPoints,
2762
- mapPoints = _nextProps$mapPoints === void 0 ? [] : _nextProps$mapPoints,
2763
- _nextProps$mapLines = nextProps.mapLines,
2764
- mapLines = _nextProps$mapLines === void 0 ? [] : _nextProps$mapLines,
2765
- _nextProps$mapPolygon = nextProps.mapPolygons,
2766
- mapPolygons = _nextProps$mapPolygon === void 0 ? [] : _nextProps$mapPolygon,
2767
- _nextProps$mapCircles = nextProps.mapCircles,
2768
- mapCircles = _nextProps$mapCircles === void 0 ? [] : _nextProps$mapCircles,
2769
- _nextProps$customized = nextProps.customizedBoundary,
2770
- customizedBoundary = _nextProps$customized === void 0 ? [] : _nextProps$customized,
2771
- isOpenTrafficInfo = nextProps.isOpenTrafficInfo,
2772
- boundaryName = nextProps.boundaryName,
2773
- heatMapData = nextProps.heatMapData,
2774
- imageOverlays = nextProps.imageOverlays,
2775
- mapVisiblePoints = nextProps.mapVisiblePoints,
2776
- setVisiblePoints = nextProps.setVisiblePoints,
2777
- setCenter = nextProps.setCenter,
2778
- mapCenter = nextProps.mapCenter,
2779
- setZoomLevel = nextProps.setZoomLevel,
2780
- mapZoomLevel = nextProps.mapZoomLevel,
2781
- setCluster = nextProps.setCluster,
2782
- mapCluster = nextProps.mapCluster,
2783
- isRangingTool = nextProps.isRangingTool,
2784
- mapRangingTool = nextProps.mapRangingTool,
2785
- isRemove = nextProps.isRemove,
2786
- mapRemove = nextProps.mapRemove,
2787
- mapDraw = nextProps.mapDraw,
2788
- isDraw = nextProps.isDraw,
2789
- isCloseDraw = nextProps.isCloseDraw,
2790
- editGraphicId = nextProps.editGraphicId,
2791
- isDoEdit = nextProps.isDoEdit,
2792
- isEndEdit = nextProps.isEndEdit,
2793
- isClearAll = nextProps.isClearAll,
2794
- mapPointCollection = nextProps.mapPointCollection,
2795
- isclearAllPointCollection = nextProps.isclearAllPointCollection,
2796
- isSetAreaRestriction = nextProps.isSetAreaRestriction,
2797
- areaRestriction = nextProps.areaRestriction,
2798
- isClearAreaRestriction = nextProps.isClearAreaRestriction,
2799
- mapStyle = nextProps.mapStyle,
2800
- coverageType = nextProps.coverageType,
2801
- infoWindowData = nextProps.infoWindowData;
2802
- var props = t.props;
2803
- // 设置地图样式
3079
+ mapPoints = _nextProps$mapPoints === void 0 ? [] : _nextProps$mapPoints,
3080
+ _nextProps$mapLines = nextProps.mapLines,
3081
+ mapLines = _nextProps$mapLines === void 0 ? [] : _nextProps$mapLines,
3082
+ _nextProps$mapPolygon = nextProps.mapPolygons,
3083
+ mapPolygons = _nextProps$mapPolygon === void 0 ? [] : _nextProps$mapPolygon,
3084
+ _nextProps$mapCircles = nextProps.mapCircles,
3085
+ mapCircles = _nextProps$mapCircles === void 0 ? [] : _nextProps$mapCircles,
3086
+ _nextProps$customized = nextProps.customizedBoundary,
3087
+ customizedBoundary = _nextProps$customized === void 0 ? [] : _nextProps$customized,
3088
+ isOpenTrafficInfo = nextProps.isOpenTrafficInfo,
3089
+ boundaryName = nextProps.boundaryName,
3090
+ heatMapData = nextProps.heatMapData,
3091
+ imageOverlays = nextProps.imageOverlays,
3092
+ mapVisiblePoints = nextProps.mapVisiblePoints,
3093
+ setVisiblePoints = nextProps.setVisiblePoints,
3094
+ setCenter = nextProps.setCenter,
3095
+ mapCenter = nextProps.mapCenter,
3096
+ setZoomLevel = nextProps.setZoomLevel,
3097
+ mapZoomLevel = nextProps.mapZoomLevel,
3098
+ setCluster = nextProps.setCluster,
3099
+ mapCluster = nextProps.mapCluster,
3100
+ isRangingTool = nextProps.isRangingTool,
3101
+ mapRangingTool = nextProps.mapRangingTool,
3102
+ isRemove = nextProps.isRemove,
3103
+ mapRemove = nextProps.mapRemove,
3104
+ mapDraw = nextProps.mapDraw,
3105
+ isDraw = nextProps.isDraw,
3106
+ isCloseDraw = nextProps.isCloseDraw,
3107
+ editGraphicId = nextProps.editGraphicId,
3108
+ isDoEdit = nextProps.isDoEdit,
3109
+ isEndEdit = nextProps.isEndEdit,
3110
+ isClearAll = nextProps.isClearAll,
3111
+ mapPointCollection = nextProps.mapPointCollection,
3112
+ isclearAllPointCollection = nextProps.isclearAllPointCollection,
3113
+ isSetAreaRestriction = nextProps.isSetAreaRestriction,
3114
+ areaRestriction = nextProps.areaRestriction,
3115
+ isClearAreaRestriction = nextProps.isClearAreaRestriction,
3116
+ mapStyle = nextProps.mapStyle,
3117
+ coverageType = nextProps.coverageType,
3118
+ infoWindowData = nextProps.infoWindowData;
3119
+ var props = t.props; // 设置地图样式
3120
+
2804
3121
  if (mapStyle && !t.deepEqual(mapStyle, t.props.mapStyle)) {
2805
3122
  t.state.gis.setMapStyle(mapStyle);
2806
- }
2807
- // 切换地图矢量图和卫星图背景
3123
+ } // 切换地图矢量图和卫星图背景
3124
+
3125
+
2808
3126
  if (coverageType && !t.deepEqual(coverageType, t.props.coverageType)) {
2809
3127
  t.setMapType(coverageType);
2810
- }
2811
- // 等待地图加载
3128
+ } // 等待地图加载
3129
+
3130
+
2812
3131
  if (!t.state.mapCreated) return;
3132
+
2813
3133
  if (mapPointCollection instanceof Array && props.mapPointCollection instanceof Array && !t.deepEqual(mapPointCollection, t.props.mapPointCollection)) {
2814
3134
  var _t$dataMatch = t.dataMatch(t.props.mapPointCollection, mapPointCollection, 'id'),
2815
- deletedDataIDs = _t$dataMatch.deletedDataIDs,
2816
- addedData = _t$dataMatch.addedData,
2817
- updatedData = _t$dataMatch.updatedData;
3135
+ deletedDataIDs = _t$dataMatch.deletedDataIDs,
3136
+ addedData = _t$dataMatch.addedData,
3137
+ updatedData = _t$dataMatch.updatedData;
3138
+
2818
3139
  t.clearPointCollection(deletedDataIDs);
2819
3140
  t.addPointCollection(addedData);
2820
3141
  t.updatePointCollection(updatedData);
2821
3142
  }
3143
+
2822
3144
  if (typeof isclearAllPointCollection == 'boolean' && isclearAllPointCollection || isclearAllPointCollection && isclearAllPointCollection !== t.props.isclearAllPointCollection) {
2823
3145
  t.clearAllPointCollection();
2824
3146
  }
@@ -2827,10 +3149,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2827
3149
  pointData[1]的数据在idsForGraphicId中不存在的,执行新增
2828
3150
  pointData[0]数据中多余的id,执行删除
2829
3151
  */
3152
+
3153
+
2830
3154
  if (mapPoints instanceof Array && props.mapPoints instanceof Array && !t.deepEqual(mapPoints, props.mapPoints)) {
2831
3155
  var oldMapPoints = props.mapPoints;
2832
- var newMapPoints = mapPoints;
2833
- //过滤编辑的图元
3156
+ var newMapPoints = mapPoints; //过滤编辑的图元
3157
+
2834
3158
  if (!!t.state.editId) {
2835
3159
  oldMapPoints = props.mapPoints.filter(function (item) {
2836
3160
  return item.id !== editGraphicId;
@@ -2839,41 +3163,50 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2839
3163
  return item.id !== editGraphicId;
2840
3164
  });
2841
3165
  }
3166
+
2842
3167
  var _t$dataMatch2 = t.dataMatch(oldMapPoints, newMapPoints, 'id'),
2843
- _deletedDataIDs = _t$dataMatch2.deletedDataIDs,
2844
- _addedData = _t$dataMatch2.addedData,
2845
- _updatedData = _t$dataMatch2.updatedData;
3168
+ _deletedDataIDs = _t$dataMatch2.deletedDataIDs,
3169
+ _addedData = _t$dataMatch2.addedData,
3170
+ _updatedData = _t$dataMatch2.updatedData;
3171
+
2846
3172
  var _t$dealAdd = t.dealAdd(_addedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
2847
- ads = _t$dealAdd.ads,
2848
- otherupds = _t$dealAdd.otherupds;
3173
+ ads = _t$dealAdd.ads,
3174
+ otherupds = _t$dealAdd.otherupds;
3175
+
2849
3176
  var _t$dealUpdate = t.dealUpdate(_updatedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
2850
- upds = _t$dealUpdate.upds,
2851
- otherads = _t$dealUpdate.otherads;
2852
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3177
+ upds = _t$dealUpdate.upds,
3178
+ otherads = _t$dealUpdate.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3179
+
3180
+
2853
3181
  var _iterator = _createForOfIteratorHelper(_deletedDataIDs),
2854
- _step;
3182
+ _step;
3183
+
2855
3184
  try {
2856
3185
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
2857
3186
  var id = _step.value;
2858
3187
  t.removeGraphic(id, 'point');
2859
- }
2860
- //增加
3188
+ } //增加
3189
+
2861
3190
  } catch (err) {
2862
3191
  _iterator.e(err);
2863
3192
  } finally {
2864
3193
  _iterator.f();
2865
3194
  }
2866
- t.addPoint([].concat(_toConsumableArray(ads), _toConsumableArray(otherads)));
2867
- //更新
3195
+
3196
+ t.addPoint([].concat(_toConsumableArray(ads), _toConsumableArray(otherads))); //更新
3197
+
2868
3198
  t.updatePoint([].concat(_toConsumableArray(upds), _toConsumableArray(otherupds)));
2869
3199
  }
2870
3200
  /*
2871
3201
  面数据处理
2872
3202
  先全删除,再新增
2873
3203
  */
3204
+
3205
+
2874
3206
  if (mapPolygons instanceof Array && props.mapPolygons instanceof Array && !t.deepEqual(mapPolygons, props.mapPolygons)) {
2875
3207
  var oldMapPolygons = props.mapPolygons;
2876
3208
  var newMapPolygons = mapPolygons;
3209
+
2877
3210
  if (!!t.state.editId) {
2878
3211
  oldMapPolygons = props.mapPolygons.filter(function (item) {
2879
3212
  return item.id !== editGraphicId;
@@ -2882,41 +3215,50 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2882
3215
  return item.id !== editGraphicId;
2883
3216
  });
2884
3217
  }
3218
+
2885
3219
  var _t$dataMatch3 = t.dataMatch(oldMapPolygons, newMapPolygons, 'id'),
2886
- _deletedDataIDs2 = _t$dataMatch3.deletedDataIDs,
2887
- _addedData2 = _t$dataMatch3.addedData,
2888
- _updatedData2 = _t$dataMatch3.updatedData;
3220
+ _deletedDataIDs2 = _t$dataMatch3.deletedDataIDs,
3221
+ _addedData2 = _t$dataMatch3.addedData,
3222
+ _updatedData2 = _t$dataMatch3.updatedData;
3223
+
2889
3224
  var _t$dealAdd2 = t.dealAdd(_addedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
2890
- _ads = _t$dealAdd2.ads,
2891
- _otherupds = _t$dealAdd2.otherupds;
3225
+ _ads = _t$dealAdd2.ads,
3226
+ _otherupds = _t$dealAdd2.otherupds;
3227
+
2892
3228
  var _t$dealUpdate2 = t.dealUpdate(_updatedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
2893
- _upds = _t$dealUpdate2.upds,
2894
- _otherads = _t$dealUpdate2.otherads;
2895
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3229
+ _upds = _t$dealUpdate2.upds,
3230
+ _otherads = _t$dealUpdate2.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3231
+
3232
+
2896
3233
  var _iterator2 = _createForOfIteratorHelper(_deletedDataIDs2),
2897
- _step2;
3234
+ _step2;
3235
+
2898
3236
  try {
2899
3237
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2900
3238
  var _id = _step2.value;
2901
3239
  t.removeGraphic(_id, 'polygon');
2902
- }
2903
- //增加
3240
+ } //增加
3241
+
2904
3242
  } catch (err) {
2905
3243
  _iterator2.e(err);
2906
3244
  } finally {
2907
3245
  _iterator2.f();
2908
3246
  }
2909
- t.addPolygon([].concat(_toConsumableArray(_ads), _toConsumableArray(_otherads)));
2910
- //更新
3247
+
3248
+ t.addPolygon([].concat(_toConsumableArray(_ads), _toConsumableArray(_otherads))); //更新
3249
+
2911
3250
  t.updatePolygon([].concat(_toConsumableArray(_upds), _toConsumableArray(_otherupds)));
2912
3251
  }
2913
3252
  /*
2914
3253
  面数据处理
2915
3254
  先全删除,再新增
2916
3255
  */
3256
+
3257
+
2917
3258
  if (mapCircles instanceof Array && props.mapCircles instanceof Array && !t.deepEqual(mapCircles, props.mapCircles)) {
2918
3259
  var oldMapCircles = props.mapCircles;
2919
3260
  var newMapCircles = mapCircles;
3261
+
2920
3262
  if (!!t.state.editId) {
2921
3263
  oldMapCircles = props.mapCircles.filter(function (item) {
2922
3264
  return item.id !== editGraphicId;
@@ -2925,41 +3267,50 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2925
3267
  return item.id !== editGraphicId;
2926
3268
  });
2927
3269
  }
3270
+
2928
3271
  var _t$dataMatch4 = t.dataMatch(oldMapCircles, newMapCircles, 'id'),
2929
- _deletedDataIDs3 = _t$dataMatch4.deletedDataIDs,
2930
- _addedData3 = _t$dataMatch4.addedData,
2931
- _updatedData3 = _t$dataMatch4.updatedData;
3272
+ _deletedDataIDs3 = _t$dataMatch4.deletedDataIDs,
3273
+ _addedData3 = _t$dataMatch4.addedData,
3274
+ _updatedData3 = _t$dataMatch4.updatedData;
3275
+
2932
3276
  var _t$dealAdd3 = t.dealAdd(_addedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
2933
- _ads2 = _t$dealAdd3.ads,
2934
- _otherupds2 = _t$dealAdd3.otherupds;
3277
+ _ads2 = _t$dealAdd3.ads,
3278
+ _otherupds2 = _t$dealAdd3.otherupds;
3279
+
2935
3280
  var _t$dealUpdate3 = t.dealUpdate(_updatedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
2936
- _upds2 = _t$dealUpdate3.upds,
2937
- _otherads2 = _t$dealUpdate3.otherads;
2938
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3281
+ _upds2 = _t$dealUpdate3.upds,
3282
+ _otherads2 = _t$dealUpdate3.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3283
+
3284
+
2939
3285
  var _iterator3 = _createForOfIteratorHelper(_deletedDataIDs3),
2940
- _step3;
3286
+ _step3;
3287
+
2941
3288
  try {
2942
3289
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2943
3290
  var _id2 = _step3.value;
2944
3291
  t.removeGraphic(_id2, 'circle');
2945
- }
2946
- //增加
3292
+ } //增加
3293
+
2947
3294
  } catch (err) {
2948
3295
  _iterator3.e(err);
2949
3296
  } finally {
2950
3297
  _iterator3.f();
2951
3298
  }
2952
- t.addCircle([].concat(_toConsumableArray(_ads2), _toConsumableArray(_otherads2)));
2953
- //更新
3299
+
3300
+ t.addCircle([].concat(_toConsumableArray(_ads2), _toConsumableArray(_otherads2))); //更新
3301
+
2954
3302
  t.updateCircle([].concat(_toConsumableArray(_upds2), _toConsumableArray(_otherupds2)));
2955
3303
  }
2956
3304
  /*
2957
3305
  线数据处理
2958
3306
  先全删除,再新增
2959
3307
  */
3308
+
3309
+
2960
3310
  if (mapLines instanceof Array && props.mapLines instanceof Array && !t.deepEqual(mapLines, props.mapLines)) {
2961
3311
  var oldMapLines = props.mapLines;
2962
3312
  var newMapLines = mapLines;
3313
+
2963
3314
  if (!!t.state.editId) {
2964
3315
  oldMapLines = props.mapLines.filter(function (item) {
2965
3316
  return item.id !== editGraphicId;
@@ -2968,43 +3319,52 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
2968
3319
  return item.id !== editGraphicId;
2969
3320
  });
2970
3321
  }
3322
+
2971
3323
  var _t$dataMatch5 = t.dataMatch(oldMapLines, newMapLines, 'id'),
2972
- _deletedDataIDs4 = _t$dataMatch5.deletedDataIDs,
2973
- _addedData4 = _t$dataMatch5.addedData,
2974
- _updatedData4 = _t$dataMatch5.updatedData;
3324
+ _deletedDataIDs4 = _t$dataMatch5.deletedDataIDs,
3325
+ _addedData4 = _t$dataMatch5.addedData,
3326
+ _updatedData4 = _t$dataMatch5.updatedData;
3327
+
2975
3328
  var _t$dealAdd4 = t.dealAdd(_addedData4, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
2976
- _ads3 = _t$dealAdd4.ads,
2977
- _otherupds3 = _t$dealAdd4.otherupds;
3329
+ _ads3 = _t$dealAdd4.ads,
3330
+ _otherupds3 = _t$dealAdd4.otherupds;
3331
+
2978
3332
  var _t$dealUpdate4 = t.dealUpdate(_updatedData4, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
2979
- _upds3 = _t$dealUpdate4.upds,
2980
- _otherads3 = _t$dealUpdate4.otherads;
2981
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3333
+ _upds3 = _t$dealUpdate4.upds,
3334
+ _otherads3 = _t$dealUpdate4.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3335
+
3336
+
2982
3337
  var _iterator4 = _createForOfIteratorHelper(_deletedDataIDs4),
2983
- _step4;
3338
+ _step4;
3339
+
2984
3340
  try {
2985
3341
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
2986
3342
  var _id3 = _step4.value;
2987
3343
  t.removeGraphic(_id3, 'line');
2988
- }
2989
- //增加
3344
+ } //增加
3345
+
2990
3346
  } catch (err) {
2991
3347
  _iterator4.e(err);
2992
3348
  } finally {
2993
3349
  _iterator4.f();
2994
3350
  }
2995
- t.addLine([].concat(_toConsumableArray(_ads3), _toConsumableArray(_otherads3)));
2996
- //更新
3351
+
3352
+ t.addLine([].concat(_toConsumableArray(_ads3), _toConsumableArray(_otherads3))); //更新
3353
+
2997
3354
  t.updateLine([].concat(_toConsumableArray(_upds3), _toConsumableArray(_otherupds3)));
2998
- }
2999
- //画其他特例线专用
3355
+ } //画其他特例线专用
3356
+
3357
+
3000
3358
  if (customizedBoundary instanceof Array && props.customizedBoundary instanceof Array && !t.deepEqual(customizedBoundary, props.customizedBoundary)) {
3001
3359
  var _t$dataMatch6 = t.dataMatch(props.customizedBoundary, customizedBoundary, 'id'),
3002
- _deletedDataIDs5 = _t$dataMatch6.deletedDataIDs,
3003
- _addedData5 = _t$dataMatch6.addedData,
3004
- _updatedData5 = _t$dataMatch6.updatedData;
3005
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3360
+ _deletedDataIDs5 = _t$dataMatch6.deletedDataIDs,
3361
+ _addedData5 = _t$dataMatch6.addedData,
3362
+ _updatedData5 = _t$dataMatch6.updatedData; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3363
+
3364
+
3006
3365
  var _iterator5 = _createForOfIteratorHelper(_deletedDataIDs5),
3007
- _step5;
3366
+ _step5;
3367
+
3008
3368
  try {
3009
3369
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3010
3370
  var _id4 = _step5.value;
@@ -3015,10 +3375,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
3015
3375
  } finally {
3016
3376
  _iterator5.f();
3017
3377
  }
3378
+
3018
3379
  t.updateLine(_updatedData5);
3019
3380
  t.addLine(_addedData5);
3020
- }
3021
- //绘制边界线
3381
+ } //绘制边界线
3382
+
3383
+
3022
3384
  if (boundaryName instanceof Array && props.boundaryName instanceof Array && !t.deepEqual(boundaryName, props.boundaryName)) {
3023
3385
  var newBDName = Set(boundaryName);
3024
3386
  var oldBDName = Set(props.boundaryName);
@@ -3026,100 +3388,128 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
3026
3388
  var addedBoundaryName = newBDName.subtract(oldBDName).toJS();
3027
3389
  t.removeBaiduBoundary(removedBoundaryName);
3028
3390
  t.addBaiduBoundary(addedBoundaryName);
3029
- }
3030
- // 获取热力图
3391
+ } // 获取热力图
3392
+
3393
+
3031
3394
  if (heatMapData && !t.deepEqual(heatMapData, props.heatMapData)) {
3032
3395
  t.heatMapOverlay(heatMapData);
3033
- }
3034
- // 打开信息窗体
3396
+ } // 打开信息窗体
3397
+
3398
+
3035
3399
  if (infoWindowData && !t.deepEqual(infoWindowData, t.props.infoWindowData)) {
3036
3400
  t.infoWindow(infoWindowData);
3037
- }
3038
- //添加图片图层
3401
+ } //添加图片图层
3402
+
3403
+
3039
3404
  if (imageOverlays instanceof Array && props.imageOverlays instanceof Array && !t.deepEqual(imageOverlays, props.imageOverlays)) {
3040
3405
  t.imageUrlOverlay(imageOverlays);
3041
- }
3042
- //图元编辑调用
3406
+ } //图元编辑调用
3407
+
3408
+
3043
3409
  if (typeof isDoEdit == 'boolean' && isDoEdit || isDoEdit && isDoEdit !== t.props.isDoEdit) {
3044
3410
  t.doEdit(editGraphicId);
3045
- }
3046
- //是否关闭图元编辑
3411
+ } //是否关闭图元编辑
3412
+
3413
+
3047
3414
  if (typeof isEndEdit == 'boolean' && isEndEdit || isEndEdit && isEndEdit !== t.props.isEndEdit) {
3048
3415
  t.endEdit();
3049
3416
  }
3050
3417
  /*设置指定图元展示*/
3418
+
3419
+
3051
3420
  if (typeof setVisiblePoints == 'boolean' && setVisiblePoints || setVisiblePoints && setVisiblePoints !== t.props.setVisiblePoints) {
3052
3421
  t.setVisiblePoints(mapVisiblePoints);
3053
- }
3054
- //绘制图元
3422
+ } //绘制图元
3423
+
3424
+
3055
3425
  if (typeof isDraw == 'boolean' && isDraw || isDraw && isDraw !== t.props.isDraw) {
3056
3426
  t.draw(mapDraw);
3057
- }
3058
- //关闭绘制
3427
+ } //关闭绘制
3428
+
3429
+
3059
3430
  if (typeof isCloseDraw == 'boolean' && isCloseDraw || isCloseDraw && isCloseDraw !== t.props.isCloseDraw) {
3060
3431
  t.closeDraw();
3061
- }
3062
- //清空地图
3432
+ } //清空地图
3433
+
3434
+
3063
3435
  if (typeof isClearAll == 'boolean' && isClearAll || isClearAll && isClearAll !== t.props.isClearAll) {
3064
3436
  t.clearAll();
3065
- }
3066
- //设置中心点
3437
+ } //设置中心点
3438
+
3439
+
3067
3440
  if (typeof setCenter == 'boolean' && setCenter || setCenter && setCenter !== t.props.setCenter) {
3068
3441
  if (!(t.getCurrentCenter().lng == mapCenter[0] && t.getCurrentCenter().lat == mapCenter[1])) {
3069
3442
  t.setCenter(mapCenter);
3070
3443
  }
3071
- }
3072
- //设置比例尺
3444
+ } //设置比例尺
3445
+
3446
+
3073
3447
  if (typeof setZoomLevel == 'boolean' && setZoomLevel || setZoomLevel && setZoomLevel !== t.props.setZoomLevel) {
3074
3448
  if (!(t.getZoomLevel() == mapZoomLevel)) {
3075
3449
  t.setZoomLevel(mapZoomLevel);
3076
3450
  }
3077
- }
3078
- //是否打开路况
3451
+ } //是否打开路况
3452
+
3453
+
3079
3454
  if (isOpenTrafficInfo) {
3080
3455
  t.openTrafficInfo();
3081
3456
  } else {
3082
3457
  t.hideTrafficInfo();
3083
- }
3084
- //设置点聚合
3458
+ } //设置点聚合
3459
+
3460
+
3085
3461
  if (typeof setCluster == 'boolean' && setCluster || setCluster && setCluster !== t.props.setCluster) {
3086
3462
  t.cluster(mapCluster);
3087
- }
3088
- //测距工具调用
3463
+ } // 清除聚合
3464
+
3465
+
3466
+ if (!setCluster && setCluster !== t.props.setCluster) {
3467
+ t.removeCluster(mapCluster);
3468
+ } //测距工具调用
3469
+
3470
+
3089
3471
  if (typeof isRangingTool == 'boolean' && isRangingTool || isRangingTool && isRangingTool !== t.props.isRangingTool) {
3090
3472
  t.vtxRangingTool();
3091
- }
3092
- //单独删除操作
3473
+ } //单独删除操作
3474
+
3475
+
3093
3476
  if (typeof isRemove == 'boolean' && isRemove || isRemove && isRemove !== t.props.isRemove) {
3094
3477
  mapRemove.map(function (item, index) {
3095
3478
  t.removeGraphic(item.id, item.type);
3096
3479
  });
3097
- }
3098
- //设置区域限制
3480
+ } //设置区域限制
3481
+
3482
+
3099
3483
  if (typeof isSetAreaRestriction == 'boolean' && isSetAreaRestriction || isSetAreaRestriction && isSetAreaRestriction !== t.props.isSetAreaRestriction && areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
3100
3484
  t.setAreaRestriction(areaRestriction);
3101
- }
3102
- //关闭区域限制
3485
+ } //关闭区域限制
3486
+
3487
+
3103
3488
  if (typeof isClearAreaRestriction == 'boolean' && isClearAreaRestriction || isClearAreaRestriction && isClearAreaRestriction !== t.props.isClearAreaRestriction) {
3104
3489
  t.clearAreaRestriction();
3105
- }
3490
+ } // 比例尺控件位置改变
3491
+
3106
3492
 
3107
- // 比例尺控件位置改变
3108
3493
  if (nextProps.showControl && JSON.stringify(nextProps.showControl) != JSON.stringify(t.props.showControl)) {
3109
3494
  t.showControl(nextProps);
3110
- }
3111
- // 比例尺移除
3495
+ } // 比例尺移除
3496
+
3497
+
3112
3498
  if (!nextProps.showControl) {
3113
3499
  t.removeControl();
3114
- }
3115
- // 地图类型控件位置改变
3500
+ } // 地图类型控件位置改变
3501
+
3502
+
3116
3503
  if (nextProps.satelliteSwitch && JSON.stringify(nextProps.satelliteSwitch) != JSON.stringify(t.props.satelliteSwitch)) {
3117
3504
  t.showMapTypeControl(nextProps);
3118
3505
  }
3119
3506
  }
3120
3507
  }]);
3508
+
3121
3509
  return VortexAMap;
3122
3510
  }(_react["default"].Component);
3123
- var _default = exports["default"] = VortexAMap;
3511
+
3512
+ var _default = VortexAMap;
3513
+ exports["default"] = _default;
3124
3514
  module.exports = exports["default"];
3125
3515
  //# sourceMappingURL=AMap.js.map