@vtx/map 1.1.49 → 1.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/lib/VtxMap/AMap/AMap.js +1003 -633
  2. package/lib/VtxMap/AMap/AMap.js.map +1 -1
  3. package/lib/VtxMap/BMap/Map.js +1198 -749
  4. package/lib/VtxMap/BMap/Map.js.map +1 -1
  5. package/lib/VtxMap/GMap/Map.js +1564 -1046
  6. package/lib/VtxMap/GMap/Map.js.map +1 -1
  7. package/lib/VtxMap/Map.js +42 -8
  8. package/lib/VtxMap/Map.js.map +1 -1
  9. package/lib/VtxMap/MapToolFunction.js +63 -26
  10. package/lib/VtxMap/MapToolFunction.js.map +1 -1
  11. package/lib/VtxMap/OMap/Map.js +1361 -867
  12. package/lib/VtxMap/OMap/Map.js.map +1 -1
  13. package/lib/VtxMap/OlMap/Map.js +1243 -722
  14. package/lib/VtxMap/OlMap/Map.js.map +1 -1
  15. package/lib/VtxMap/TMap/TMap.js +1059 -652
  16. package/lib/VtxMap/TMap/TMap.js.map +1 -1
  17. package/lib/VtxMap/index.js +8 -1
  18. package/lib/VtxMap/index.js.map +1 -1
  19. package/lib/VtxMap/mapPlayer.js +123 -67
  20. package/lib/VtxMap/mapPlayer.js.map +1 -1
  21. package/lib/VtxMap/optimizingPointMap.js +77 -21
  22. package/lib/VtxMap/optimizingPointMap.js.map +1 -1
  23. package/lib/VtxMap/style/css.js +6 -0
  24. package/lib/VtxMap/style/css.js.map +1 -1
  25. package/lib/VtxMap/style/index.js +6 -0
  26. package/lib/VtxMap/style/index.js.map +1 -1
  27. package/lib/VtxMap/zoomMap.js +41 -12
  28. package/lib/VtxMap/zoomMap.js.map +1 -1
  29. package/lib/VtxModal/VtxModal.js +63 -19
  30. package/lib/VtxModal/VtxModal.js.map +1 -1
  31. package/lib/VtxModal/draggableModal.js +48 -12
  32. package/lib/VtxModal/draggableModal.js.map +1 -1
  33. package/lib/VtxModal/index.js +6 -1
  34. package/lib/VtxModal/index.js.map +1 -1
  35. package/lib/VtxModal/style/css.js +6 -0
  36. package/lib/VtxModal/style/css.js.map +1 -1
  37. package/lib/VtxModal/style/index.js +6 -0
  38. package/lib/VtxModal/style/index.js.map +1 -1
  39. package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js +238 -105
  40. package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js.map +1 -1
  41. package/lib/VtxSearchCheckMap/index.js +2 -0
  42. package/lib/VtxSearchCheckMap/index.js.map +1 -1
  43. package/lib/VtxSearchCheckMap/mapping.js +2 -1
  44. package/lib/VtxSearchCheckMap/mapping.js.map +1 -1
  45. package/lib/VtxSearchCheckMap/style/css.js +19 -0
  46. package/lib/VtxSearchCheckMap/style/css.js.map +1 -1
  47. package/lib/VtxSearchCheckMap/style/index.js +19 -0
  48. package/lib/VtxSearchCheckMap/style/index.js.map +1 -1
  49. package/lib/VtxSearchMap/VtxSearchMap.js +229 -91
  50. package/lib/VtxSearchMap/VtxSearchMap.js.map +1 -1
  51. package/lib/VtxSearchMap/index.js +2 -0
  52. package/lib/VtxSearchMap/index.js.map +1 -1
  53. package/lib/VtxSearchMap/mapping.js +2 -1
  54. package/lib/VtxSearchMap/mapping.js.map +1 -1
  55. package/lib/VtxSearchMap/style/css.js +19 -0
  56. package/lib/VtxSearchMap/style/css.js.map +1 -1
  57. package/lib/VtxSearchMap/style/index.js +19 -0
  58. package/lib/VtxSearchMap/style/index.js.map +1 -1
  59. package/lib/default.js +19 -4
  60. package/lib/default.js.map +1 -1
  61. package/lib/index.js +3 -0
  62. package/lib/index.js.map +1 -1
  63. package/lib/utils/util.js +17 -5
  64. package/lib/utils/util.js.map +1 -1
  65. package/package.json +1 -1
@@ -1,42 +1,69 @@
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 _unionBy = _interopRequireDefault(require("lodash/unionBy"));
19
+
13
20
  var _default2 = _interopRequireDefault(require("../../default"));
21
+
14
22
  var _antd = require("antd");
23
+
15
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
+
16
26
  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; } } }; }
17
- 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; }
18
- 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; }
19
- 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; }
27
+
28
+ 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; }
29
+
30
+ 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; }
31
+
32
+ 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; }
33
+
20
34
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
35
+
21
36
  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."); }
37
+
22
38
  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); }
39
+
23
40
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
41
+
24
42
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
25
- 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; }
43
+
44
+ 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; }
45
+
26
46
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27
- 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); } }
47
+
48
+ 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); } }
49
+
28
50
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
29
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
30
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
51
+
31
52
  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); }
53
+
32
54
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
55
+
33
56
  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); }; }
57
+
34
58
  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); }
59
+
35
60
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
61
+
36
62
  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; } }
63
+
37
64
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
38
- var Set = _immutable["default"].Set;
39
- //公共地址配置
65
+
66
+ var Set = _immutable["default"].Set; //公共地址配置
40
67
 
41
68
  // 百度地图js文件内做了一些额外的http or https判断
42
69
  // 如果协议为Https,我们需要改动全局变量BMAP_PROTOCOL和BMap_loadScriptTime
@@ -44,6 +71,7 @@ if (window.location.protocol === 'https:') {
44
71
  window.BMAP_PROTOCOL = "https";
45
72
  window.BMap_loadScriptTime = new Date().getTime();
46
73
  }
74
+
47
75
  var gisMapConstant = {
48
76
  circle: 'BMAP_POINT_SHAPE_CIRCLE',
49
77
  //圆形
@@ -68,28 +96,47 @@ var gisMapConstant = {
68
96
  bigger: 6,
69
97
  //定义点的尺寸为很大,宽高为20px*20px
70
98
  huge: 7 //定义点的尺寸为超大,宽高为30px*30px
99
+
71
100
  };
101
+
72
102
  var BaiduMap = /*#__PURE__*/function (_React$Component) {
73
103
  _inherits(BaiduMap, _React$Component);
104
+
74
105
  var _super = _createSuper(BaiduMap);
106
+
75
107
  function BaiduMap(props) {
76
108
  var _this;
109
+
77
110
  _classCallCheck(this, BaiduMap);
111
+
78
112
  _this = _super.call(this, props);
79
113
  _this.GM = new _MapToolFunction.graphicManage(); //初始化 图元管理方法
114
+
80
115
  _this.getPolygonArea = _MapToolFunction.getPolygonArea;
81
116
  _this.initPointIndex = 0; //初始化地图时记录点当前位置
117
+
82
118
  _this._cluster = null; //点聚合对象
119
+
83
120
  _this._rangingTool = null; //测距对象
121
+
84
122
  _this._bmar = null; //区域限制对象
123
+
85
124
  _this._drawmanager = null; //图元绘制对象
125
+
86
126
  _this.editGraphicChange = null; //编辑方法回调
127
+
87
128
  _this.editTimeout = null; //圆编辑回调延迟时间对象
129
+
88
130
  _this._boundary = null; //获取行政区域数据的对象
131
+
89
132
  _this.moveToTimer = null; //moveTo时间对象
133
+
90
134
  _this.heatmap = null; //热力图对象
135
+
91
136
  _this.morepoints = []; //海量点数组
137
+
92
138
  _this.movePoints = []; //移动点的动画集合
139
+
93
140
  _this.popupWindow = null;
94
141
  _this.mapCreated = false;
95
142
  _this.state = {
@@ -120,13 +167,17 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
120
167
  }
121
168
  };
122
169
  _this.frameSelectProps = {};
170
+
123
171
  _this.loadMapJs();
172
+
124
173
  return _this;
125
174
  }
175
+
126
176
  _createClass(BaiduMap, [{
127
177
  key: "loadPlugin",
128
178
  value: function loadPlugin() {
129
179
  var loadList = [];
180
+
130
181
  if (!window.BMapLib || !window.BMapLib.DistanceTool) {
131
182
  loadList.push(new Promise(function (resolve, reject) {
132
183
  $.getScript("".concat(_default2["default"].mapServerURL, "/DistanceTool_min.js"), function () {
@@ -134,6 +185,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
134
185
  });
135
186
  }));
136
187
  }
188
+
137
189
  if (!window.BMapLib || !window.BMapLib.TrafficControl) {
138
190
  loadList.push(new Promise(function (resolve, reject) {
139
191
  $.getScript("".concat(_default2["default"].mapServerURL, "/TrafficControl_min.js"), function () {
@@ -141,6 +193,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
141
193
  });
142
194
  }));
143
195
  }
196
+
144
197
  if (!window.BMapLib || !window.BMapLib.MarkerClusterer) {
145
198
  loadList.push(new Promise(function (resolve, reject) {
146
199
  $.getScript("".concat(_default2["default"].mapServerURL, "/MarkerClusterer_min.js"), function () {
@@ -148,6 +201,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
148
201
  });
149
202
  }));
150
203
  }
204
+
151
205
  if (!window.BMapLib || !window.BMapLib.AreaRestriction) {
152
206
  loadList.push(new Promise(function (resolve, reject) {
153
207
  $.getScript("".concat(_default2["default"].mapServerURL, "/AreaRestriction_min.js"), function () {
@@ -155,6 +209,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
155
209
  });
156
210
  }));
157
211
  }
212
+
158
213
  if (!window.BMapLib || !window.BMapLib.DrawingManager) {
159
214
  loadList.push(new Promise(function (resolve, reject) {
160
215
  $.getScript("".concat(_default2["default"].mapServerURL, "/DrawingManager_min.js"), function () {
@@ -162,6 +217,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
162
217
  });
163
218
  }));
164
219
  }
220
+
165
221
  if (!window.BMapLib || !window.BMapLib.HeatmapOverlay) {
166
222
  loadList.push(new Promise(function (resolve, reject) {
167
223
  $.getScript("".concat(_default2["default"].mapServerURL, "/Heatmap_min.js"), function () {
@@ -169,6 +225,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
169
225
  });
170
226
  }));
171
227
  }
228
+
172
229
  if (!window.BMapLib || !window.BMapLib.GeoUtils) {
173
230
  loadList.push(new Promise(function (resolve, reject) {
174
231
  $.getScript("".concat(_default2["default"].mapServerURL, "/GeoUtils_min.js"), function () {
@@ -176,6 +233,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
176
233
  });
177
234
  }));
178
235
  }
236
+
179
237
  if (!window.BMapLib || !window.BMapLib.TextIconOverlay) {
180
238
  loadList.push(new Promise(function (resolve, reject) {
181
239
  $.getScript("".concat(_default2["default"].mapServerURL, "/TextIconOverlay_min.js"), function () {
@@ -183,6 +241,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
183
241
  });
184
242
  }));
185
243
  }
244
+
186
245
  if (!window.BMapLib || !window.BMapLib.InfoBox) {
187
246
  loadList.push(new Promise(function (resolve, reject) {
188
247
  $.getScript("".concat(_default2["default"].mapServerURL, "/InfoBox_min.js"), function () {
@@ -191,6 +250,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
191
250
  }));
192
251
  loadList.push();
193
252
  }
253
+
194
254
  loadList.push(new Promise(function (resolve, reject) {
195
255
  $.getScript("".concat(_default2["default"].mapServerURL, "/TextIconOverlay_min.js"), function () {
196
256
  resolve();
@@ -204,12 +264,13 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
204
264
  key: "loadMapJs",
205
265
  value: function loadMapJs() {
206
266
  var _this2 = this;
267
+
207
268
  this.loadMapComplete = new Promise(function (resolve, reject) {
208
269
  if (window.BMap) {
209
270
  resolve(_this2.loadPlugin());
210
271
  } else {
211
272
  // EVlFc6DZzAzU5avIjoxNcFgQ
212
- $.getScript('//api.map.baidu.com/getscript?v=3.0&ak=42IughV5lDxAt0wI8AhDVuGR', function () {
273
+ $.getScript(_default2["default"].bmapScriptUrl, function () {
213
274
  resolve(_this2.loadPlugin());
214
275
  });
215
276
  $("<link>").attr({
@@ -219,147 +280,165 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
219
280
  }).appendTo("head");
220
281
  }
221
282
  });
222
- }
223
- //初始化地图数据
283
+ } //初始化地图数据
284
+
224
285
  }, {
225
286
  key: "init",
226
287
  value: function init() {
227
- var t = this;
228
- //创建地图
288
+ var t = this; //创建地图
289
+
229
290
  t.createMap();
230
291
  var _this$props = this.props,
231
- mapPoints = _this$props.mapPoints,
232
- mapLines = _this$props.mapLines,
233
- mapPolygons = _this$props.mapPolygons,
234
- mapCircles = _this$props.mapCircles,
235
- imageOverlays = _this$props.imageOverlays,
236
- mapVisiblePoints = _this$props.mapVisiblePoints,
237
- mapCluster = _this$props.mapCluster,
238
- mapZoomLevel = _this$props.mapZoomLevel,
239
- isOpenTrafficInfo = _this$props.isOpenTrafficInfo,
240
- mapPointCollection = _this$props.mapPointCollection,
241
- areaRestriction = _this$props.areaRestriction,
242
- coverageType = _this$props.coverageType;
292
+ mapPoints = _this$props.mapPoints,
293
+ mapLines = _this$props.mapLines,
294
+ mapPolygons = _this$props.mapPolygons,
295
+ mapCircles = _this$props.mapCircles,
296
+ imageOverlays = _this$props.imageOverlays,
297
+ mapVisiblePoints = _this$props.mapVisiblePoints,
298
+ mapCluster = _this$props.mapCluster,
299
+ mapZoomLevel = _this$props.mapZoomLevel,
300
+ isOpenTrafficInfo = _this$props.isOpenTrafficInfo,
301
+ mapPointCollection = _this$props.mapPointCollection,
302
+ areaRestriction = _this$props.areaRestriction,
303
+ coverageType = _this$props.coverageType;
243
304
  var _this$props2 = this.props,
244
- boundaryName = _this$props2.boundaryName,
245
- heatMapData = _this$props2.heatMapData,
246
- infoWindowData = _this$props2.infoWindowData,
247
- customizedBoundary = _this$props2.customizedBoundary;
305
+ boundaryName = _this$props2.boundaryName,
306
+ heatMapData = _this$props2.heatMapData,
307
+ infoWindowData = _this$props2.infoWindowData,
308
+ customizedBoundary = _this$props2.customizedBoundary;
248
309
  var _this$state = this.state,
249
- boundaryInfo = _this$state.boundaryInfo,
250
- pointIds = _this$state.pointIds,
251
- lineIds = _this$state.lineIds,
252
- polygonIds = _this$state.polygonIds,
253
- circleIds = _this$state.circleIds;
254
- // 切换地图矢量图和卫星图背景
310
+ boundaryInfo = _this$state.boundaryInfo,
311
+ pointIds = _this$state.pointIds,
312
+ lineIds = _this$state.lineIds,
313
+ polygonIds = _this$state.polygonIds,
314
+ circleIds = _this$state.circleIds; // 切换地图矢量图和卫星图背景
315
+
255
316
  if (coverageType) {
256
317
  t.setMapType(coverageType);
257
- }
258
- //添加点
318
+ } //添加点
319
+
320
+
259
321
  if (mapPoints instanceof Array) {
260
322
  t.addPoint(mapPoints);
261
- }
262
- //添加线
323
+ } //添加线
324
+
325
+
263
326
  if (mapLines instanceof Array) {
264
327
  t.addLine(mapLines);
265
- }
266
- //添加面
328
+ } //添加面
329
+
330
+
267
331
  if (mapPolygons instanceof Array) {
268
332
  t.addPolygon(mapPolygons);
269
- }
270
- //添加圆
333
+ } //添加圆
334
+
335
+
271
336
  if (mapCircles instanceof Array) {
272
337
  t.addCircle(mapCircles);
273
- }
274
- //添加图片图层
338
+ } //添加图片图层
339
+
340
+
275
341
  if (imageOverlays instanceof Array) {
276
342
  t.imageUrlOverlay(imageOverlays);
277
- }
278
- //画边界线
343
+ } //画边界线
344
+
345
+
279
346
  if (boundaryName instanceof Array && boundaryName.length > 0) {
280
347
  t.addBaiduBoundary(boundaryName);
281
- }
282
- // 画热力图
348
+ } // 画热力图
349
+
350
+
283
351
  if (heatMapData) {
284
352
  t.heatMapOverlay(heatMapData);
285
- }
286
- // 打开信息窗体
353
+ } // 打开信息窗体
354
+
355
+
287
356
  if (infoWindowData) {
288
357
  t.infoWindow(infoWindowData);
289
358
  }
359
+
290
360
  if (mapPointCollection instanceof Array) {
291
361
  t.addPointCollection(mapPointCollection);
292
- }
293
- //初始展示的视野范围
362
+ } //初始展示的视野范围
363
+
364
+
294
365
  if (mapVisiblePoints) {
295
366
  t.setVisiblePoints(mapVisiblePoints);
296
- }
297
- //设置点聚合
367
+ } //设置点聚合
368
+
369
+
298
370
  if (mapCluster instanceof Array) {
299
371
  t.cluster(mapCluster);
300
- }
301
- //开关路况
372
+ } //开关路况
373
+
374
+
302
375
  if (isOpenTrafficInfo) {
303
376
  t.openTrafficInfo();
304
377
  } else {
305
378
  t.hideTrafficInfo();
306
- }
307
- //设置区域限制
379
+ } //设置区域限制
380
+
381
+
308
382
  if (areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
309
383
  t.setAreaRestriction(areaRestriction);
310
- }
311
- //是否设置比例尺
384
+ } //是否设置比例尺
385
+
386
+
312
387
  if (t.props.showControl) {
313
388
  t.showControl();
314
389
  }
315
390
  /*地图事件*/
316
391
  //初始化地图点击事件
317
- t.clickMap();
318
- //地图拖动之前事件
319
- t.dragMapStart();
320
- //地图拖动结束后事件
321
- t.dragMapEnd();
322
- //地图移动之前事件
323
- t.moveStart();
324
- //地图移动结束后事件
325
- t.moveEnd();
326
- //地图缩放开始前事件
327
- t.zoomStart();
328
- //地图缩放结束后事件
392
+
393
+
394
+ t.clickMap(); //地图拖动之前事件
395
+
396
+ t.dragMapStart(); //地图拖动结束后事件
397
+
398
+ t.dragMapEnd(); //地图移动之前事件
399
+
400
+ t.moveStart(); //地图移动结束后事件
401
+
402
+ t.moveEnd(); //地图缩放开始前事件
403
+
404
+ t.zoomStart(); //地图缩放结束后事件
405
+
329
406
  t.zoomEnd();
330
407
  this.mapCreated = true;
331
- }
332
- //创建地图
408
+ } //创建地图
409
+
333
410
  }, {
334
411
  key: "createMap",
335
412
  value: function createMap() {
336
413
  var t = this;
337
414
  var _t$props = t.props,
338
- mapCenter = _t$props.mapCenter,
339
- mapStyle = _t$props.mapStyle,
340
- mapId = _t$props.mapId,
341
- mapZoomLevel = _t$props.mapZoomLevel,
342
- minZoom = _t$props.minZoom,
343
- maxZoom = _t$props.maxZoom;
415
+ mapCenter = _t$props.mapCenter,
416
+ mapStyle = _t$props.mapStyle,
417
+ mapId = _t$props.mapId,
418
+ mapZoomLevel = _t$props.mapZoomLevel,
419
+ minZoom = _t$props.minZoom,
420
+ maxZoom = _t$props.maxZoom;
344
421
  var options = {
345
422
  zoom: mapZoomLevel || 10,
346
423
  center: mapCenter || [116.404, 39.915],
347
424
  minZoom: minZoom,
348
425
  maxZoom: maxZoom
349
426
  };
427
+
350
428
  if (window.VtxMap) {
351
429
  window.VtxMap[mapId] = null;
352
430
  } else {
353
431
  window.VtxMap = {};
354
- }
355
- // 控件位置常量
432
+ } // 控件位置常量
433
+
434
+
356
435
  t.AnchorConstant = {
357
436
  tr: BMAP_ANCHOR_TOP_RIGHT,
358
437
  tl: BMAP_ANCHOR_TOP_LEFT,
359
438
  bl: BMAP_ANCHOR_BOTTOM_LEFT,
360
439
  br: BMAP_ANCHOR_BOTTOM_RIGHT
361
- };
362
- // 平移缩放控件大小
440
+ }; // 平移缩放控件大小
441
+
363
442
  t.NavigationConstant = {
364
443
  large: BMAP_NAVIGATION_CONTROL_LARGE,
365
444
  small: BMAP_NAVIGATION_CONTROL_SMALL,
@@ -371,73 +450,85 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
371
450
  minZoom: options.minZoom,
372
451
  maxZoom: options.maxZoom
373
452
  });
453
+
374
454
  if (mapStyle) {
375
455
  if (typeof mapStyle === 'string') {
376
456
  t.state.gis.setMapStyle({
377
457
  style: mapStyle
378
458
  });
379
459
  }
460
+
380
461
  if (mapStyle instanceof Array) {
381
462
  t.state.gis.setMapStyle({
382
463
  styleJson: mapStyle
383
464
  });
384
465
  }
385
466
  }
467
+
386
468
  setTimeout(function () {
387
469
  $('#myCanvasElement').parent().children('svg').css({
388
470
  'z-index': 1
389
471
  });
390
- }, 500);
391
- // 初始化地图,设置中心点坐标和地图级别
392
- map.centerAndZoom(new BMap.Point(parseFloat(options.center[0]), parseFloat(options.center[1])), options.zoom);
393
- //添加地图类型控件
472
+ }, 500); // 初始化地图,设置中心点坐标和地图级别
473
+
474
+ map.centerAndZoom(new BMap.Point(parseFloat(options.center[0]), parseFloat(options.center[1])), options.zoom); //添加地图类型控件
475
+
394
476
  if (t.props.satelliteSwitch) {
395
477
  t.showMapTypeControl();
396
- }
397
- //初始化路况控件
478
+ } //初始化路况控件
479
+
480
+
398
481
  if (!t._trafficCtrl) {
399
482
  t._trafficCtrl = new BMapLib.TrafficControl({
400
483
  // 是否显示路况提示面板
401
484
  showPanel: false
402
485
  });
403
486
  map.addControl(t._trafficCtrl);
487
+
404
488
  if (document.getElementById('tcBtn').remove) {
405
489
  document.getElementById('tcBtn').remove();
406
490
  } else {
407
491
  document.getElementById('tcBtn').removeNode();
408
492
  }
409
- }
410
- //开启鼠标滚轮缩放
411
- map.enableScrollWheelZoom(true);
412
- //初始化获取行政区域数据的对象
493
+ } //开启鼠标滚轮缩放
494
+
495
+
496
+ map.enableScrollWheelZoom(true); //初始化获取行政区域数据的对象
497
+
413
498
  if (!t._boundary) {
414
499
  t._boundary = new BMap.Boundary();
415
- }
416
- //初始化点聚合对象
500
+ } //初始化点聚合对象
501
+
502
+
417
503
  if (!t._cluster) {
418
504
  t._cluster = new BMapLib.MarkerClusterer(map, {
419
505
  maxZoom: 17
420
506
  });
421
- }
422
- //初始化测距对象
507
+ } //初始化测距对象
508
+
509
+
423
510
  if (!t._rangingTool) {
424
511
  t._rangingTool = new BMapLib.DistanceTool(map);
425
- }
426
- //初始化区域限制对象
512
+ } //初始化区域限制对象
513
+
514
+
427
515
  if (!t._bmar) {
428
516
  t._bmar = new BMapLib.AreaRestriction();
429
- }
430
- //初始化图元绘制对象
517
+ } //初始化图元绘制对象
518
+
519
+
431
520
  if (!t._drawmanager) {
432
- t._drawmanager = new BMapLib.DrawingManager(map);
433
- //监听绘制结束事件
521
+ t._drawmanager = new BMapLib.DrawingManager(map); //监听绘制结束事件
522
+
434
523
  t._drawmanager.addEventListener('overlaycomplete', function (e) {
435
524
  var _t$frameSelectProps$b;
525
+
436
526
  if (e.label) {
437
527
  t.state.gis.removeOverlay(e.label);
438
528
  }
439
- var drawExtData = e.extData;
440
- //保存绘制图元的id便于后期比对
529
+
530
+ var drawExtData = e.extData; //保存绘制图元的id便于后期比对
531
+
441
532
  t.state.drawIds[drawExtData.type].push(drawExtData.id);
442
533
  var backobj = {
443
534
  id: drawExtData.id,
@@ -447,51 +538,55 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
447
538
  geometry: {
448
539
  type: drawExtData.type == 'rectangle' ? 'polygon' : drawExtData.type
449
540
  }
450
- };
451
- //点击事件
541
+ }; //点击事件
542
+
452
543
  e.overlay.addEventListener('click', function (e) {
453
544
  t.clickGraphic(drawExtData.id, e);
454
- });
455
- //鼠标移入事件
545
+ }); //鼠标移入事件
546
+
456
547
  e.overlay.addEventListener('mouseover', function (e) {
457
548
  t.mouseOverGraphic(drawExtData.id, e);
458
- });
459
- //鼠标移出事件
549
+ }); //鼠标移出事件
550
+
460
551
  e.overlay.addEventListener('mouseout', function (e) {
461
552
  t.mouseOutGraphic(drawExtData.id, e);
462
- });
463
- //缓存绘制的图元信息
464
- t.GM.setGraphic(drawExtData.id, e.overlay);
553
+ }); //缓存绘制的图元信息
554
+
555
+ t.GM.setGraphic(drawExtData.id, e.overlay); //区别点和圆的经纬度数据处理
465
556
 
466
- //区别点和圆的经纬度数据处理
467
557
  var _t$dealData = t.dealData(e.overlay),
468
- lnglatAry = _t$dealData.lnglatAry,
469
- _extent = _t$dealData._extent,
470
- path = _t$dealData.path;
471
- //处理返回数据
558
+ lnglatAry = _t$dealData.lnglatAry,
559
+ _extent = _t$dealData._extent,
560
+ path = _t$dealData.path; //处理返回数据
561
+
562
+
472
563
  switch (drawExtData.type) {
473
564
  case 'point':
474
565
  backobj.geometry.x = e.overlay.getPosition().lng;
475
566
  backobj.geometry.y = e.overlay.getPosition().lat;
476
567
  break;
568
+
477
569
  case 'polyline':
478
570
  backobj.distance = e.calculate;
479
571
  backobj.lnglatAry = lnglatAry;
480
572
  backobj.geometry.paths = path;
481
573
  backobj.geometry._extent = _extent;
482
574
  break;
575
+
483
576
  case 'polygon':
484
577
  backobj.area = e.calculate;
485
578
  backobj.lnglatAry = lnglatAry;
486
579
  backobj.geometry.rings = path;
487
580
  backobj.geometry._extent = _extent;
488
581
  break;
582
+
489
583
  case 'rectangle':
490
584
  backobj.area = e.calculate;
491
585
  backobj.lnglatAry = lnglatAry;
492
586
  backobj.geometry.rings = path;
493
587
  backobj.geometry._extent = _extent;
494
588
  break;
589
+
495
590
  case 'circle':
496
591
  backobj.geometry.x = e.overlay.getCenter().lng;
497
592
  backobj.geometry.y = e.overlay.getCenter().lat;
@@ -499,16 +594,21 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
499
594
  backobj.area = e.calculate;
500
595
  break;
501
596
  }
597
+
502
598
  t.GM.setGraphicParam(drawExtData.id, backobj);
599
+
503
600
  t._drawmanager.close();
601
+
504
602
  if ('drawEnd' in t.props) {
505
603
  t.props.drawEnd(backobj);
506
604
  }
605
+
507
606
  if (((_t$frameSelectProps$b = t.frameSelectProps[backobj.id]) === null || _t$frameSelectProps$b === void 0 ? void 0 : _t$frameSelectProps$b.callback) instanceof Function) {
508
607
  t.frameSelectProps[backobj.id].callback(backobj);
509
608
  }
510
609
  });
511
610
  }
611
+
512
612
  t.initPropsForUser();
513
613
  }
514
614
  /*
@@ -518,6 +618,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
518
618
  BMAP_SATELLITE_MAP 单卫星图 (暂定不用)
519
619
  BMAP_HYBRID_MAP 卫星路况图
520
620
  */
621
+
521
622
  }, {
522
623
  key: "setMapType",
523
624
  value: function setMapType(type) {
@@ -525,61 +626,69 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
525
626
  case 'sl':
526
627
  this.state.gis.setMapType(BMAP_NORMAL_MAP);
527
628
  break;
629
+
528
630
  case 'wx':
529
631
  this.state.gis.setMapType(BMAP_HYBRID_MAP);
530
632
  break;
531
633
  }
532
- }
533
- //增加图片图层
634
+ } //增加图片图层
635
+
534
636
  }, {
535
637
  key: "imageUrlOverlay",
536
638
  value: function imageUrlOverlay(imageAry) {
537
639
  var t = this;
538
640
  imageAry.map(function (item, index) {
539
641
  var sw = item.sw,
540
- ne = item.ne,
541
- url = item.url,
542
- opacity = item.opacity;
642
+ ne = item.ne,
643
+ url = item.url,
644
+ opacity = item.opacity;
645
+
543
646
  if (!url) {
544
647
  console.warn("\u56FE\u7247\u56FE\u5C42url\u6570\u636E\u9519\u8BEF");
545
648
  return false;
546
649
  }
650
+
547
651
  if (sw && ne && Array.isArray(sw) && Array.isArray(ne) && sw[0] && sw[1] && ne[0] && ne[1]) {
548
652
  var swp = new BMap.Point(sw[0], sw[1]),
549
- nep = new BMap.Point(ne[0], ne[1]),
550
- option = {
551
- opacity: opacity || 1,
552
- displayOnMinLevel: item.displayOnMinLevel || 3,
553
- displayOnMaxLevel: item.displayOnMaxLevel || 19,
554
- imageURL: url
555
- },
556
- swnep = new BMap.Bounds(swp, nep),
557
- imageUrlOverlay = new BMap.GroundOverlay(swnep, option);
653
+ nep = new BMap.Point(ne[0], ne[1]),
654
+ option = {
655
+ opacity: opacity || 1,
656
+ displayOnMinLevel: item.displayOnMinLevel || 3,
657
+ displayOnMaxLevel: item.displayOnMaxLevel || 19,
658
+ imageURL: url
659
+ },
660
+ swnep = new BMap.Bounds(swp, nep),
661
+ imageUrlOverlay = new BMap.GroundOverlay(swnep, option);
558
662
  t.state.gis.addOverlay(imageUrlOverlay);
559
663
  } else {
560
664
  console.warn("\u533A\u57DF\u7ECF\u7EAC\u5EA6sw/ne\u6570\u636E\u9519\u8BEF");
561
665
  return false;
562
666
  }
563
667
  });
564
- }
565
- //新增点位
668
+ } //新增点位
669
+
566
670
  }, {
567
671
  key: "addPoint",
568
672
  value: function addPoint(mapPoints, type) {
569
673
  var _this3 = this;
674
+
570
675
  var t = this;
676
+
571
677
  var psids = _toConsumableArray(t.state.pointIds);
678
+
572
679
  mapPoints.map(function (item, index) {
573
680
  //如果id重复,直接跳过不执行.
574
681
  if (_this3.GM.isRepetition(item.id)) {
575
682
  console.warn("\u52A0\u70B9id: ".concat(item.id, " \u91CD\u590D"));
576
683
  return false;
577
- }
578
- //点位数据不符合,直接跳过
684
+ } //点位数据不符合,直接跳过
685
+
686
+
579
687
  if (!item.longitude || !item.latitude) {
580
688
  console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
581
689
  return false;
582
690
  }
691
+
583
692
  var cg = {
584
693
  width: 30,
585
694
  height: 30,
@@ -593,6 +702,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
593
702
  markerContentY: -30,
594
703
  deg: 0
595
704
  };
705
+
596
706
  if (item.markerContent) {
597
707
  cg = _objectSpread(_objectSpread({}, cg), {}, {
598
708
  markerContentX: 0,
@@ -600,13 +710,16 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
600
710
  width: 100,
601
711
  height: 30
602
712
  });
603
- }
604
- //初始化默认数据
713
+ } //初始化默认数据
714
+
715
+
605
716
  if (item.config) {
606
717
  cg = _objectSpread(_objectSpread({}, cg), item.config);
607
718
  }
719
+
608
720
  var position = new BMap.Point(item.longitude, item.latitude);
609
721
  var marker = null;
722
+
610
723
  if (item.markerContent) {
611
724
  /*自定义html加点
612
725
  用Label来实现,无法再添加label(高德有判断,实现不同)*/
@@ -620,9 +733,8 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
620
733
  markerOption = _objectSpread(_objectSpread({}, markerOption), {}, {
621
734
  icon: icon
622
735
  });
623
- marker = new BMap.Marker(position, markerOption);
736
+ marker = new BMap.Marker(position, markerOption); //覆盖物参数
624
737
 
625
- //覆盖物参数
626
738
  var markerLOption = {
627
739
  offset: new BMap.Size(0, 0)
628
740
  };
@@ -639,22 +751,26 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
639
751
  offset: new BMap.Size(cg.markerContentX + cg.width / 2, cg.markerContentY + cg.height / 2),
640
752
  icon: null
641
753
  };
754
+
642
755
  var _icon = new BMap.Icon(item.url || "".concat(_default2["default"].mapServerURL, "/images/defaultMarker.png"), new BMap.Size(cg.width, cg.height));
756
+
643
757
  _icon.setImageSize(new BMap.Size(cg.width, cg.height));
758
+
644
759
  _markerOption = _objectSpread(_objectSpread({}, _markerOption), {}, {
645
760
  icon: _icon
646
761
  });
647
- marker = new BMap.Marker(position, _markerOption);
648
- //设置选择角度
649
- marker.setRotation(cg.deg);
650
- //添加label
762
+ marker = new BMap.Marker(position, _markerOption); //设置选择角度
763
+
764
+ marker.setRotation(cg.deg); //添加label
765
+
651
766
  if (item.canShowLabel && cg.labelContent) {
652
767
  //label默认样式
653
- var labelClass = 'label-content';
654
- //接受label自定义样式
768
+ var labelClass = 'label-content'; //接受label自定义样式
769
+
655
770
  if (item.labelClass) {
656
771
  labelClass = item.labelClass.split(',').join(' ');
657
772
  }
773
+
658
774
  var markerLabel = new BMap.Label("<div class='" + labelClass + "' style=\"margin-left: 0;\">" + cg.labelContent + "</div>", {
659
775
  offset: new BMap.Size(cg.labelPixelX, cg.labelPixelY)
660
776
  });
@@ -665,31 +781,35 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
665
781
  marker.setLabel(markerLabel);
666
782
  }
667
783
  }
784
+
668
785
  if (cg.zIndex || cg.zIndex === 0) {
669
786
  marker.setZIndex(cg.zIndex);
670
- }
671
- //添加点到地图
787
+ } //添加点到地图
788
+
789
+
672
790
  t.state.gis.addOverlay(marker);
791
+
673
792
  if (!item.markerContent && cg.BAnimationType == 0) {
674
793
  marker.setAnimation(BMAP_ANIMATION_BOUNCE);
675
794
  } else if (!item.markerContent && cg.BAnimationType == 1) {
676
795
  marker.setAnimation(BMAP_ANIMATION_DROP);
677
- }
678
- //点击事件
796
+ } //点击事件
797
+
798
+
679
799
  marker.addEventListener('click', function (e) {
680
800
  t.clickGraphic(item.id, e);
681
- });
682
- //鼠标移入事件
801
+ }); //鼠标移入事件
802
+
683
803
  marker.addEventListener('mouseover', function (e) {
684
804
  t.mouseOverGraphic(item.id, e);
685
- });
686
- //鼠标移出事件
805
+ }); //鼠标移出事件
806
+
687
807
  marker.addEventListener('mouseout', function (e) {
688
808
  t.mouseOutGraphic(item.id, e);
689
- });
690
- //缓存所有点的id
691
- psids.push(item.id);
692
- //缓存当前点的图元对象和基本数据
809
+ }); //缓存所有点的id
810
+
811
+ psids.push(item.id); //缓存当前点的图元对象和基本数据
812
+
693
813
  t.GM.setGraphic(item.id, marker).setGraphicParam(item.id, {
694
814
  attributes: _objectSpread(_objectSpread({}, item), {}, {
695
815
  other: item
@@ -702,6 +822,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
702
822
  }
703
823
  });
704
824
  });
825
+
705
826
  if (type !== 'defined') {
706
827
  //所有点缓存在state中
707
828
  // t.setState({
@@ -709,14 +830,15 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
709
830
  // });
710
831
  t.state.pointIds = psids;
711
832
  }
712
- }
713
- //更新点位
833
+ } //更新点位
834
+
714
835
  }, {
715
836
  key: "updatePoint",
716
837
  value: function updatePoint(mapPoints) {
717
838
  var _this4 = this;
718
- var t = this;
719
- // let dpoints = [],apoints = [];
839
+
840
+ var t = this; // let dpoints = [],apoints = [];
841
+
720
842
  mapPoints.map(function (item, index) {
721
843
  //判断图元是否存在.
722
844
  if (_this4.GM.isRepetition(item.id)) {
@@ -724,8 +846,9 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
724
846
  if (!item.longitude || !item.latitude) {
725
847
  console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
726
848
  return false;
727
- }
728
- //获取原有的图元
849
+ } //获取原有的图元
850
+
851
+
729
852
  var gc = t.GM.getGraphic(item.id);
730
853
  var cg = {
731
854
  width: 30,
@@ -740,6 +863,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
740
863
  markerContentY: -30,
741
864
  deg: 0
742
865
  };
866
+
743
867
  if (item.markerContent) {
744
868
  cg = _objectSpread(_objectSpread({}, cg), {}, {
745
869
  markerContentX: 0,
@@ -748,14 +872,17 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
748
872
  height: 30
749
873
  });
750
874
  }
875
+
751
876
  if (item.config) {
752
877
  cg = _objectSpread(_objectSpread({}, cg), item.config);
753
878
  }
879
+
754
880
  if (item.markerContent) {
755
881
  gc.setOffset(new BMap.Size(cg.markerContentX + cg.width / 2, cg.markerContentY + cg.height / 2));
756
882
  var icon = new BMap.Icon("".concat(_default2["default"].mapServerURL, "/images/touming.png"), new BMap.Size(cg.width, cg.height));
757
883
  icon.setImageSize(new BMap.Size(cg.width, cg.height));
758
884
  gc.setIcon(icon);
885
+
759
886
  if (!!gc.getLabel()) {
760
887
  gc.getLabel().setContent(item.markerContent);
761
888
  gc.getLabel().setOffset(new BMap.Size(0, 0));
@@ -773,25 +900,29 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
773
900
  }
774
901
  } else {
775
902
  cg.width = cg.width || gc.getIcon().size.width;
776
- cg.height = cg.height || gc.getIcon().size.height;
777
- //未改变方式的点 直接修改数据
903
+ cg.height = cg.height || gc.getIcon().size.height; //未改变方式的点 直接修改数据
904
+
778
905
  var _icon2 = new BMap.Icon(item.url || "".concat(_default2["default"].mapServerURL, "/images/defaultMarker.png"), new BMap.Size(cg.width, cg.height));
906
+
779
907
  _icon2.setImageSize(new BMap.Size(cg.width, cg.height));
908
+
780
909
  gc.setIcon(_icon2);
781
- gc.setOffset(new BMap.Size((cg.markerContentX || -15) + cg.width / 2, (cg.markerContentY || -30) + cg.height / 2));
782
- //修改角度
783
- gc.setRotation(cg.deg || 0);
784
- //添加label
910
+ gc.setOffset(new BMap.Size((cg.markerContentX || -15) + cg.width / 2, (cg.markerContentY || -30) + cg.height / 2)); //修改角度
911
+
912
+ gc.setRotation(cg.deg || 0); //添加label
913
+
785
914
  if (item.canShowLabel && cg.labelContent) {
786
915
  var markerLabel = gc.getLabel(),
787
- //label默认样式
788
- labelClass = 'label-content';
789
- //接受label自定义样式
916
+ //label默认样式
917
+ labelClass = 'label-content'; //接受label自定义样式
918
+
790
919
  if (item.labelClass) {
791
920
  labelClass = item.labelClass.split(',').join(' ');
792
921
  }
922
+
793
923
  var labelContent = "<div class='" + labelClass + "' style=\"margin-left: 0;\">" + cg.labelContent + "</div>",
794
- labelOffset = new BMap.Size(cg.labelPixelX, cg.labelPixelY);
924
+ labelOffset = new BMap.Size(cg.labelPixelX, cg.labelPixelY);
925
+
795
926
  if (markerLabel) {
796
927
  markerLabel.setContent(labelContent);
797
928
  markerLabel.setOffset(labelOffset);
@@ -810,6 +941,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
810
941
  gc.getLabel().setContent('');
811
942
  }
812
943
  }
944
+
813
945
  if (cg.BAnimationType == 0) {
814
946
  gc.setAnimation(BMAP_ANIMATION_BOUNCE);
815
947
  } else if (cg.BAnimationType == 1) {
@@ -818,17 +950,21 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
818
950
  gc.setAnimation(null);
819
951
  }
820
952
  /*moveTo*/
821
- }
822
- //动画效果会延迟执行经纬度的切换
953
+
954
+ } //动画效果会延迟执行经纬度的切换
955
+
956
+
823
957
  if (cg.isAnimation) {
824
958
  t.moveTo(item.id, [item.longitude, item.latitude], cg.animationDelay, cg.autoRotation, item.url, item.urlleft);
825
959
  } else {
826
960
  //修改经纬度
827
961
  gc.setPosition(new BMap.Point(item.longitude, item.latitude));
828
962
  }
963
+
829
964
  if (cg.zIndex || cg.zIndex === 0) {
830
965
  gc.setZIndex(cg.zIndex);
831
966
  }
967
+
832
968
  t.GM.setGraphicParam(item.id, {
833
969
  attributes: _objectSpread(_objectSpread({}, item), {}, {
834
970
  other: item
@@ -845,8 +981,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
845
981
  return false;
846
982
  }
847
983
  });
848
- t.moveAnimation();
849
- // //删除改变了加载方式的点
984
+ t.moveAnimation(); // //删除改变了加载方式的点
850
985
  // dpoints.map((item,index)=>{
851
986
  // t.removeGraphic(item,'point');
852
987
  // });
@@ -856,71 +991,78 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
856
991
  // t.addPoint(apoints);
857
992
  // },100);
858
993
  // }
859
- }
860
- //添加线
994
+ } //添加线
995
+
861
996
  }, {
862
997
  key: "addLine",
863
998
  value: function addLine(mapLines, type) {
864
999
  var t = this;
865
- var lsids = _toConsumableArray(t.state.lineIds);
866
- //遍历添加线(图元)
1000
+
1001
+ var lsids = _toConsumableArray(t.state.lineIds); //遍历添加线(图元)
1002
+
1003
+
867
1004
  mapLines.map(function (item, index) {
868
1005
  //如果id重复,直接跳过不执行.
869
1006
  if (t.GM.isRepetition(item.id)) {
870
1007
  console.warn("\u591A\u6298\u7EBFid: ".concat(item.id, " \u91CD\u590D"));
871
1008
  return false;
872
- }
873
- //多折线点位数据不符合,直接跳过
1009
+ } //多折线点位数据不符合,直接跳过
1010
+
1011
+
874
1012
  if (!(item.paths && item.paths.length >= 2)) {
875
1013
  console.warn("\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF");
876
1014
  return false;
877
- }
878
- //初始化默认参数
1015
+ } //初始化默认参数
1016
+
1017
+
879
1018
  var cg = {
880
1019
  color: '#277ffa',
881
1020
  pellucidity: 0.9,
882
1021
  lineWidth: 5,
883
1022
  lineType: 'solid',
884
1023
  isHidden: false
885
- };
886
- //合并参数
1024
+ }; //合并参数
1025
+
887
1026
  if (item.config) {
888
1027
  cg = _objectSpread(_objectSpread({}, cg), item.config);
889
- }
890
- //处理线的点数组
1028
+ } //处理线的点数组
1029
+
1030
+
891
1031
  var linePath = item.paths.map(function (item, index) {
892
- return new BMap.Point(item[0], item[1]);
893
- }),
894
- //处理线的参数
895
- lineOption = {
896
- strokeColor: cg.color,
897
- // 线颜色
898
- strokeWeight: cg.lineWidth,
899
- // 线宽
900
- strokeOpacity: cg.pellucidity,
901
- // 线透明度
902
- strokeStyle: cg.lineType // 线样式
903
- };
904
- //创建线对象
905
- var line = new BMap.Polyline(linePath, lineOption);
906
- //判断线显示和隐藏
1032
+ return new BMap.Point(item[0], item[1]);
1033
+ }),
1034
+ //处理线的参数
1035
+ lineOption = {
1036
+ strokeColor: cg.color,
1037
+ // 线颜色
1038
+ strokeWeight: cg.lineWidth,
1039
+ // 线宽
1040
+ strokeOpacity: cg.pellucidity,
1041
+ // 线透明度
1042
+ strokeStyle: cg.lineType // 线样式
1043
+
1044
+ }; //创建线对象
1045
+
1046
+ var line = new BMap.Polyline(linePath, lineOption); //判断线显示和隐藏
1047
+
907
1048
  if (cg.isHidden) {
908
1049
  line.hide();
909
1050
  } else {
910
1051
  line.show();
911
1052
  }
912
- lsids.push(item.id);
913
- //添加线至地图
914
- t.state.gis.addOverlay(line);
915
- //点击事件
1053
+
1054
+ lsids.push(item.id); //添加线至地图
1055
+
1056
+ t.state.gis.addOverlay(line); //点击事件
1057
+
916
1058
  line.addEventListener('click', function (e) {
917
1059
  t.clickGraphic(item.id, e);
918
- });
919
- //鼠标移入事件
1060
+ }); //鼠标移入事件
1061
+
920
1062
  line.addEventListener('mouseover', function (e) {
921
1063
  t.mouseOverGraphic(item.id, e);
922
- });
923
- //鼠标移出事件
1064
+ }); //鼠标移出事件
1065
+
924
1066
  line.addEventListener('mouseout', function (e) {
925
1067
  t.mouseOutGraphic(item.id, e);
926
1068
  });
@@ -936,19 +1078,19 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
936
1078
  }
937
1079
  });
938
1080
  });
1081
+
939
1082
  if (type !== 'defined') {
940
- t.state.lineIds = lsids;
941
- // t.setState({
1083
+ t.state.lineIds = lsids; // t.setState({
942
1084
  // lineIds: lsids
943
1085
  // });
944
1086
  }
945
- }
946
- //更新线
1087
+ } //更新线
1088
+
947
1089
  }, {
948
1090
  key: "updateLine",
949
1091
  value: function updateLine(mapLines) {
950
- var t = this;
951
- //遍历添加线(图元)
1092
+ var t = this; //遍历添加线(图元)
1093
+
952
1094
  mapLines.map(function (item, index) {
953
1095
  //判断图元是否存在.
954
1096
  if (t.GM.isRepetition(item.id)) {
@@ -961,8 +1103,9 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
961
1103
  console.warn("\u66F4\u65B0\u7684\u591A\u6298\u7EBFid\u4E0D\u5B58\u5728!");
962
1104
  return false;
963
1105
  }
964
- var gc = t.GM.getGraphic(item.id);
965
- //初始化默认参数
1106
+
1107
+ var gc = t.GM.getGraphic(item.id); //初始化默认参数
1108
+
966
1109
  var cg = {
967
1110
  color: '#277ffa',
968
1111
  pellucidity: 0.9,
@@ -970,31 +1113,33 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
970
1113
  lineType: 'solid',
971
1114
  //'solid' 'dashed'
972
1115
  isHidden: false
973
- };
974
- //合并参数
1116
+ }; //合并参数
1117
+
975
1118
  if (item.config) {
976
1119
  cg = _objectSpread(_objectSpread({}, cg), item.config);
977
- }
978
- //处理线的点数组
1120
+ } //处理线的点数组
1121
+
1122
+
979
1123
  var linePath = item.paths.map(function (item, index) {
980
1124
  return new BMap.Point(item[0], item[1]);
981
- });
982
- //修改线点位数据
983
- gc.setPath(linePath);
984
- //修改线颜色
985
- gc.setStrokeColor(cg.color);
986
- //修改透明度
987
- gc.setStrokeOpacity(cg.pellucidity);
988
- //修改线宽度
989
- gc.setStrokeWeight(cg.lineWidth);
990
- //修改线的类型
991
- gc.setStrokeStyle(cg.lineType);
992
- //判断线显示和隐藏
1125
+ }); //修改线点位数据
1126
+
1127
+ gc.setPath(linePath); //修改线颜色
1128
+
1129
+ gc.setStrokeColor(cg.color); //修改透明度
1130
+
1131
+ gc.setStrokeOpacity(cg.pellucidity); //修改线宽度
1132
+
1133
+ gc.setStrokeWeight(cg.lineWidth); //修改线的类型
1134
+
1135
+ gc.setStrokeStyle(cg.lineType); //判断线显示和隐藏
1136
+
993
1137
  if (cg.isHidden) {
994
1138
  gc.hide();
995
1139
  } else {
996
1140
  gc.show();
997
1141
  }
1142
+
998
1143
  t.GM.setGraphicParam(item.id, {
999
1144
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1000
1145
  paths: item.paths,
@@ -1007,69 +1152,75 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1007
1152
  }
1008
1153
  });
1009
1154
  });
1010
- }
1011
- //添加面
1155
+ } //添加面
1156
+
1012
1157
  }, {
1013
1158
  key: "addPolygon",
1014
1159
  value: function addPolygon(mapPolygons) {
1015
1160
  var t = this;
1016
- var pgsids = _toConsumableArray(t.state.polygonIds);
1017
- //遍历添加面(图元)
1161
+
1162
+ var pgsids = _toConsumableArray(t.state.polygonIds); //遍历添加面(图元)
1163
+
1164
+
1018
1165
  mapPolygons.map(function (item, index) {
1019
1166
  //如果id重复,直接跳过不执行.
1020
1167
  if (t.GM.isRepetition(item.id)) {
1021
1168
  console.warn("\u591A\u8FB9\u5F62id: ".concat(item.id, " \u91CD\u590D"));
1022
1169
  return false;
1023
- }
1024
- //多边形点位数据不符合,直接跳过
1170
+ } //多边形点位数据不符合,直接跳过
1171
+
1172
+
1025
1173
  if (!(item.rings && item.rings.length >= 3)) {
1026
1174
  console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
1027
1175
  return false;
1028
- }
1029
- //初始化参数
1176
+ } //初始化参数
1177
+
1178
+
1030
1179
  var cg = {
1031
1180
  lineType: 'solid',
1032
1181
  lineWidth: 5,
1033
1182
  lineColor: '#277ffa',
1034
1183
  lineOpacity: 1,
1035
1184
  color: '#fff',
1036
- pellucidity: 0.5
1037
- // isHidden: false //后期需要再加
1185
+ pellucidity: 0.5 // isHidden: false //后期需要再加
1186
+
1038
1187
  };
1188
+
1039
1189
  if (item.config) {
1040
1190
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1041
- }
1042
- //面的参数
1191
+ } //面的参数
1192
+
1193
+
1043
1194
  var polygonOption = {
1044
- strokeColor: cg.lineColor,
1045
- strokeOpacity: cg.lineOpacity,
1046
- strokeWeight: cg.lineWidth,
1047
- strokeStyle: cg.lineType,
1048
- fillColor: cg.color,
1049
- fillOpacity: cg.pellucidity
1050
- },
1051
- polygonPath = item.rings.map(function (item, index) {
1052
- return new BMap.Point(item[0], item[1]);
1053
- });
1054
- //创建面对象
1055
- var polygon = new BMap.Polygon(polygonPath, polygonOption);
1056
- //添加面至地图
1057
- t.state.gis.addOverlay(polygon);
1058
- //点击事件
1195
+ strokeColor: cg.lineColor,
1196
+ strokeOpacity: cg.lineOpacity,
1197
+ strokeWeight: cg.lineWidth,
1198
+ strokeStyle: cg.lineType,
1199
+ fillColor: cg.color,
1200
+ fillOpacity: cg.pellucidity
1201
+ },
1202
+ polygonPath = item.rings.map(function (item, index) {
1203
+ return new BMap.Point(item[0], item[1]);
1204
+ }); //创建面对象
1205
+
1206
+ var polygon = new BMap.Polygon(polygonPath, polygonOption); //添加面至地图
1207
+
1208
+ t.state.gis.addOverlay(polygon); //点击事件
1209
+
1059
1210
  polygon.addEventListener('click', function (e) {
1060
1211
  t.clickGraphic(item.id, e);
1061
- });
1062
- //鼠标移入事件
1212
+ }); //鼠标移入事件
1213
+
1063
1214
  polygon.addEventListener('mouseover', function (e) {
1064
1215
  t.mouseOverGraphic(item.id, e);
1065
- });
1066
- //鼠标移出事件
1216
+ }); //鼠标移出事件
1217
+
1067
1218
  polygon.addEventListener('mouseout', function (e) {
1068
1219
  t.mouseOutGraphic(item.id, e);
1069
- });
1070
- //缓存面id
1071
- pgsids.push(item.id);
1072
- //缓存面图元对象和对于传入数据
1220
+ }); //缓存面id
1221
+
1222
+ pgsids.push(item.id); //缓存面图元对象和对于传入数据
1223
+
1073
1224
  t.GM.setGraphic(item.id, polygon).setGraphicParam(item.id, {
1074
1225
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1075
1226
  rings: item.rings,
@@ -1082,12 +1233,11 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1082
1233
  }
1083
1234
  });
1084
1235
  });
1085
- t.state.polygonIds = pgsids;
1086
- // t.setState({
1236
+ t.state.polygonIds = pgsids; // t.setState({
1087
1237
  // polygonIds: pgsids
1088
1238
  // });
1089
- }
1090
- //更新面
1239
+ } //更新面
1240
+
1091
1241
  }, {
1092
1242
  key: "updatePolygon",
1093
1243
  value: function updatePolygon(mapPolygons) {
@@ -1099,38 +1249,41 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1099
1249
  if (!(item.rings && item.rings.length >= 3)) {
1100
1250
  console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
1101
1251
  return false;
1102
- }
1103
- //获取原有的图元
1104
- var gc = t.GM.getGraphic(item.id);
1105
- //初始化参数
1252
+ } //获取原有的图元
1253
+
1254
+
1255
+ var gc = t.GM.getGraphic(item.id); //初始化参数
1256
+
1106
1257
  var cg = {
1107
1258
  lineType: 'solid',
1108
1259
  lineWidth: 5,
1109
1260
  lineColor: '#277ffa',
1110
1261
  lineOpacity: 1,
1111
1262
  color: '#fff',
1112
- pellucidity: 0.5
1113
- // isHidden: false //后期需要再加
1263
+ pellucidity: 0.5 // isHidden: false //后期需要再加
1264
+
1114
1265
  };
1266
+
1115
1267
  if (item.config) {
1116
1268
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1117
1269
  }
1270
+
1118
1271
  var polygonPath = item.rings.map(function (item, index) {
1119
1272
  return new BMap.Point(item[0], item[1]);
1120
- });
1121
- //更新经纬度
1122
- gc.setPath(polygonPath);
1123
- //更新边框线颜色
1124
- gc.setStrokeColor(cg.lineColor);
1125
- //更新填充色
1126
- gc.setFillColor(cg.color);
1127
- //更新变线透明度
1128
- gc.setStrokeOpacity(cg.lineOpacity);
1129
- //更新填充色透明度
1130
- gc.setFillOpacity(cg.pellucidity);
1131
- //更新边线宽度
1132
- gc.setStrokeWeight(cg.lineWidth);
1133
- //更新边线类型
1273
+ }); //更新经纬度
1274
+
1275
+ gc.setPath(polygonPath); //更新边框线颜色
1276
+
1277
+ gc.setStrokeColor(cg.lineColor); //更新填充色
1278
+
1279
+ gc.setFillColor(cg.color); //更新变线透明度
1280
+
1281
+ gc.setStrokeOpacity(cg.lineOpacity); //更新填充色透明度
1282
+
1283
+ gc.setFillOpacity(cg.pellucidity); //更新边线宽度
1284
+
1285
+ gc.setStrokeWeight(cg.lineWidth); //更新边线类型
1286
+
1134
1287
  gc.setStrokeStyle(cg.lineType);
1135
1288
  t.GM.setGraphicParam(item.id, {
1136
1289
  attributes: _objectSpread(_objectSpread({}, item), {}, {
@@ -1148,64 +1301,70 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1148
1301
  return false;
1149
1302
  }
1150
1303
  });
1151
- }
1152
- //添加圆 circle
1304
+ } //添加圆 circle
1305
+
1153
1306
  }, {
1154
1307
  key: "addCircle",
1155
1308
  value: function addCircle(mapCircles) {
1156
1309
  var t = this;
1310
+
1157
1311
  var ccsids = _toConsumableArray(t.state.circleIds);
1312
+
1158
1313
  mapCircles.map(function (item, index) {
1159
1314
  //如果id重复,直接跳过不执行.
1160
1315
  if (t.GM.isRepetition(item.id)) {
1161
1316
  console.warn("\u5706id: ".concat(item.id, " \u91CD\u590D"));
1162
1317
  return false;
1163
- }
1164
- //圆 点位数据不符合,直接跳过
1318
+ } //圆 点位数据不符合,直接跳过
1319
+
1320
+
1165
1321
  if (!item.longitude || !item.latitude) {
1166
1322
  console.warn("\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
1167
1323
  return false;
1168
1324
  }
1325
+
1169
1326
  var cg = {
1170
1327
  lineType: 'solid',
1171
1328
  lineWidth: 5,
1172
1329
  lineColor: '#277ffa',
1173
1330
  lineOpacity: 1,
1174
1331
  color: '#fff',
1175
- pellucidity: 0.5
1176
- // isHidden: false //后期需要在加
1332
+ pellucidity: 0.5 // isHidden: false //后期需要在加
1333
+
1177
1334
  };
1335
+
1178
1336
  if (item.config) {
1179
1337
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1180
- }
1181
- //初始化配置数据
1338
+ } //初始化配置数据
1339
+
1340
+
1182
1341
  var circleOption = {
1183
- strokeColor: cg.lineColor,
1184
- strokeOpacity: cg.lineOpacity,
1185
- strokeWeight: cg.lineWidth,
1186
- strokeStyle: cg.lineType,
1187
- fillColor: cg.color,
1188
- fillOpacity: cg.pellucidity
1189
- },
1190
- centerPoint = new BMap.Point(item.longitude, item.latitude);
1191
- //创建圆图元实例
1192
- var circle = new BMap.Circle(centerPoint, item.radius, circleOption);
1193
- //添加圆至地图
1194
- t.state.gis.addOverlay(circle);
1195
- //点击事件
1342
+ strokeColor: cg.lineColor,
1343
+ strokeOpacity: cg.lineOpacity,
1344
+ strokeWeight: cg.lineWidth,
1345
+ strokeStyle: cg.lineType,
1346
+ fillColor: cg.color,
1347
+ fillOpacity: cg.pellucidity
1348
+ },
1349
+ centerPoint = new BMap.Point(item.longitude, item.latitude); //创建圆图元实例
1350
+
1351
+ var circle = new BMap.Circle(centerPoint, item.radius, circleOption); //添加圆至地图
1352
+
1353
+ t.state.gis.addOverlay(circle); //点击事件
1354
+
1196
1355
  circle.addEventListener('click', function (e) {
1197
1356
  t.clickGraphic(item.id, e);
1198
- });
1199
- //鼠标移入事件
1357
+ }); //鼠标移入事件
1358
+
1200
1359
  circle.addEventListener('mouseover', function (e) {
1201
1360
  t.mouseOverGraphic(item.id, e);
1202
- });
1203
- //鼠标移出事件
1361
+ }); //鼠标移出事件
1362
+
1204
1363
  circle.addEventListener('mouseout', function (e) {
1205
1364
  t.mouseOutGraphic(item.id, e);
1206
1365
  });
1207
- ccsids.push(item.id);
1208
- //缓存数据
1366
+ ccsids.push(item.id); //缓存数据
1367
+
1209
1368
  t.GM.setGraphic(item.id, circle).setGraphicParam(item.id, {
1210
1369
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1211
1370
  other: item
@@ -1219,12 +1378,11 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1219
1378
  }
1220
1379
  });
1221
1380
  });
1222
- t.state.circleIds = ccsids;
1223
- // t.setState({
1381
+ t.state.circleIds = ccsids; // t.setState({
1224
1382
  // circleIds: ccsids
1225
1383
  // });
1226
- }
1227
- //更新圆
1384
+ } //更新圆
1385
+
1228
1386
  }, {
1229
1387
  key: "updateCircle",
1230
1388
  value: function updateCircle(mapCircles) {
@@ -1236,40 +1394,43 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1236
1394
  if (!item.longitude || !item.latitude) {
1237
1395
  console.warn("\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
1238
1396
  return false;
1239
- }
1240
- //获取原有的图元
1241
- var gc = t.GM.getGraphic(item.id);
1242
- //获取原有的面属性,转换key值
1397
+ } //获取原有的图元
1398
+
1399
+
1400
+ var gc = t.GM.getGraphic(item.id); //获取原有的面属性,转换key值
1401
+
1243
1402
  var cg = {
1244
1403
  lineType: 'solid',
1245
1404
  lineWidth: 5,
1246
1405
  lineColor: '#277ffa',
1247
1406
  lineOpacity: 1,
1248
1407
  color: '#fff',
1249
- pellucidity: 0.5
1250
- // isHidden: false //后期需要在加
1408
+ pellucidity: 0.5 // isHidden: false //后期需要在加
1409
+
1251
1410
  };
1411
+
1252
1412
  if (item.config) {
1253
1413
  cg = _objectSpread(_objectSpread({}, cg), item.config);
1254
1414
  }
1255
- var centerPoint = new BMap.Point(item.longitude, item.latitude);
1256
- //修改中心点
1257
- gc.setCenter(centerPoint);
1258
- //修改半径
1259
- gc.setRadius(item.radius);
1260
- //修改边线颜色
1261
- gc.setStrokeColor(cg.lineColor);
1262
- //修改填充颜色
1263
- gc.setFillColor(cg.color);
1264
- //修改边线透明度
1265
- gc.setStrokeOpacity(cg.lineOpacity);
1266
- //修改填充透明度
1267
- gc.setFillOpacity(cg.pellucidity);
1268
- //修改边线宽度
1269
- gc.setStrokeWeight(cg.lineWidth);
1270
- //修改边线样式
1271
- gc.setStrokeStyle(cg.lineType);
1272
- //缓存图元的数据,便于后期操作
1415
+
1416
+ var centerPoint = new BMap.Point(item.longitude, item.latitude); //修改中心点
1417
+
1418
+ gc.setCenter(centerPoint); //修改半径
1419
+
1420
+ gc.setRadius(item.radius); //修改边线颜色
1421
+
1422
+ gc.setStrokeColor(cg.lineColor); //修改填充颜色
1423
+
1424
+ gc.setFillColor(cg.color); //修改边线透明度
1425
+
1426
+ gc.setStrokeOpacity(cg.lineOpacity); //修改填充透明度
1427
+
1428
+ gc.setFillOpacity(cg.pellucidity); //修改边线宽度
1429
+
1430
+ gc.setStrokeWeight(cg.lineWidth); //修改边线样式
1431
+
1432
+ gc.setStrokeStyle(cg.lineType); //缓存图元的数据,便于后期操作
1433
+
1273
1434
  t.GM.setGraphicParam(item.id, {
1274
1435
  attributes: _objectSpread(_objectSpread({}, item), {}, {
1275
1436
  other: item
@@ -1287,8 +1448,8 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1287
1448
  return false;
1288
1449
  }
1289
1450
  });
1290
- }
1291
- //画出对应边界线 name区域名
1451
+ } //画出对应边界线 name区域名
1452
+
1292
1453
  }, {
1293
1454
  key: "addBaiduBoundary",
1294
1455
  value: function addBaiduBoundary(bdNames) {
@@ -1315,8 +1476,8 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1315
1476
  t.addPolygon(arr);
1316
1477
  });
1317
1478
  });
1318
- }
1319
- //删除对应应边界线 name区域名
1479
+ } //删除对应应边界线 name区域名
1480
+
1320
1481
  }, {
1321
1482
  key: "removeBaiduBoundary",
1322
1483
  value: function removeBaiduBoundary(removedBDNames) {
@@ -1334,8 +1495,8 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1334
1495
  removedBDIds.forEach(function (id) {
1335
1496
  t.removeGraphic(id, 'polygon');
1336
1497
  });
1337
- }
1338
- //热力图
1498
+ } //热力图
1499
+
1339
1500
  }, {
1340
1501
  key: "heatMapOverlay",
1341
1502
  value: function heatMapOverlay() {
@@ -1347,36 +1508,42 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1347
1508
  visible: true,
1348
1509
  opacity: 0.7
1349
1510
  };
1511
+
1350
1512
  if (d.config) {
1351
1513
  cg = _objectSpread(_objectSpread({}, cg), d.config);
1352
1514
  }
1515
+
1353
1516
  if (!t.heatmap) {
1354
1517
  t.heatmap = new BMapLib.HeatmapOverlay({
1355
1518
  visible: cg.visible
1356
1519
  });
1357
1520
  t.state.gis.addOverlay(t.heatmap);
1358
1521
  }
1522
+
1359
1523
  var option = {
1360
1524
  radius: cg.radius,
1361
1525
  //百度是1-100,高德是0-1
1362
1526
  opacity: eval(cg.opacity) * 100,
1363
1527
  visible: cg.visible
1364
1528
  };
1529
+
1365
1530
  if (cg.gradient) {
1366
1531
  option.gradient = cg.gradient;
1367
1532
  }
1533
+
1368
1534
  t.heatmap.setDataSet({
1369
1535
  max: cg.max,
1370
1536
  data: d.data || []
1371
1537
  });
1372
1538
  t.heatmap.setOptions(option);
1539
+
1373
1540
  if (cg.visible) {
1374
1541
  t.heatmap.show();
1375
1542
  } else {
1376
1543
  t.heatmap.hide();
1377
1544
  }
1378
- }
1379
- //信息窗体
1545
+ } //信息窗体
1546
+
1380
1547
  }, {
1381
1548
  key: "infoWindow",
1382
1549
  value: function infoWindow() {
@@ -1386,26 +1553,30 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1386
1553
  width: 300,
1387
1554
  height: 172
1388
1555
  };
1556
+
1389
1557
  if (d.config) {
1390
1558
  cg = _objectSpread(_objectSpread({}, cg), d.config);
1391
1559
  }
1560
+
1392
1561
  var sContent = document.createElement('div');
1393
1562
  var infowindow = new BMap.InfoWindow(sContent);
1394
1563
  infowindow.setWidth(cg.width);
1395
1564
  infowindow.setHeight(cg.height);
1565
+
1396
1566
  if (d.onClose instanceof Function) {
1397
1567
  infowindow.addEventListener("clickclose", function (e) {
1398
1568
  d.onClose(e);
1399
1569
  });
1400
1570
  }
1571
+
1401
1572
  if (d.lat && d.lng && d.content) {
1402
1573
  (0, _reactDom.render)(d.content, sContent);
1403
1574
  t.state.gis.openInfoWindow(infowindow, new BMap.Point(d.lng, d.lat));
1404
1575
  } else {
1405
1576
  infowindow && t.state.gis.closeInfoWindow();
1406
1577
  }
1407
- }
1408
- //添加海量点
1578
+ } //添加海量点
1579
+
1409
1580
  }, {
1410
1581
  key: "addPointCollection",
1411
1582
  value: function addPointCollection() {
@@ -1423,10 +1594,11 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1423
1594
  size: gisMapConstant[d.size] || gisMapConstant['normal'],
1424
1595
  shape: gisMapConstant[d.shape] || gisMapConstant['circle'],
1425
1596
  color: d.color || '#d340c3'
1426
- };
1427
- // 初始化PointCollection
1597
+ }; // 初始化PointCollection
1598
+
1428
1599
  var VotexpointCollection = new BMap.PointCollection(points, options);
1429
1600
  t.state.gis.addOverlay(VotexpointCollection); // 添加Overlay
1601
+
1430
1602
  t.morepoints.push({
1431
1603
  id: d.id,
1432
1604
  value: VotexpointCollection
@@ -1438,12 +1610,13 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1438
1610
  }, e.point), {}, {
1439
1611
  mapLayer: VotexpointCollection
1440
1612
  });
1613
+
1441
1614
  t.props.clickPointCollection(obj);
1442
1615
  }
1443
1616
  });
1444
1617
  });
1445
- }
1446
- //更新海量点
1618
+ } //更新海量点
1619
+
1447
1620
  }, {
1448
1621
  key: "updatePointCollection",
1449
1622
  value: function updatePointCollection() {
@@ -1467,8 +1640,8 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1467
1640
  }
1468
1641
  });
1469
1642
  });
1470
- }
1471
- //清空单个海量点
1643
+ } //清空单个海量点
1644
+
1472
1645
  }, {
1473
1646
  key: "clearPointCollection",
1474
1647
  value: function clearPointCollection(ids) {
@@ -1480,8 +1653,8 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1480
1653
  }
1481
1654
  });
1482
1655
  });
1483
- }
1484
- //清空海量点
1656
+ } //清空海量点
1657
+
1485
1658
  }, {
1486
1659
  key: "clearAllPointCollection",
1487
1660
  value: function clearAllPointCollection() {
@@ -1492,12 +1665,14 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1492
1665
  }
1493
1666
  /*图元事件处理*/
1494
1667
  //点击图元事件
1668
+
1495
1669
  }, {
1496
1670
  key: "clickGraphic",
1497
1671
  value: function clickGraphic(id, e) {
1498
- var t = this;
1499
- //编辑中的图元关闭其他事件返回
1672
+ var t = this; //编辑中的图元关闭其他事件返回
1673
+
1500
1674
  if (t.state.editId == id) return false;
1675
+
1501
1676
  if (typeof t.props.clickGraphic === "function") {
1502
1677
  var param = t.getGraphic(id);
1503
1678
  var obj = {
@@ -1515,14 +1690,15 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1515
1690
  };
1516
1691
  t.props.clickGraphic(obj);
1517
1692
  }
1518
- }
1519
- //图元鼠标悬浮事件
1693
+ } //图元鼠标悬浮事件
1694
+
1520
1695
  }, {
1521
1696
  key: "mouseOverGraphic",
1522
1697
  value: function mouseOverGraphic(id, e) {
1523
- var t = this;
1524
- //编辑中的图元关闭其他事件返回
1698
+ var t = this; //编辑中的图元关闭其他事件返回
1699
+
1525
1700
  if (t.state.editId == id) return false;
1701
+
1526
1702
  if (typeof t.props.mouseOverGraphic === 'function') {
1527
1703
  var obj = {
1528
1704
  e: e,
@@ -1534,14 +1710,15 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1534
1710
  };
1535
1711
  t.props.mouseOverGraphic(obj);
1536
1712
  }
1537
- }
1538
- //图元鼠标移开事件
1713
+ } //图元鼠标移开事件
1714
+
1539
1715
  }, {
1540
1716
  key: "mouseOutGraphic",
1541
1717
  value: function mouseOutGraphic(id, e) {
1542
- var t = this;
1543
- //编辑中的图元关闭其他事件返回
1718
+ var t = this; //编辑中的图元关闭其他事件返回
1719
+
1544
1720
  if (t.state.editId == id) return false;
1721
+
1545
1722
  if (typeof t.props.mouseOutGraphic === "function") {
1546
1723
  var obj = {
1547
1724
  e: e,
@@ -1556,10 +1733,12 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1556
1733
  }
1557
1734
  /*地图事件处理*/
1558
1735
  //地图点击事件
1736
+
1559
1737
  }, {
1560
1738
  key: "clickMap",
1561
1739
  value: function clickMap() {
1562
1740
  var t = this;
1741
+
1563
1742
  if (typeof t.props.clickMap === "function") {
1564
1743
  t.state.gis.addEventListener('click', function (e) {
1565
1744
  var obj = t.getMapExtent();
@@ -1569,12 +1748,13 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1569
1748
  t.props.clickMap(obj);
1570
1749
  });
1571
1750
  }
1572
- }
1573
- //地图拖动之前事件
1751
+ } //地图拖动之前事件
1752
+
1574
1753
  }, {
1575
1754
  key: "dragMapStart",
1576
1755
  value: function dragMapStart() {
1577
1756
  var t = this;
1757
+
1578
1758
  if (typeof t.props.dragMapStart === 'function') {
1579
1759
  t.state.gis.addEventListener('dragstart', function (e) {
1580
1760
  var obj = t.getMapExtent();
@@ -1582,12 +1762,13 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1582
1762
  t.props.dragMapStart(obj);
1583
1763
  });
1584
1764
  }
1585
- }
1586
- //地图拖动结束后事件
1765
+ } //地图拖动结束后事件
1766
+
1587
1767
  }, {
1588
1768
  key: "dragMapEnd",
1589
1769
  value: function dragMapEnd() {
1590
1770
  var t = this;
1771
+
1591
1772
  if (typeof t.props.dragMapEnd === 'function') {
1592
1773
  t.state.gis.addEventListener('dragend', function (e) {
1593
1774
  var obj = t.getMapExtent();
@@ -1595,12 +1776,13 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1595
1776
  t.props.dragMapEnd(obj);
1596
1777
  });
1597
1778
  }
1598
- }
1599
- //地图移动之前事件
1779
+ } //地图移动之前事件
1780
+
1600
1781
  }, {
1601
1782
  key: "moveStart",
1602
1783
  value: function moveStart() {
1603
1784
  var t = this;
1785
+
1604
1786
  if (typeof t.props.moveStart === 'function') {
1605
1787
  t.state.gis.addEventListener('movestart', function (e) {
1606
1788
  var obj = t.getMapExtent();
@@ -1608,12 +1790,13 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1608
1790
  t.props.moveStart(obj);
1609
1791
  });
1610
1792
  }
1611
- }
1612
- //地图移动结束后事件
1793
+ } //地图移动结束后事件
1794
+
1613
1795
  }, {
1614
1796
  key: "moveEnd",
1615
1797
  value: function moveEnd() {
1616
1798
  var t = this;
1799
+
1617
1800
  if (typeof t.props.moveEnd === 'function') {
1618
1801
  t.state.gis.addEventListener('moveend', function (e) {
1619
1802
  var obj = t.getMapExtent();
@@ -1621,12 +1804,13 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1621
1804
  t.props.moveEnd(obj);
1622
1805
  });
1623
1806
  }
1624
- }
1625
- //地图更改缩放级别开始时触发触发此事件
1807
+ } //地图更改缩放级别开始时触发触发此事件
1808
+
1626
1809
  }, {
1627
1810
  key: "zoomStart",
1628
1811
  value: function zoomStart() {
1629
1812
  var t = this;
1813
+
1630
1814
  if (typeof t.props.zoomStart === 'function') {
1631
1815
  t.state.gis.addEventListener('zoomstart', function (e) {
1632
1816
  var obj = t.getMapExtent();
@@ -1634,12 +1818,13 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1634
1818
  t.props.zoomStart(obj);
1635
1819
  });
1636
1820
  }
1637
- }
1638
- //地图更改缩放级别结束时触发触发此事件
1821
+ } //地图更改缩放级别结束时触发触发此事件
1822
+
1639
1823
  }, {
1640
1824
  key: "zoomEnd",
1641
1825
  value: function zoomEnd() {
1642
1826
  var t = this;
1827
+
1643
1828
  if (typeof t.props.zoomEnd === 'function') {
1644
1829
  t.state.gis.addEventListener('zoomend', function (e) {
1645
1830
  var obj = t.getMapExtent();
@@ -1650,48 +1835,59 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1650
1835
  }
1651
1836
  /*set方法*/
1652
1837
  //设置地图中心位置 lng/经度 lat/纬度
1838
+
1653
1839
  }, {
1654
1840
  key: "setCenter",
1655
1841
  value: function setCenter(gt) {
1656
1842
  var t = this;
1843
+
1657
1844
  if (!t.state.gis) {
1658
1845
  return;
1659
1846
  }
1847
+
1660
1848
  var mgt = [116.404, 39.915];
1849
+
1661
1850
  if (gt) {
1662
1851
  //经纬度 必须存在 否则不操作
1663
1852
  if (!gt[0] || !gt[1]) {
1664
1853
  return false;
1665
- }
1666
- //如果设置的经纬度 与当前中心点一样 不操作
1854
+ } //如果设置的经纬度 与当前中心点一样 不操作
1855
+
1856
+
1667
1857
  var c = t.state.gis.getCenter();
1858
+
1668
1859
  if (c.lng == gt[0] && c.lat == gt[1]) {
1669
1860
  return false;
1670
1861
  }
1862
+
1671
1863
  mgt = gt;
1672
1864
  }
1865
+
1673
1866
  t.state.gis.setCenter(new BMap.Point(mgt[0], mgt[1]));
1674
1867
  t.setState({
1675
1868
  center: mgt
1676
1869
  });
1677
- }
1678
- //设置地图比例尺
1870
+ } //设置地图比例尺
1871
+
1679
1872
  }, {
1680
1873
  key: "setZoomLevel",
1681
1874
  value: function setZoomLevel(zoom) {
1682
1875
  var t = this;
1683
1876
  var z = t.getZoomLevel();
1877
+
1684
1878
  if (z == zoom) {
1685
1879
  return false;
1686
1880
  }
1881
+
1687
1882
  t.state.gis.setZoom(zoom);
1688
- }
1689
- //将制定图元展示在视野内 (强制改变地图中心位置)
1883
+ } //将制定图元展示在视野内 (强制改变地图中心位置)
1884
+
1690
1885
  /*
1691
1886
  参数arg格式如下1,2
1692
1887
  1.string 格式如:'1,a,2,3,4'
1693
1888
  2.数组 ['1','2']
1694
1889
  */
1890
+
1695
1891
  }, {
1696
1892
  key: "setVisiblePoints",
1697
1893
  value: function setVisiblePoints(mapVisiblePoints) {
@@ -1700,31 +1896,38 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1700
1896
  var type = mapVisiblePoints.type;
1701
1897
  var ary = [];
1702
1898
  var obj = null;
1899
+
1703
1900
  switch (mapVisiblePoints.fitView) {
1704
1901
  case 'point':
1705
1902
  arg = this.state.pointIds;
1706
1903
  break;
1904
+
1707
1905
  case 'line':
1708
1906
  arg = this.state.lineIds;
1709
1907
  break;
1908
+
1710
1909
  case 'polygon':
1711
1910
  arg = this.state.polygonIds;
1712
1911
  break;
1912
+
1713
1913
  case 'circle':
1714
1914
  arg = this.state.circleIds;
1715
1915
  break;
1916
+
1716
1917
  case 'all':
1717
1918
  arg = this.state.pointIds.concat(this.state.lineIds).concat(this.state.polygonIds).concat(this.state.circleIds);
1718
1919
  break;
1920
+
1719
1921
  default:
1720
1922
  arg = mapVisiblePoints.fitView;
1721
1923
  break;
1722
1924
  }
1723
-
1724
1925
  /**
1725
1926
  * 用法
1726
1927
  * map.setVisiblePoints('lng,lat;lng,lat')
1727
1928
  */
1929
+
1930
+
1728
1931
  if (typeof arg === 'string') {
1729
1932
  ary = arg.split(',');
1730
1933
  obj = t.getFitView(ary);
@@ -1735,9 +1938,11 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1735
1938
  */
1736
1939
  if (arg[0] instanceof Array) {
1737
1940
  var a = [];
1941
+
1738
1942
  for (var i = 0; i < arg.length; i++) {
1739
1943
  a.push(new BMap.Point(arg[i][0], arg[i][1]));
1740
1944
  }
1945
+
1741
1946
  obj = t.state.gis.getViewport(a);
1742
1947
  /**
1743
1948
  * 用法
@@ -1747,9 +1952,11 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1747
1952
  obj = t.getFitView(arg);
1748
1953
  }
1749
1954
  }
1955
+
1750
1956
  if (!obj) {
1751
1957
  return false;
1752
1958
  }
1959
+
1753
1960
  if (!type || type == 'all') {
1754
1961
  t.state.gis.centerAndZoom(obj.center, obj.zoom);
1755
1962
  } else if (type == 'zoom') {
@@ -1760,68 +1967,82 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1760
1967
  }
1761
1968
  /*get方法*/
1762
1969
  //获取当前地图的中心位置
1970
+
1763
1971
  }, {
1764
1972
  key: "getCurrentCenter",
1765
1973
  value: function getCurrentCenter() {
1766
1974
  var t = this;
1767
1975
  return t.state.gis.getCenter();
1768
- }
1769
- //获取当前比例尺
1976
+ } //获取当前比例尺
1977
+
1770
1978
  }, {
1771
1979
  key: "getZoomLevel",
1772
1980
  value: function getZoomLevel() {
1773
1981
  var t = this;
1774
1982
  return t.state.gis.getZoom();
1775
- }
1776
- //获取对应经纬的最优 zoomLevel和center
1983
+ } //获取对应经纬的最优 zoomLevel和center
1984
+
1777
1985
  }, {
1778
1986
  key: "getFitView",
1779
1987
  value: function getFitView(ids) {
1780
1988
  var t = this;
1989
+
1781
1990
  if (ids.length > 0) {
1782
1991
  var allLayers = [];
1992
+
1783
1993
  for (var i = 0; i < ids.length; i++) {
1784
1994
  switch ((t.GM.getGraphicParam(ids[i]) || {}).geometryType) {
1785
1995
  case 'point':
1786
1996
  if (t.GM.getGraphic(ids[i])) {
1787
1997
  allLayers.push(t.GM.getGraphic(ids[i]).getPosition());
1788
1998
  }
1999
+
1789
2000
  break;
2001
+
1790
2002
  case 'polyline':
1791
2003
  case 'polygon':
1792
2004
  if (t.GM.getGraphic(ids[i])) {
1793
2005
  allLayers = [].concat(_toConsumableArray(allLayers), _toConsumableArray(t.GM.getGraphic(ids[i]).getPath()));
1794
2006
  }
2007
+
1795
2008
  break;
2009
+
1796
2010
  case 'circle':
1797
2011
  if (t.GM.getGraphic(ids[i])) {
1798
2012
  allLayers.push(t.GM.getGraphic(ids[i]).getCenter());
1799
2013
  }
2014
+
1800
2015
  break;
1801
2016
  }
1802
2017
  }
2018
+
1803
2019
  if (allLayers.length > 0) {
1804
2020
  return t.state.gis.getViewport(allLayers);
1805
2021
  }
1806
2022
  }
1807
- }
1808
- //获取图元数据
2023
+ } //获取图元数据
2024
+
1809
2025
  }, {
1810
2026
  key: "getGraphic",
1811
2027
  value: function getGraphic(id) {
1812
2028
  var t = this;
2029
+
1813
2030
  if (!id) {
1814
2031
  return false;
1815
2032
  }
2033
+
1816
2034
  var gp = t.GM.getGraphicParam(id);
1817
2035
  var gg = t.GM.getGraphic(id);
2036
+
1818
2037
  if (!gg) {
1819
2038
  return false;
1820
2039
  }
2040
+
1821
2041
  var p = {},
1822
- pts = [],
1823
- lng = 0,
1824
- lat = 0;
2042
+ pts = [],
2043
+ lng = 0,
2044
+ lat = 0;
2045
+
1825
2046
  switch (gp.geometryType) {
1826
2047
  case 'point':
1827
2048
  lng = gg.getPosition().lng;
@@ -1842,6 +2063,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1842
2063
  })
1843
2064
  });
1844
2065
  break;
2066
+
1845
2067
  case 'polyline':
1846
2068
  pts = gg.getPath().map(function (item, index) {
1847
2069
  return [item.lng, item.lat];
@@ -1859,6 +2081,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1859
2081
  })
1860
2082
  });
1861
2083
  break;
2084
+
1862
2085
  case 'polygon':
1863
2086
  // fix: 编辑图元时面积计算不正确,需要过滤一下重复的经纬度
1864
2087
  pts = (0, _unionBy["default"])(gg.getPath(), function (res) {
@@ -1879,6 +2102,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1879
2102
  })
1880
2103
  });
1881
2104
  break;
2105
+
1882
2106
  case 'circle':
1883
2107
  lng = gg.getCenter().lng;
1884
2108
  lat = gg.getCenter().lat;
@@ -1903,108 +2127,134 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
1903
2127
  });
1904
2128
  break;
1905
2129
  }
2130
+
1906
2131
  return p;
1907
2132
  }
1908
2133
  /*功能方法*/
1909
2134
  //单个删除图元
2135
+
1910
2136
  }, {
1911
2137
  key: "removeGraphic",
1912
2138
  value: function removeGraphic(id, type) {
1913
2139
  var t = this;
1914
2140
  var graphic = t.GM.getGraphic(id);
2141
+
1915
2142
  if (!!graphic) {
1916
2143
  //清除聚合点 避免异常
1917
- t._cluster.removeMarker(this.GM.getGraphic(id));
1918
- //清除地图中图元
1919
- t.state.gis.removeOverlay(graphic);
1920
- //清除对应id的图元数据缓存
1921
- t.GM.removeGraphic(id);
1922
- } else {
2144
+ t._cluster.removeMarker(this.GM.getGraphic(id)); //清除地图中图元
2145
+
2146
+
2147
+ t.state.gis.removeOverlay(graphic); //清除对应id的图元数据缓存
2148
+
2149
+ t.GM.removeGraphic(id);
2150
+ } else {
1923
2151
  return false;
1924
2152
  }
2153
+
1925
2154
  for (var i = 0; i < t.movePoints.length; i++) {
1926
2155
  if (t.movePoints[i].id == id) {
1927
2156
  t.movePoints.splice(i, 1);
1928
2157
  continue;
1929
2158
  }
1930
2159
  }
2160
+
1931
2161
  var ids = [];
2162
+
1932
2163
  switch (type) {
1933
2164
  case 'point':
1934
2165
  ids = t.state.pointIds;
1935
2166
  break;
2167
+
1936
2168
  case 'line':
1937
2169
  ids = t.state.lineIds;
1938
2170
  break;
2171
+
1939
2172
  case 'polygon':
1940
2173
  ids = t.state.polygonIds;
1941
2174
  break;
2175
+
1942
2176
  case 'circle':
1943
2177
  ids = t.state.circleIds;
1944
2178
  break;
2179
+
1945
2180
  case 'draw':
1946
2181
  if (t.state.drawIds.point.indexOf(id) > -1) {
1947
2182
  t.state.drawIds.point.splice(t.state.drawIds.point.indexOf(id), 1);
1948
2183
  }
2184
+
1949
2185
  if (t.state.drawIds.polyline.indexOf(id) > -1) {
1950
2186
  t.state.drawIds.polyline.splice(t.state.drawIds.polyline.indexOf(id), 1);
1951
2187
  }
2188
+
1952
2189
  if (t.state.drawIds.polygon.indexOf(id) > -1) {
1953
2190
  t.state.drawIds.polygon.splice(t.state.drawIds.polygon.indexOf(id), 1);
1954
2191
  }
2192
+
1955
2193
  if (t.state.drawIds.circle.indexOf(id) > -1) {
1956
2194
  t.state.drawIds.circle.splice(t.state.drawIds.circle.indexOf(id), 1);
1957
2195
  }
2196
+
1958
2197
  if (t.state.drawIds.rectangle.indexOf(id) > -1) {
1959
2198
  t.state.drawIds.rectangle.splice(t.state.drawIds.rectangle.indexOf(id), 1);
1960
2199
  }
2200
+
1961
2201
  break;
2202
+
1962
2203
  default:
1963
2204
  if (t.state.pointIds.indexOf(id) > -1) {
1964
2205
  t.state.pointIds.splice(t.state.pointIds.indexOf(id), 1);
1965
2206
  }
2207
+
1966
2208
  if (t.state.lineIds.indexOf(id) > -1) {
1967
2209
  t.state.lineIds.splice(t.state.lineIds.indexOf(id), 1);
1968
2210
  }
2211
+
1969
2212
  if (t.state.polygonIds.indexOf(id) > -1) {
1970
2213
  t.state.polygonIds.splice(t.state.polygonIds.indexOf(id), 1);
1971
2214
  }
2215
+
1972
2216
  if (t.state.circleIds.indexOf(id) > -1) {
1973
2217
  t.state.circleIds.splice(t.state.circleIds.indexOf(id), 1);
1974
2218
  }
2219
+
1975
2220
  break;
1976
2221
  }
2222
+
1977
2223
  if (id == t.state.editId) {
1978
2224
  t.state.editId = '';
1979
2225
  }
2226
+
1980
2227
  if (ids.indexOf(id) != -1) {
1981
2228
  ids.splice(ids.indexOf(id), 1);
1982
2229
  }
1983
2230
  }
1984
2231
  /*根据图元id,使图元变成可编辑状态*/
2232
+
1985
2233
  }, {
1986
2234
  key: "doEdit",
1987
2235
  value: function doEdit(id) {
1988
- var t = this;
1989
- //获取编辑点的图元和参数
2236
+ var t = this; //获取编辑点的图元和参数
2237
+
1990
2238
  var graphic = t.GM.getGraphic(id);
1991
2239
  var gtp = t.GM.getGraphicParam(id);
1992
- if (!graphic) return false;
1993
- //关闭先前编辑的图元
2240
+ if (!graphic) return false; //关闭先前编辑的图元
2241
+
1994
2242
  if (!!t.state.editId) {
1995
2243
  t.endEdit();
1996
2244
  }
2245
+
1997
2246
  if (!t.editGraphicChange) {
1998
2247
  //编辑变动后
1999
2248
  t.editGraphicChange = function (e) {
2000
2249
  var id = t.state.editId,
2001
- param = t.getGraphic(id),
2002
- obj = {
2003
- param: param,
2004
- e: e,
2005
- id: id,
2006
- geometry: param.geometry
2007
- };
2250
+ param = t.getGraphic(id),
2251
+ obj = {
2252
+ param: param,
2253
+ e: e,
2254
+ id: id,
2255
+ geometry: param.geometry
2256
+ };
2257
+
2008
2258
  if (param.geometry.type == 'polygon') {
2009
2259
  // obj.area = BMapLib.GeoUtils.getPolygonArea(param.mapLayer);
2010
2260
  // fix: 只能是数组计算之前的计算因为重复的经纬度导致面积为NAN
@@ -2012,14 +2262,18 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2012
2262
  return new BMap.Point(item[0], item[1]);
2013
2263
  }));
2014
2264
  }
2265
+
2015
2266
  if (param.geometry.type == 'polyline') {
2016
2267
  obj.distance = t.calculateDistance(param.geometry.paths);
2017
2268
  }
2269
+
2018
2270
  if (param.geometry.type == 'circle') {
2019
2271
  obj.area = Math.pow(param.geometry.radius, 2) * Math.PI;
2272
+
2020
2273
  if (t.editTimeout) {
2021
2274
  clearTimeout(t.editTimeout);
2022
2275
  }
2276
+
2023
2277
  t.editTimeout = setTimeout(function () {
2024
2278
  t.setState({
2025
2279
  editGraphic: obj
@@ -2036,51 +2290,59 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2036
2290
  }
2037
2291
  };
2038
2292
  }
2293
+
2039
2294
  switch (gtp.geometryType) {
2040
2295
  case 'point':
2041
2296
  graphic.enableDragging();
2042
2297
  graphic.addEventListener("dragend", t.editGraphicChange);
2043
2298
  break;
2299
+
2044
2300
  case 'polyline':
2045
2301
  case 'polygon':
2046
2302
  case 'rectangle':
2047
2303
  graphic.enableEditing();
2048
2304
  graphic.addEventListener("lineupdate", t.editGraphicChange);
2049
2305
  break;
2306
+
2050
2307
  case 'circle':
2051
2308
  graphic.enableEditing();
2052
2309
  graphic.addEventListener("lineupdate", t.editGraphicChange);
2053
2310
  break;
2054
2311
  }
2312
+
2055
2313
  t.setState({
2056
2314
  editId: id
2057
2315
  });
2058
- }
2059
- //关闭编辑
2316
+ } //关闭编辑
2317
+
2060
2318
  }, {
2061
2319
  key: "endEdit",
2062
2320
  value: function endEdit() {
2063
- var t = this;
2064
- //获取编辑点的图元和参数
2321
+ var t = this; //获取编辑点的图元和参数
2322
+
2065
2323
  var graphic = t.GM.getGraphic(t.state.editId);
2066
2324
  var gtp = t.GM.getGraphicParam(t.state.editId);
2067
2325
  if (!graphic) return false;
2326
+
2068
2327
  switch (gtp.geometryType) {
2069
2328
  case 'point':
2070
2329
  graphic.disableDragging();
2071
2330
  graphic.removeEventListener("dragend", t.editGraphicChange);
2072
2331
  break;
2332
+
2073
2333
  case 'polyline':
2074
2334
  case 'polygon':
2075
2335
  case 'rectangle':
2076
2336
  graphic.disableEditing();
2077
2337
  graphic.removeEventListener("lineupdate", t.editGraphicChange);
2078
2338
  break;
2339
+
2079
2340
  case 'circle':
2080
2341
  graphic.disableEditing();
2081
2342
  graphic.removeEventListener("lineupdate", t.editGraphicChange);
2082
2343
  break;
2083
2344
  }
2345
+
2084
2346
  var editGraphic = t.state.editGraphic;
2085
2347
  t.setState({
2086
2348
  editId: '',
@@ -2090,29 +2352,33 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2090
2352
  t.props.editGraphicChange(editGraphic);
2091
2353
  }
2092
2354
  });
2093
- }
2094
- //绘制图元
2355
+ } //绘制图元
2356
+
2095
2357
  }, {
2096
2358
  key: "draw",
2097
2359
  value: function draw(obj) {
2098
2360
  var t = this,
2099
- drawParam = {};
2100
- //先关闭(防止连点)
2101
- t._drawmanager.close();
2102
- //初始化参数
2361
+ drawParam = {}; //先关闭(防止连点)
2362
+
2363
+ t._drawmanager.close(); //初始化参数
2364
+
2365
+
2103
2366
  drawParam.geometryType = obj.geometryType || 'point';
2104
2367
  drawParam.parameter = obj.parameter ? _objectSpread({}, obj.parameter) : {};
2105
2368
  drawParam.data = obj.data ? _objectSpread({}, obj.data) : {};
2106
- drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime());
2107
- //判断id是否存在
2369
+ drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime()); //判断id是否存在
2370
+
2108
2371
  var len = t.state.drawIds[drawParam.geometryType].indexOf(drawParam.data.id);
2372
+
2109
2373
  if (len > -1) {
2110
2374
  //如果id存在 删除存在的图元,清除drawId中的id数据
2111
2375
  t.removeGraphic(drawParam.data.id);
2112
2376
  t.state.drawIds[drawParam.geometryType].splice(len, 1);
2113
2377
  }
2378
+
2114
2379
  var param = {};
2115
2380
  var paramgcr = {};
2381
+
2116
2382
  if (drawParam.geometryType == 'polygon' || drawParam.geometryType == 'circle' || drawParam.geometryType == 'rectangle') {
2117
2383
  paramgcr.fillColor = drawParam.parameter.color;
2118
2384
  paramgcr.strokeColor = drawParam.parameter.lineColor;
@@ -2135,6 +2401,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2135
2401
  type: drawParam.geometryType
2136
2402
  };
2137
2403
  }
2404
+
2138
2405
  switch (drawParam.geometryType) {
2139
2406
  case 'point':
2140
2407
  param.offset = new BMap.Size((drawParam.parameter.markerContentX || -15) + (drawParam.parameter.width || 30) / 2, (drawParam.parameter.markerContentY || -30) + (drawParam.parameter.height || 30) / 2);
@@ -2153,11 +2420,15 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2153
2420
  },
2154
2421
  type: 'point'
2155
2422
  };
2423
+
2156
2424
  t._drawmanager.setDrawingMode('marker');
2425
+
2157
2426
  t._drawmanager.open({
2158
2427
  markerOptions: param
2159
2428
  });
2429
+
2160
2430
  break;
2431
+
2161
2432
  case 'polyline':
2162
2433
  param.strokeColor = drawParam.parameter.color;
2163
2434
  param.strokeOpacity = drawParam.parameter.pellucidity;
@@ -2175,62 +2446,77 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2175
2446
  },
2176
2447
  type: 'polyline'
2177
2448
  };
2449
+
2178
2450
  t._drawmanager.open({
2179
2451
  polylineOptions: param,
2180
2452
  enableCalculate: true
2181
2453
  });
2454
+
2182
2455
  t._drawmanager.setDrawingMode('polyline');
2456
+
2183
2457
  break;
2458
+
2184
2459
  case 'polygon':
2185
2460
  t._drawmanager.open({
2186
2461
  polygonOptions: paramgcr,
2187
2462
  enableCalculate: true
2188
2463
  });
2464
+
2189
2465
  t._drawmanager.setDrawingMode('polygon');
2466
+
2190
2467
  break;
2468
+
2191
2469
  case 'circle':
2192
2470
  t._drawmanager.open({
2193
2471
  circleOptions: paramgcr,
2194
2472
  enableCalculate: true
2195
2473
  });
2474
+
2196
2475
  t._drawmanager.setDrawingMode('circle');
2476
+
2197
2477
  break;
2478
+
2198
2479
  case 'rectangle':
2199
2480
  t._drawmanager.open({
2200
2481
  rectangleOptions: paramgcr,
2201
2482
  enableCalculate: true
2202
2483
  });
2484
+
2203
2485
  t._drawmanager.setDrawingMode('rectangle');
2486
+
2204
2487
  break;
2205
2488
  }
2206
- }
2207
- //关闭绘制图元
2489
+ } //关闭绘制图元
2490
+
2208
2491
  }, {
2209
2492
  key: "closeDraw",
2210
2493
  value: function closeDraw() {
2211
2494
  var t = this;
2495
+
2212
2496
  t._drawmanager.close();
2213
- }
2214
- //清空地图图元
2497
+ } //清空地图图元
2498
+
2215
2499
  }, {
2216
2500
  key: "clearAll",
2217
2501
  value: function clearAll() {
2218
- var t = this;
2219
- //清空聚合
2502
+ var t = this; //清空聚合
2503
+
2220
2504
  if (t._cluster) {
2221
2505
  t._cluster.clearMarkers();
2222
- }
2223
- //关闭测距
2506
+ } //关闭测距
2507
+
2508
+
2224
2509
  if (t._rangingTool) {
2225
2510
  t._rangingTool.close();
2226
- }
2227
- //清空地图
2228
- t.state.gis.clearOverlays();
2229
- //清空缓存数据
2230
- t.GM.clearAll();
2231
- //关闭编辑
2232
- t.endEdit();
2233
- //清空历史数据记录
2511
+ } //清空地图
2512
+
2513
+
2514
+ t.state.gis.clearOverlays(); //清空缓存数据
2515
+
2516
+ t.GM.clearAll(); //关闭编辑
2517
+
2518
+ t.endEdit(); //清空历史数据记录
2519
+
2234
2520
  t.setState({
2235
2521
  pointIds: [],
2236
2522
  lineIds: [],
@@ -2248,42 +2534,48 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2248
2534
  }
2249
2535
  /*工具方法*/
2250
2536
  //聚合地图图元(arg为空时聚合全部点)
2537
+
2251
2538
  }, {
2252
2539
  key: "cluster",
2253
2540
  value: function cluster(arg) {
2254
2541
  var t = this;
2255
2542
  var ary = t.clusterToolFunction(arg && (arg === null || arg === void 0 ? void 0 : arg.length) > 0 ? arg : t.state.pointIds);
2543
+
2256
2544
  t._cluster.addMarkers(ary);
2257
- }
2258
- //删除点聚合效果
2545
+ } //删除点聚合效果
2546
+
2259
2547
  }, {
2260
2548
  key: "removeCluster",
2261
2549
  value: function removeCluster(arg) {
2262
2550
  var t = this;
2263
2551
  var ids = arg && (arg === null || arg === void 0 ? void 0 : arg.length) > 0 ? arg : t.state.pointIds;
2264
2552
  var ary = t.clusterToolFunction(ids);
2553
+
2265
2554
  if (ary.length > 0) {
2266
2555
  t._cluster.removeMarkers(ary);
2267
2556
  }
2557
+
2268
2558
  ids.map(function (id) {
2269
2559
  t.GM.removeGraphic(id);
2270
- });
2271
- // 重新加点
2560
+ }); // 重新加点
2561
+
2272
2562
  t.addPoint(t.props.mapPoints);
2273
- }
2274
- //清空聚合效果
2563
+ } //清空聚合效果
2564
+
2275
2565
  }, {
2276
2566
  key: "clearClusters",
2277
2567
  value: function clearClusters() {
2278
2568
  var t = this;
2569
+
2279
2570
  t._cluster.clearMarkers();
2280
- }
2281
- //聚合功能公共方法(获取图元集合)
2571
+ } //聚合功能公共方法(获取图元集合)
2572
+
2282
2573
  }, {
2283
2574
  key: "clusterToolFunction",
2284
2575
  value: function clusterToolFunction(arg) {
2285
2576
  var t = this;
2286
2577
  var ary = [];
2578
+
2287
2579
  if (!arg) {
2288
2580
  var pointIds = t.state.pointIds;
2289
2581
  ary = pointIds;
@@ -2293,87 +2585,106 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2293
2585
  } else if (typeof arg === 'string') {
2294
2586
  ary = arg.split(',');
2295
2587
  }
2296
- }
2297
- //过滤moveTo的点位
2588
+ } //过滤moveTo的点位
2298
2589
  //缓存所有聚合的点位
2590
+
2591
+
2299
2592
  var allps = [];
2593
+
2300
2594
  for (var i = 0; i < ary.length; i++) {
2301
2595
  allps.push(t.GM.getGraphic(ary[i]));
2302
2596
  }
2597
+
2303
2598
  return allps;
2304
- }
2305
- //测距
2599
+ } //测距
2600
+
2306
2601
  }, {
2307
2602
  key: "vtxRangingTool",
2308
2603
  value: function vtxRangingTool(callback) {
2309
2604
  var t = this;
2605
+
2310
2606
  var cb = function cb(e) {
2311
2607
  //关闭测距
2312
- t._rangingTool.close();
2313
- //注销事件(避免重复)
2608
+ t._rangingTool.close(); //注销事件(避免重复)
2609
+
2610
+
2314
2611
  t._rangingTool.removeEventListener('drawend', cb);
2612
+
2315
2613
  if (typeof callback === "function") {
2316
2614
  var obj = {
2317
2615
  distance: e.distance
2318
2616
  };
2319
2617
  var objLngLats = new Array();
2618
+
2320
2619
  for (var i = 0; i < e.points.length; i++) {
2321
2620
  objLngLats.push([e.points[i].lng, e.points[i].lat]);
2322
2621
  }
2622
+
2323
2623
  obj.lnglats = objLngLats;
2324
2624
  callback(obj);
2325
2625
  }
2326
2626
  };
2627
+
2327
2628
  t._rangingTool.addEventListener('drawend', cb);
2629
+
2328
2630
  t._rangingTool.open(this.state.gis);
2329
- }
2330
- //开启路况
2631
+ } //开启路况
2632
+
2331
2633
  }, {
2332
2634
  key: "openTrafficInfo",
2333
2635
  value: function openTrafficInfo() {
2334
2636
  var t = this;
2637
+
2335
2638
  t._trafficCtrl.showTraffic();
2336
- }
2337
- //关闭路况
2639
+ } //关闭路况
2640
+
2338
2641
  }, {
2339
2642
  key: "hideTrafficInfo",
2340
2643
  value: function hideTrafficInfo() {
2341
2644
  var t = this;
2645
+
2342
2646
  t._trafficCtrl.hideTraffic();
2343
- }
2344
- //展示比例尺
2647
+ } //展示比例尺
2648
+
2345
2649
  }, {
2346
2650
  key: "showControl",
2347
2651
  value: function showControl(props) {
2348
2652
  var t = this,
2349
- location = t.AnchorConstant['tr'],
2350
- type = '',
2351
- offset = null,
2352
- scaleOffset = null;
2653
+ location = t.AnchorConstant['tr'],
2654
+ type = '',
2655
+ offset = null,
2656
+ scaleOffset = null;
2353
2657
  var config = props || t.props;
2658
+
2354
2659
  if (t.scaleControl) {
2355
2660
  t.state.gis.removeControl(t.scaleControl);
2356
2661
  }
2662
+
2357
2663
  if (t.navigationControl) {
2358
2664
  t.state.gis.removeControl(t.navigationControl);
2359
2665
  }
2666
+
2360
2667
  if (config.showControl.location) {
2361
2668
  location = t.AnchorConstant[config.showControl.location];
2362
2669
  }
2670
+
2363
2671
  if (config.showControl.type) {
2364
2672
  type = t.NavigationConstant[config.showControl.type];
2365
2673
  }
2674
+
2366
2675
  if (config.showControl.offset && config.showControl.offset.length > 0) {
2367
2676
  offset = new BMap.Size(config.showControl.offset[0], config.showControl.offset[1]);
2368
2677
  scaleOffset = new BMap.Size(config.showControl.offset[0] + 70, config.showControl.offset[1]);
2369
- }
2370
- // 左上角,添加比例尺
2678
+ } // 左上角,添加比例尺
2679
+
2680
+
2371
2681
  var control = new BMap.ScaleControl({
2372
2682
  anchor: location,
2373
2683
  offset: scaleOffset
2374
2684
  });
2375
2685
  t.state.gis.addControl(control);
2376
2686
  t.scaleControl = control;
2687
+
2377
2688
  if (type !== 'null') {
2378
2689
  //右上角,仅包含平移和缩放按钮
2379
2690
  var navigation = new BMap.NavigationControl({
@@ -2384,40 +2695,46 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2384
2695
  t.state.gis.addControl(navigation);
2385
2696
  t.navigationControl = navigation;
2386
2697
  }
2387
- }
2388
- // 移除比例尺
2698
+ } // 移除比例尺
2699
+
2389
2700
  }, {
2390
2701
  key: "removeControl",
2391
2702
  value: function removeControl() {
2392
2703
  var t = this;
2704
+
2393
2705
  if (t.scaleControl) {
2394
2706
  t.state.gis.removeControl(t.scaleControl);
2395
2707
  t.scaleControl = null;
2396
2708
  }
2709
+
2397
2710
  if (t.navigationControl) {
2398
2711
  t.state.gis.removeControl(t.navigationControl);
2399
2712
  t.navigationControl = null;
2400
2713
  }
2401
- }
2402
- //展示地图切换控件
2714
+ } //展示地图切换控件
2715
+
2403
2716
  }, {
2404
2717
  key: "showMapTypeControl",
2405
2718
  value: function showMapTypeControl(props) {
2406
2719
  var t = this,
2407
- location = t.AnchorConstant['br'],
2408
- offset = null;
2720
+ location = t.AnchorConstant['br'],
2721
+ offset = null;
2409
2722
  var config = props || t.props;
2723
+
2410
2724
  if (t.mapTypeControl) {
2411
2725
  t.state.gis.removeControl(t.mapTypeControl);
2412
2726
  }
2727
+
2413
2728
  if (config.satelliteSwitch.location) {
2414
2729
  location = t.AnchorConstant[config.satelliteSwitch.location];
2415
2730
  }
2731
+
2416
2732
  if (config.satelliteSwitch.offset && config.satelliteSwitch.offset.length > 0) {
2417
2733
  offset = new BMap.Size(config.satelliteSwitch.offset[0], config.satelliteSwitch.offset[1]);
2418
2734
  }
2419
- var mapTypes = [BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP, BMAP_HYBRID_MAP];
2420
- // 地图切换控件
2735
+
2736
+ var mapTypes = [BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP, BMAP_HYBRID_MAP]; // 地图切换控件
2737
+
2421
2738
  var control = new BMap.MapTypeControl({
2422
2739
  mapTypes: mapTypes,
2423
2740
  anchor: location,
@@ -2428,22 +2745,26 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2428
2745
  t.mapTypeControl = control;
2429
2746
  }
2430
2747
  /*设置显示区域*/
2748
+
2431
2749
  }, {
2432
2750
  key: "setAreaRestriction",
2433
2751
  value: function setAreaRestriction(sw_ne) {
2434
- var t = this;
2435
- //修改了区域限制的js文件.
2752
+ var t = this; //修改了区域限制的js文件.
2753
+
2436
2754
  var bounds = new BMap.Bounds(new BMap.Point(sw_ne[0][0], sw_ne[0][1]), new BMap.Point(sw_ne[1][0], sw_ne[1][1]));
2755
+
2437
2756
  t._bmar.setBounds(this.state.gis, bounds);
2438
2757
  }
2439
2758
  /*取消显示区域*/
2759
+
2440
2760
  }, {
2441
2761
  key: "clearAreaRestriction",
2442
2762
  value: function clearAreaRestriction() {
2443
2763
  var t = this;
2764
+
2444
2765
  t._bmar.clearBounds();
2445
- }
2446
- //渲染
2766
+ } //渲染
2767
+
2447
2768
  }, {
2448
2769
  key: "render",
2449
2770
  value: function render() {
@@ -2458,50 +2779,60 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2458
2779
  });
2459
2780
  }
2460
2781
  /*公共方法*/
2782
+
2461
2783
  }, {
2462
2784
  key: "moveAnimation",
2463
2785
  value: function moveAnimation() {
2464
2786
  var t = this;
2787
+
2465
2788
  if (t.moveToTimer) {
2466
2789
  clearInterval(t.moveToTimer);
2467
2790
  }
2791
+
2468
2792
  t.moveToTimer = setInterval(function () {
2469
2793
  for (var i = 0; i < t.movePoints.length; i++) {
2470
2794
  t.movePoints[i].waitTime += 10;
2471
2795
  t.movePoints[i].deleteTime -= 10;
2472
2796
  }
2797
+
2473
2798
  t.movePoints.sort(function (x, y) {
2474
2799
  return y.waitTime - x.waitTime;
2475
2800
  });
2476
2801
  var nowMovePoints = t.movePoints.slice(0, 10),
2477
- deleteIndex = [];
2802
+ deleteIndex = [];
2803
+
2478
2804
  for (var _i = 0; _i < nowMovePoints.length; _i++) {
2479
2805
  var _nowMovePoints$_i = nowMovePoints[_i],
2480
- id = _nowMovePoints$_i.id,
2481
- rx = _nowMovePoints$_i.rx,
2482
- ry = _nowMovePoints$_i.ry,
2483
- waitTime = _nowMovePoints$_i.waitTime,
2484
- deleteTime = _nowMovePoints$_i.deleteTime;
2806
+ id = _nowMovePoints$_i.id,
2807
+ rx = _nowMovePoints$_i.rx,
2808
+ ry = _nowMovePoints$_i.ry,
2809
+ waitTime = _nowMovePoints$_i.waitTime,
2810
+ deleteTime = _nowMovePoints$_i.deleteTime;
2485
2811
  var gc = t.GM.getGraphic(id);
2812
+
2486
2813
  if (!gc) {
2487
2814
  clearInterval(t.moveToTimer);
2488
2815
  } else {
2489
2816
  var gg = gc.getPosition();
2490
2817
  var tx = gg.lng + rx,
2491
- ty = gg.lat + ry;
2818
+ ty = gg.lat + ry;
2492
2819
  gc.setPosition(new BMap.Point(tx, ty));
2493
2820
  t.movePoints[_i].waitTime = 0;
2821
+
2494
2822
  if (deleteTime <= 0) {
2495
2823
  deleteIndex.push(_i);
2496
2824
  }
2497
2825
  }
2498
2826
  }
2827
+
2499
2828
  deleteIndex.sort(function (a, b) {
2500
2829
  return b - a;
2501
2830
  });
2831
+
2502
2832
  for (var _i2 = 0; _i2 < deleteIndex.length; _i2++) {
2503
2833
  t.movePoints.splice(deleteIndex[_i2], 1);
2504
2834
  }
2835
+
2505
2836
  if (nowMovePoints.length == 0) {
2506
2837
  clearInterval(t.moveToTimer);
2507
2838
  }
@@ -2512,34 +2843,39 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2512
2843
  value: function moveTo(id, lnglat, delay, autoRotation, urlright, urlleft) {
2513
2844
  delay = delay || 3;
2514
2845
  var t = this,
2515
- timer = 10,
2516
- gc = t.GM.getGraphic(id);
2846
+ timer = 10,
2847
+ gc = t.GM.getGraphic(id);
2517
2848
  delay = eval(delay) * 1000;
2518
2849
  var count = delay / timer;
2519
2850
  var s = gc.getPosition(),
2520
- e = new BMap.Point(lnglat[0], lnglat[1]);
2851
+ e = new BMap.Point(lnglat[0], lnglat[1]);
2852
+
2521
2853
  if (s.equals(e)) {
2522
2854
  return false;
2523
2855
  } else {
2524
- var url = null;
2525
- //计算角度,旋转
2856
+ var url = null; //计算角度,旋转
2857
+
2526
2858
  if (autoRotation) {
2527
2859
  var ddeg = t.rotateDeg(gc.getPosition(), lnglat);
2860
+
2528
2861
  if (urlleft && ddeg < -90 && ddeg > -270) {
2529
2862
  ddeg += 180;
2530
2863
  url = urlleft;
2531
2864
  } else {
2532
2865
  url = urlright;
2533
2866
  }
2867
+
2534
2868
  var gcicon = gc.getIcon();
2535
2869
  gcicon.setImageUrl(url);
2536
2870
  gc.setIcon(gcicon);
2537
2871
  gc.setRotation(ddeg);
2538
- }
2539
- //拆分延迟移动定位
2872
+ } //拆分延迟移动定位
2873
+
2874
+
2540
2875
  var rx = (e.lng - s.lng) / count,
2541
- ry = (e.lat - s.lat) / count;
2876
+ ry = (e.lat - s.lat) / count;
2542
2877
  var isHave = false;
2878
+
2543
2879
  for (var i = 0; i < t.movePoints.length; i++) {
2544
2880
  if (t.movePoints[i].id == id) {
2545
2881
  t.movePoints.splice(i, 1, {
@@ -2552,6 +2888,7 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2552
2888
  isHave = true;
2553
2889
  }
2554
2890
  }
2891
+
2555
2892
  if (!isHave) {
2556
2893
  t.movePoints.push({
2557
2894
  id: id,
@@ -2562,30 +2899,34 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2562
2899
  });
2563
2900
  }
2564
2901
  }
2565
- }
2566
- //点位角度旋转(以指向东(右)为0°)
2902
+ } //点位角度旋转(以指向东(右)为0°)
2903
+
2567
2904
  }, {
2568
2905
  key: "rotateDeg",
2569
2906
  value: function rotateDeg(sp, ep) {
2570
2907
  var t = this;
2571
2908
  var spLngLat = sp;
2909
+
2572
2910
  if (Array.isArray(sp)) {
2573
2911
  spLngLat = new BMap.Point(sp[0], sp[1]);
2574
2912
  }
2913
+
2575
2914
  var s = t.state.gis.pointToPixel(spLngLat),
2576
- //获取当前点位的经纬度
2577
- e = t.state.gis.pointToPixel(new BMap.Point(ep[0], ep[1])),
2578
- deg = 0;
2915
+ //获取当前点位的经纬度
2916
+ e = t.state.gis.pointToPixel(new BMap.Point(ep[0], ep[1])),
2917
+ deg = 0;
2918
+
2579
2919
  if (e.x != s.x) {
2580
2920
  var tan = (e.y - s.y) / (e.x - s.x),
2581
- atan = Math.atan(tan);
2582
- deg = atan * 360 / (2 * Math.PI);
2583
- //degree correction;
2921
+ atan = Math.atan(tan);
2922
+ deg = atan * 360 / (2 * Math.PI); //degree correction;
2923
+
2584
2924
  if (e.x < s.x) {
2585
2925
  deg = -deg + 90 + 90;
2586
2926
  } else {
2587
2927
  deg = -deg;
2588
2928
  }
2929
+
2589
2930
  deg = -deg;
2590
2931
  } else {
2591
2932
  var disy = e.y - s.y;
@@ -2594,38 +2935,45 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2594
2935
  if (disy == 0) bias = 0;
2595
2936
  deg = -bias * 90;
2596
2937
  }
2938
+
2597
2939
  return deg;
2598
- }
2599
- //处理线和面的 经纬度数据
2940
+ } //处理线和面的 经纬度数据
2941
+
2600
2942
  }, {
2601
2943
  key: "dealData",
2602
2944
  value: function dealData(ms) {
2603
2945
  //区别点和圆的经纬度数据处理
2604
2946
  var lnglatAry = [],
2605
- _extent = {
2606
- xmax: 0,
2607
- xmin: 0,
2608
- ymax: 0,
2609
- ymin: 0
2610
- },
2611
- path = [];
2947
+ _extent = {
2948
+ xmax: 0,
2949
+ xmin: 0,
2950
+ ymax: 0,
2951
+ ymin: 0
2952
+ },
2953
+ path = [];
2954
+
2612
2955
  if ('getPath' in ms) {
2613
2956
  path = ms.getPath();
2614
2957
  path = path.map(function (item, index) {
2615
2958
  var lng = item.lng,
2616
- lat = item.lat;
2959
+ lat = item.lat;
2960
+
2617
2961
  if (lng > _extent.xmax) {
2618
2962
  _extent.xmax = lng;
2619
2963
  }
2964
+
2620
2965
  if (lng < _extent.xmin || _extent.xmin == 0) {
2621
2966
  _extent.xmin = lng;
2622
2967
  }
2968
+
2623
2969
  if (lat > _extent.ymax) {
2624
2970
  _extent.ymax = lat;
2625
2971
  }
2972
+
2626
2973
  if (lat < _extent.ymin || _extent.ymin == 0) {
2627
2974
  _extent.ymin = lat;
2628
2975
  }
2976
+
2629
2977
  lnglatAry.push({
2630
2978
  lngX: lng,
2631
2979
  latX: lat
@@ -2633,31 +2981,34 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2633
2981
  return [lng, lat];
2634
2982
  });
2635
2983
  }
2984
+
2636
2985
  return {
2637
2986
  lnglatAry: lnglatAry,
2638
2987
  _extent: _extent,
2639
2988
  path: path
2640
2989
  };
2641
- }
2642
- //显示隐藏的图元
2990
+ } //显示隐藏的图元
2991
+
2643
2992
  }, {
2644
2993
  key: "showGraphicById",
2645
2994
  value: function showGraphicById(id) {
2646
2995
  var t = this;
2996
+
2647
2997
  if (t.GM.getGraphic(id)) {
2648
2998
  t.GM.getGraphic(id).show();
2649
2999
  }
2650
- }
2651
- //隐藏图元
3000
+ } //隐藏图元
3001
+
2652
3002
  }, {
2653
3003
  key: "hideGraphicById",
2654
3004
  value: function hideGraphicById(id) {
2655
3005
  var t = this;
3006
+
2656
3007
  if (t.GM.getGraphic(id)) {
2657
3008
  t.GM.getGraphic(id).hide();
2658
3009
  }
2659
- }
2660
- //获取地图当前的位置状态信息
3010
+ } //获取地图当前的位置状态信息
3011
+
2661
3012
  }, {
2662
3013
  key: "getMapExtent",
2663
3014
  value: function getMapExtent() {
@@ -2677,43 +3028,46 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2677
3028
  obj.mapSize = t.state.gis.getSize();
2678
3029
  obj.radius = t.calculatePointsDistance([obj.nowCenter.lng, obj.nowCenter.lat], [obj.northEast.lng, obj.northEast.lat]);
2679
3030
  return obj;
2680
- }
2681
- //计算2点间距离 单位m 精确到2位小数
3031
+ } //计算2点间距离 单位m 精确到2位小数
3032
+
2682
3033
  }, {
2683
3034
  key: "calculatePointsDistance",
2684
3035
  value: function calculatePointsDistance(fp, ep) {
2685
3036
  return Math.round(this.state.gis.getDistance(new BMap.Point(fp[0], fp[1]), new BMap.Point(ep[0], ep[1])) * 100) / 100;
2686
- }
2687
- //计算多个点的距离(常用于线计算)
3037
+ } //计算多个点的距离(常用于线计算)
3038
+
2688
3039
  }, {
2689
3040
  key: "calculateDistance",
2690
3041
  value: function calculateDistance(ps) {
2691
3042
  var t = this,
2692
- totalDistance = 0;
3043
+ totalDistance = 0;
3044
+
2693
3045
  if (ps.length < 0) {
2694
3046
  return false;
2695
3047
  }
3048
+
2696
3049
  for (var i = 0; i < ps.length; i++) {
2697
3050
  if (i < ps.length - 1) {
2698
3051
  totalDistance += t.calculatePointsDistance(ps[i], ps[i + 1]);
2699
3052
  }
2700
3053
  }
3054
+
2701
3055
  return Math.round(totalDistance * 100) / 100;
2702
- }
2703
- //计算图元面积(面,圆)
3056
+ } //计算图元面积(面,圆)
3057
+
2704
3058
  }, {
2705
3059
  key: "calculateArea",
2706
3060
  value: function calculateArea(id) {
2707
3061
  var t = this;
2708
3062
  return t.state.gis.calculateArea(t.getGraphic(id));
2709
- }
2710
- //对比对象数据是否相等
3063
+ } //对比对象数据是否相等
3064
+
2711
3065
  }, {
2712
3066
  key: "deepEqual",
2713
3067
  value: function deepEqual(a, b) {
2714
3068
  return _immutable["default"].is(_immutable["default"].fromJS(a), _immutable["default"].fromJS(b));
2715
- }
2716
- //数据解析(分析,新增,更新,删除对应的数据)
3069
+ } //数据解析(分析,新增,更新,删除对应的数据)
3070
+
2717
3071
  }, {
2718
3072
  key: "dataMatch",
2719
3073
  value: function dataMatch(oldData, newData, type) {
@@ -2744,13 +3098,14 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2744
3098
  updatedData: updatedData,
2745
3099
  replacedData: replacedData
2746
3100
  };
2747
- }
2748
- //处理需要增加图元的数据(避免意外问题)
3101
+ } //处理需要增加图元的数据(避免意外问题)
3102
+
2749
3103
  }, {
2750
3104
  key: "dealAdd",
2751
3105
  value: function dealAdd(ary, ids) {
2752
3106
  var ads = [],
2753
- otherupds = [];
3107
+ otherupds = [];
3108
+
2754
3109
  for (var i = 0; i < ary.length; i++) {
2755
3110
  if (ids.indexOf(ary[i].id) > -1) {
2756
3111
  otherupds.push(ary[i]);
@@ -2758,17 +3113,19 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2758
3113
  ads.push(ary[i]);
2759
3114
  }
2760
3115
  }
3116
+
2761
3117
  return {
2762
3118
  ads: ads,
2763
3119
  otherupds: otherupds
2764
3120
  };
2765
- }
2766
- //处理需要更新图元的数据(避免意外问题)
3121
+ } //处理需要更新图元的数据(避免意外问题)
3122
+
2767
3123
  }, {
2768
3124
  key: "dealUpdate",
2769
3125
  value: function dealUpdate(ary, ids) {
2770
3126
  var upds = [],
2771
- otherads = [];
3127
+ otherads = [];
3128
+
2772
3129
  for (var i = 0; i < ary.length; i++) {
2773
3130
  if (ids.indexOf(ary[i].id) > -1) {
2774
3131
  upds.push(ary[i]);
@@ -2776,19 +3133,22 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2776
3133
  otherads.push(ary[i]);
2777
3134
  }
2778
3135
  }
3136
+
2779
3137
  return {
2780
3138
  upds: upds,
2781
3139
  otherads: otherads
2782
3140
  };
2783
- }
2784
- // 信息窗口
3141
+ } // 信息窗口
3142
+
2785
3143
  }, {
2786
3144
  key: "showInfoWindow",
2787
3145
  value: function showInfoWindow(params) {
2788
3146
  var t = this;
3147
+
2789
3148
  if (t.popupWindow) {
2790
3149
  t.hideInfoWindow();
2791
3150
  }
3151
+
2792
3152
  var poi = new BMap.Point(params.position[0], params.position[1]);
2793
3153
  t.popupWindow = new BMapLib.InfoBox(t.state.gis, params.content, {
2794
3154
  boxStyle: params.boxStyle,
@@ -2799,24 +3159,27 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2799
3159
  });
2800
3160
  var marker = new BMap.Marker(poi);
2801
3161
  t.popupWindow.open(marker);
2802
- }
2803
- // 框选
3162
+ } // 框选
3163
+
2804
3164
  }, {
2805
3165
  key: "frameSelect",
2806
3166
  value: function frameSelect(_ref, callback) {
2807
3167
  var geometryType = _ref.geometryType,
2808
- _ref$parameter = _ref.parameter,
2809
- parameter = _ref$parameter === void 0 ? {} : _ref$parameter,
2810
- _ref$data = _ref.data,
2811
- data = _ref$data === void 0 ? {} : _ref$data;
3168
+ _ref$parameter = _ref.parameter,
3169
+ parameter = _ref$parameter === void 0 ? {} : _ref$parameter,
3170
+ _ref$data = _ref.data,
3171
+ data = _ref$data === void 0 ? {} : _ref$data;
3172
+
2812
3173
  if (!['polygon', 'circle', 'rectangle'].includes(geometryType)) {
2813
3174
  _antd.message.warn("传入的类型不支持框选!");
3175
+
2814
3176
  return false;
2815
3177
  }
3178
+
2816
3179
  var t = this;
2817
3180
  var params = {},
2818
- type = geometryType || 'polygon',
2819
- id = data.id || "frameSelectFeature_".concat(Math.random());
3181
+ type = geometryType || 'polygon',
3182
+ id = data.id || "frameSelectFeature_".concat(Math.random());
2820
3183
  params.color = parameter.color || 'red';
2821
3184
  params.lineColor = parameter.lineColor || 'red';
2822
3185
  params.lineOpacity = parameter.lineOpacity || 1;
@@ -2835,39 +3198,43 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2835
3198
  id: id,
2836
3199
  type: geometryType
2837
3200
  };
2838
- }
2839
- // 清除框选
3201
+ } // 清除框选
3202
+
2840
3203
  }, {
2841
3204
  key: "clearFrameSelect",
2842
3205
  value: function clearFrameSelect() {
2843
3206
  for (var key in this.frameSelectProps) {
2844
3207
  this.removeGraphic(this.frameSelectProps[key].id, this.frameSelectProps[key].type);
2845
3208
  }
3209
+
2846
3210
  this.frameSelectProps = {};
2847
- }
2848
- // 清除框选ById
3211
+ } // 清除框选ById
3212
+
2849
3213
  }, {
2850
3214
  key: "clearFrameSelectById",
2851
3215
  value: function clearFrameSelectById(id) {
2852
3216
  var obj = this.frameSelectProps[id];
2853
3217
  this.removeGraphic(obj.id, obj.type);
2854
3218
  delete this.frameSelectProps[id];
2855
- }
2856
- // 关闭信息窗口
3219
+ } // 关闭信息窗口
3220
+
2857
3221
  }, {
2858
3222
  key: "hideInfoWindow",
2859
3223
  value: function hideInfoWindow() {
2860
3224
  var t = this;
3225
+
2861
3226
  if (t.popupWindow) {
2862
3227
  t.popupWindow.close();
2863
3228
  }
3229
+
2864
3230
  t.popupWindow = null;
2865
- }
2866
- //百度搜索功能
3231
+ } //百度搜索功能
3232
+
2867
3233
  }, {
2868
3234
  key: "searchPoints",
2869
3235
  value: function searchPoints(searchValue) {
2870
3236
  var _this5 = this;
3237
+
2871
3238
  var pageSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
2872
3239
  var pageIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2873
3240
  return new Promise(function (resolve) {
@@ -2879,9 +3246,11 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2879
3246
  psc.gotoPage(pageIndex);
2880
3247
  } else {
2881
3248
  var res_arr = [];
3249
+
2882
3250
  for (var i = 0, len = result.getCurrentNumPois(); i < len; i++) {
2883
3251
  res_arr.push(result.getPoi(i));
2884
3252
  }
3253
+
2885
3254
  resolve(res_arr.map(function (r) {
2886
3255
  return {
2887
3256
  id: r.uid,
@@ -2895,15 +3264,15 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2895
3264
  other: 'search'
2896
3265
  };
2897
3266
  }));
2898
- }
2899
- // console.log(result,result.getNumPages(),result.getPageIndex());
3267
+ } // console.log(result,result.getNumPages(),result.getPageIndex());
3268
+
2900
3269
  },
2901
3270
  pageCapacity: pageSize
2902
3271
  });
2903
3272
  psc.search(searchValue);
2904
3273
  });
2905
- }
2906
- //初始化
3274
+ } //初始化
3275
+
2907
3276
  }, {
2908
3277
  key: "componentDidMount",
2909
3278
  value: function componentDidMount() {
@@ -2911,101 +3280,106 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
2911
3280
  t.loadMapComplete.then(function () {
2912
3281
  t.init();
2913
3282
  });
2914
- }
2915
- //重新渲染结束
3283
+ } //重新渲染结束
3284
+
2916
3285
  }, {
2917
3286
  key: "componentDidUpdate",
2918
- value: function componentDidUpdate(prevProps, prevState) {}
2919
- //已加载组件,收到新的参数时调用
3287
+ value: function componentDidUpdate(prevProps, prevState) {} //已加载组件,收到新的参数时调用
3288
+
2920
3289
  }, {
2921
3290
  key: "UNSAFE_componentWillReceiveProps",
2922
3291
  value: function UNSAFE_componentWillReceiveProps(nextProps) {
2923
- var t = this;
2924
- //点/线旧数据
3292
+ var t = this; //点/线旧数据
3293
+
2925
3294
  var _t$state = t.state,
2926
- pointIds = _t$state.pointIds,
2927
- lineIds = _t$state.lineIds,
2928
- polygonIds = _t$state.polygonIds,
2929
- circleIds = _t$state.circleIds,
2930
- drawIds = _t$state.drawIds;
3295
+ pointIds = _t$state.pointIds,
3296
+ lineIds = _t$state.lineIds,
3297
+ polygonIds = _t$state.polygonIds,
3298
+ circleIds = _t$state.circleIds,
3299
+ drawIds = _t$state.drawIds;
2931
3300
  var point = drawIds.point,
2932
- polyline = drawIds.polyline,
2933
- polygon = drawIds.polygon,
2934
- circle = drawIds.circle,
2935
- rectangle = drawIds.rectangle;
2936
- //点/线新数据
3301
+ polyline = drawIds.polyline,
3302
+ polygon = drawIds.polygon,
3303
+ circle = drawIds.circle,
3304
+ rectangle = drawIds.rectangle; //点/线新数据
3305
+
2937
3306
  var _nextProps$mapPoints = nextProps.mapPoints,
2938
- mapPoints = _nextProps$mapPoints === void 0 ? [] : _nextProps$mapPoints,
2939
- _nextProps$mapLines = nextProps.mapLines,
2940
- mapLines = _nextProps$mapLines === void 0 ? [] : _nextProps$mapLines,
2941
- _nextProps$mapPolygon = nextProps.mapPolygons,
2942
- mapPolygons = _nextProps$mapPolygon === void 0 ? [] : _nextProps$mapPolygon,
2943
- _nextProps$mapCircles = nextProps.mapCircles,
2944
- mapCircles = _nextProps$mapCircles === void 0 ? [] : _nextProps$mapCircles,
2945
- _nextProps$customized = nextProps.customizedBoundary,
2946
- customizedBoundary = _nextProps$customized === void 0 ? [] : _nextProps$customized,
2947
- isOpenTrafficInfo = nextProps.isOpenTrafficInfo,
2948
- boundaryName = nextProps.boundaryName,
2949
- heatMapData = nextProps.heatMapData,
2950
- imageOverlays = nextProps.imageOverlays,
2951
- mapVisiblePoints = nextProps.mapVisiblePoints,
2952
- setVisiblePoints = nextProps.setVisiblePoints,
2953
- setCenter = nextProps.setCenter,
2954
- mapCenter = nextProps.mapCenter,
2955
- setZoomLevel = nextProps.setZoomLevel,
2956
- mapZoomLevel = nextProps.mapZoomLevel,
2957
- setCluster = nextProps.setCluster,
2958
- mapCluster = nextProps.mapCluster,
2959
- isRangingTool = nextProps.isRangingTool,
2960
- mapRangingTool = nextProps.mapRangingTool,
2961
- isRemove = nextProps.isRemove,
2962
- mapRemove = nextProps.mapRemove,
2963
- mapDraw = nextProps.mapDraw,
2964
- isDraw = nextProps.isDraw,
2965
- isCloseDraw = nextProps.isCloseDraw,
2966
- editGraphicId = nextProps.editGraphicId,
2967
- isDoEdit = nextProps.isDoEdit,
2968
- isEndEdit = nextProps.isEndEdit,
2969
- mapPointCollection = nextProps.mapPointCollection,
2970
- isclearAllPointCollection = nextProps.isclearAllPointCollection,
2971
- isSetAreaRestriction = nextProps.isSetAreaRestriction,
2972
- areaRestriction = nextProps.areaRestriction,
2973
- isClearAreaRestriction = nextProps.isClearAreaRestriction,
2974
- isClearAll = nextProps.isClearAll,
2975
- mapStyle = nextProps.mapStyle,
2976
- coverageType = nextProps.coverageType,
2977
- infoWindowData = nextProps.infoWindowData;
2978
- var props = t.props;
2979
- // 设置地图地图样式
3307
+ mapPoints = _nextProps$mapPoints === void 0 ? [] : _nextProps$mapPoints,
3308
+ _nextProps$mapLines = nextProps.mapLines,
3309
+ mapLines = _nextProps$mapLines === void 0 ? [] : _nextProps$mapLines,
3310
+ _nextProps$mapPolygon = nextProps.mapPolygons,
3311
+ mapPolygons = _nextProps$mapPolygon === void 0 ? [] : _nextProps$mapPolygon,
3312
+ _nextProps$mapCircles = nextProps.mapCircles,
3313
+ mapCircles = _nextProps$mapCircles === void 0 ? [] : _nextProps$mapCircles,
3314
+ _nextProps$customized = nextProps.customizedBoundary,
3315
+ customizedBoundary = _nextProps$customized === void 0 ? [] : _nextProps$customized,
3316
+ isOpenTrafficInfo = nextProps.isOpenTrafficInfo,
3317
+ boundaryName = nextProps.boundaryName,
3318
+ heatMapData = nextProps.heatMapData,
3319
+ imageOverlays = nextProps.imageOverlays,
3320
+ mapVisiblePoints = nextProps.mapVisiblePoints,
3321
+ setVisiblePoints = nextProps.setVisiblePoints,
3322
+ setCenter = nextProps.setCenter,
3323
+ mapCenter = nextProps.mapCenter,
3324
+ setZoomLevel = nextProps.setZoomLevel,
3325
+ mapZoomLevel = nextProps.mapZoomLevel,
3326
+ setCluster = nextProps.setCluster,
3327
+ mapCluster = nextProps.mapCluster,
3328
+ isRangingTool = nextProps.isRangingTool,
3329
+ mapRangingTool = nextProps.mapRangingTool,
3330
+ isRemove = nextProps.isRemove,
3331
+ mapRemove = nextProps.mapRemove,
3332
+ mapDraw = nextProps.mapDraw,
3333
+ isDraw = nextProps.isDraw,
3334
+ isCloseDraw = nextProps.isCloseDraw,
3335
+ editGraphicId = nextProps.editGraphicId,
3336
+ isDoEdit = nextProps.isDoEdit,
3337
+ isEndEdit = nextProps.isEndEdit,
3338
+ mapPointCollection = nextProps.mapPointCollection,
3339
+ isclearAllPointCollection = nextProps.isclearAllPointCollection,
3340
+ isSetAreaRestriction = nextProps.isSetAreaRestriction,
3341
+ areaRestriction = nextProps.areaRestriction,
3342
+ isClearAreaRestriction = nextProps.isClearAreaRestriction,
3343
+ isClearAll = nextProps.isClearAll,
3344
+ mapStyle = nextProps.mapStyle,
3345
+ coverageType = nextProps.coverageType,
3346
+ infoWindowData = nextProps.infoWindowData;
3347
+ var props = t.props; // 设置地图地图样式
3348
+
2980
3349
  if (mapStyle && !t.deepEqual(mapStyle, props.mapStyle)) {
2981
3350
  if (typeof mapStyle === 'string') {
2982
3351
  t.state.gis.setMapStyle({
2983
3352
  style: mapStyle
2984
3353
  });
2985
3354
  }
3355
+
2986
3356
  if (mapStyle instanceof Array) {
2987
3357
  t.state.gis.setMapStyle({
2988
3358
  styleJson: mapStyle
2989
3359
  });
2990
3360
  }
2991
- }
2992
- // 切换地图矢量图和卫星图背景
3361
+ } // 切换地图矢量图和卫星图背景
3362
+
3363
+
2993
3364
  if (coverageType && !t.deepEqual(coverageType, props.coverageType)) {
2994
3365
  t.setMapType(coverageType);
2995
- }
2996
- // 等待地图加载
2997
- if (!t.mapCreated) return;
3366
+ } // 等待地图加载
2998
3367
 
3368
+
3369
+ if (!t.mapCreated) return;
2999
3370
  /*添加海量点*/
3371
+
3000
3372
  if (mapPointCollection instanceof Array && props.mapPointCollection instanceof Array && !t.deepEqual(mapPointCollection, props.mapPointCollection)) {
3001
3373
  var _t$dataMatch = t.dataMatch(props.mapPointCollection, mapPointCollection, 'id'),
3002
- deletedDataIDs = _t$dataMatch.deletedDataIDs,
3003
- addedData = _t$dataMatch.addedData,
3004
- updatedData = _t$dataMatch.updatedData;
3374
+ deletedDataIDs = _t$dataMatch.deletedDataIDs,
3375
+ addedData = _t$dataMatch.addedData,
3376
+ updatedData = _t$dataMatch.updatedData;
3377
+
3005
3378
  t.clearPointCollection(deletedDataIDs);
3006
3379
  t.addPointCollection(addedData);
3007
3380
  t.updatePointCollection(updatedData);
3008
3381
  }
3382
+
3009
3383
  if (typeof isclearAllPointCollection == 'boolean' && isclearAllPointCollection || isclearAllPointCollection && isclearAllPointCollection !== t.props.isclearAllPointCollection) {
3010
3384
  t.clearAllPointCollection();
3011
3385
  }
@@ -3014,10 +3388,12 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
3014
3388
  pointData[1]的数据在idsForGraphicId中不存在的,执行新增
3015
3389
  pointData[0]数据中多余的id,执行删除
3016
3390
  */
3391
+
3392
+
3017
3393
  if (mapPoints instanceof Array && props.mapPoints instanceof Array && !t.deepEqual(mapPoints, props.mapPoints)) {
3018
3394
  var oldMapPoints = props.mapPoints;
3019
- var newMapPoints = mapPoints;
3020
- //过滤编辑的图元
3395
+ var newMapPoints = mapPoints; //过滤编辑的图元
3396
+
3021
3397
  if (!!t.state.editId) {
3022
3398
  oldMapPoints = props.mapPoints.filter(function (item) {
3023
3399
  return item.id !== editGraphicId;
@@ -3026,41 +3402,50 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
3026
3402
  return item.id !== editGraphicId;
3027
3403
  });
3028
3404
  }
3405
+
3029
3406
  var _t$dataMatch2 = t.dataMatch(oldMapPoints, newMapPoints, 'id'),
3030
- _deletedDataIDs = _t$dataMatch2.deletedDataIDs,
3031
- _addedData = _t$dataMatch2.addedData,
3032
- _updatedData = _t$dataMatch2.updatedData;
3407
+ _deletedDataIDs = _t$dataMatch2.deletedDataIDs,
3408
+ _addedData = _t$dataMatch2.addedData,
3409
+ _updatedData = _t$dataMatch2.updatedData;
3410
+
3033
3411
  var _t$dealAdd = t.dealAdd(_addedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
3034
- ads = _t$dealAdd.ads,
3035
- otherupds = _t$dealAdd.otherupds;
3412
+ ads = _t$dealAdd.ads,
3413
+ otherupds = _t$dealAdd.otherupds;
3414
+
3036
3415
  var _t$dealUpdate = t.dealUpdate(_updatedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
3037
- upds = _t$dealUpdate.upds,
3038
- otherads = _t$dealUpdate.otherads;
3039
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3416
+ upds = _t$dealUpdate.upds,
3417
+ otherads = _t$dealUpdate.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3418
+
3419
+
3040
3420
  var _iterator = _createForOfIteratorHelper(_deletedDataIDs),
3041
- _step;
3421
+ _step;
3422
+
3042
3423
  try {
3043
3424
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
3044
3425
  var id = _step.value;
3045
3426
  t.removeGraphic(id, 'point');
3046
- }
3047
- //增加
3427
+ } //增加
3428
+
3048
3429
  } catch (err) {
3049
3430
  _iterator.e(err);
3050
3431
  } finally {
3051
3432
  _iterator.f();
3052
3433
  }
3053
- t.addPoint([].concat(_toConsumableArray(ads), _toConsumableArray(otherads)));
3054
- //更新
3434
+
3435
+ t.addPoint([].concat(_toConsumableArray(ads), _toConsumableArray(otherads))); //更新
3436
+
3055
3437
  t.updatePoint([].concat(_toConsumableArray(upds), _toConsumableArray(otherupds)));
3056
3438
  }
3057
3439
  /*
3058
3440
  面数据处理
3059
3441
  先全删除,再新增
3060
3442
  */
3443
+
3444
+
3061
3445
  if (mapPolygons instanceof Array && props.mapPolygons instanceof Array && !t.deepEqual(mapPolygons, props.mapPolygons)) {
3062
3446
  var oldMapPolygons = props.mapPolygons;
3063
3447
  var newMapPolygons = mapPolygons;
3448
+
3064
3449
  if (!!t.state.editId) {
3065
3450
  oldMapPolygons = props.mapPolygons.filter(function (item) {
3066
3451
  return item.id !== editGraphicId;
@@ -3069,41 +3454,50 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
3069
3454
  return item.id !== editGraphicId;
3070
3455
  });
3071
3456
  }
3457
+
3072
3458
  var _t$dataMatch3 = t.dataMatch(oldMapPolygons, newMapPolygons, 'id'),
3073
- _deletedDataIDs2 = _t$dataMatch3.deletedDataIDs,
3074
- _addedData2 = _t$dataMatch3.addedData,
3075
- _updatedData2 = _t$dataMatch3.updatedData;
3459
+ _deletedDataIDs2 = _t$dataMatch3.deletedDataIDs,
3460
+ _addedData2 = _t$dataMatch3.addedData,
3461
+ _updatedData2 = _t$dataMatch3.updatedData;
3462
+
3076
3463
  var _t$dealAdd2 = t.dealAdd(_addedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
3077
- _ads = _t$dealAdd2.ads,
3078
- _otherupds = _t$dealAdd2.otherupds;
3464
+ _ads = _t$dealAdd2.ads,
3465
+ _otherupds = _t$dealAdd2.otherupds;
3466
+
3079
3467
  var _t$dealUpdate2 = t.dealUpdate(_updatedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
3080
- _upds = _t$dealUpdate2.upds,
3081
- _otherads = _t$dealUpdate2.otherads;
3082
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3468
+ _upds = _t$dealUpdate2.upds,
3469
+ _otherads = _t$dealUpdate2.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3470
+
3471
+
3083
3472
  var _iterator2 = _createForOfIteratorHelper(_deletedDataIDs2),
3084
- _step2;
3473
+ _step2;
3474
+
3085
3475
  try {
3086
3476
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3087
3477
  var _id = _step2.value;
3088
3478
  t.removeGraphic(_id, 'polygon');
3089
- }
3090
- //增加
3479
+ } //增加
3480
+
3091
3481
  } catch (err) {
3092
3482
  _iterator2.e(err);
3093
3483
  } finally {
3094
3484
  _iterator2.f();
3095
3485
  }
3096
- t.addPolygon([].concat(_toConsumableArray(_ads), _toConsumableArray(_otherads)));
3097
- //更新
3486
+
3487
+ t.addPolygon([].concat(_toConsumableArray(_ads), _toConsumableArray(_otherads))); //更新
3488
+
3098
3489
  t.updatePolygon([].concat(_toConsumableArray(_upds), _toConsumableArray(_otherupds)));
3099
3490
  }
3100
3491
  /*
3101
3492
  圆数据处理
3102
3493
  先全删除,再新增
3103
3494
  */
3495
+
3496
+
3104
3497
  if (mapCircles instanceof Array && props.mapCircles instanceof Array && !t.deepEqual(mapCircles, props.mapCircles)) {
3105
3498
  var oldMapCircles = props.mapCircles;
3106
3499
  var newMapCircles = mapCircles;
3500
+
3107
3501
  if (!!t.state.editId) {
3108
3502
  oldMapCircles = props.mapCircles.filter(function (item) {
3109
3503
  return item.id !== editGraphicId;
@@ -3112,41 +3506,50 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
3112
3506
  return item.id !== editGraphicId;
3113
3507
  });
3114
3508
  }
3509
+
3115
3510
  var _t$dataMatch4 = t.dataMatch(oldMapCircles, newMapCircles, 'id'),
3116
- _deletedDataIDs3 = _t$dataMatch4.deletedDataIDs,
3117
- _addedData3 = _t$dataMatch4.addedData,
3118
- _updatedData3 = _t$dataMatch4.updatedData;
3511
+ _deletedDataIDs3 = _t$dataMatch4.deletedDataIDs,
3512
+ _addedData3 = _t$dataMatch4.addedData,
3513
+ _updatedData3 = _t$dataMatch4.updatedData;
3514
+
3119
3515
  var _t$dealAdd3 = t.dealAdd(_addedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
3120
- _ads2 = _t$dealAdd3.ads,
3121
- _otherupds2 = _t$dealAdd3.otherupds;
3516
+ _ads2 = _t$dealAdd3.ads,
3517
+ _otherupds2 = _t$dealAdd3.otherupds;
3518
+
3122
3519
  var _t$dealUpdate3 = t.dealUpdate(_updatedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
3123
- _upds2 = _t$dealUpdate3.upds,
3124
- _otherads2 = _t$dealUpdate3.otherads;
3125
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3520
+ _upds2 = _t$dealUpdate3.upds,
3521
+ _otherads2 = _t$dealUpdate3.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3522
+
3523
+
3126
3524
  var _iterator3 = _createForOfIteratorHelper(_deletedDataIDs3),
3127
- _step3;
3525
+ _step3;
3526
+
3128
3527
  try {
3129
3528
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
3130
3529
  var _id2 = _step3.value;
3131
3530
  t.removeGraphic(_id2, 'circle');
3132
- }
3133
- //增加
3531
+ } //增加
3532
+
3134
3533
  } catch (err) {
3135
3534
  _iterator3.e(err);
3136
3535
  } finally {
3137
3536
  _iterator3.f();
3138
3537
  }
3139
- t.addCircle([].concat(_toConsumableArray(_ads2), _toConsumableArray(_otherads2)));
3140
- //更新
3538
+
3539
+ t.addCircle([].concat(_toConsumableArray(_ads2), _toConsumableArray(_otherads2))); //更新
3540
+
3141
3541
  t.updateCircle([].concat(_toConsumableArray(_upds2), _toConsumableArray(_otherupds2)));
3142
3542
  }
3143
3543
  /*
3144
3544
  线数据处理
3145
3545
  先全删除,再新增
3146
3546
  */
3547
+
3548
+
3147
3549
  if (mapLines instanceof Array && props.mapLines instanceof Array && !t.deepEqual(mapLines, props.mapLines)) {
3148
3550
  var oldMapLines = props.mapLines;
3149
3551
  var newMapLines = mapLines;
3552
+
3150
3553
  if (!!t.state.editId) {
3151
3554
  oldMapLines = props.mapLines.filter(function (item) {
3152
3555
  return item.id !== editGraphicId;
@@ -3155,43 +3558,52 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
3155
3558
  return item.id !== editGraphicId;
3156
3559
  });
3157
3560
  }
3561
+
3158
3562
  var _t$dataMatch5 = t.dataMatch(oldMapLines, newMapLines, 'id'),
3159
- _deletedDataIDs4 = _t$dataMatch5.deletedDataIDs,
3160
- _addedData4 = _t$dataMatch5.addedData,
3161
- _updatedData4 = _t$dataMatch5.updatedData;
3563
+ _deletedDataIDs4 = _t$dataMatch5.deletedDataIDs,
3564
+ _addedData4 = _t$dataMatch5.addedData,
3565
+ _updatedData4 = _t$dataMatch5.updatedData;
3566
+
3162
3567
  var _t$dealAdd4 = t.dealAdd(_addedData4, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
3163
- _ads3 = _t$dealAdd4.ads,
3164
- _otherupds3 = _t$dealAdd4.otherupds;
3568
+ _ads3 = _t$dealAdd4.ads,
3569
+ _otherupds3 = _t$dealAdd4.otherupds;
3570
+
3165
3571
  var _t$dealUpdate4 = t.dealUpdate(_updatedData4, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
3166
- _upds3 = _t$dealUpdate4.upds,
3167
- _otherads3 = _t$dealUpdate4.otherads;
3168
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3572
+ _upds3 = _t$dealUpdate4.upds,
3573
+ _otherads3 = _t$dealUpdate4.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3574
+
3575
+
3169
3576
  var _iterator4 = _createForOfIteratorHelper(_deletedDataIDs4),
3170
- _step4;
3577
+ _step4;
3578
+
3171
3579
  try {
3172
3580
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
3173
3581
  var _id3 = _step4.value;
3174
3582
  t.removeGraphic(_id3, 'line');
3175
- }
3176
- //增加
3583
+ } //增加
3584
+
3177
3585
  } catch (err) {
3178
3586
  _iterator4.e(err);
3179
3587
  } finally {
3180
3588
  _iterator4.f();
3181
3589
  }
3182
- t.addLine([].concat(_toConsumableArray(_ads3), _toConsumableArray(_otherads3)));
3183
- //更新
3590
+
3591
+ t.addLine([].concat(_toConsumableArray(_ads3), _toConsumableArray(_otherads3))); //更新
3592
+
3184
3593
  t.updateLine([].concat(_toConsumableArray(_upds3), _toConsumableArray(_otherupds3)));
3185
- }
3186
- //画其他特例线专用
3594
+ } //画其他特例线专用
3595
+
3596
+
3187
3597
  if (customizedBoundary instanceof Array && props.customizedBoundary instanceof Array && !t.deepEqual(customizedBoundary, props.customizedBoundary)) {
3188
3598
  var _t$dataMatch6 = t.dataMatch(props.customizedBoundary, customizedBoundary, 'id'),
3189
- _deletedDataIDs5 = _t$dataMatch6.deletedDataIDs,
3190
- _addedData5 = _t$dataMatch6.addedData,
3191
- _updatedData5 = _t$dataMatch6.updatedData;
3192
- //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3599
+ _deletedDataIDs5 = _t$dataMatch6.deletedDataIDs,
3600
+ _addedData5 = _t$dataMatch6.addedData,
3601
+ _updatedData5 = _t$dataMatch6.updatedData; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
3602
+
3603
+
3193
3604
  var _iterator5 = _createForOfIteratorHelper(_deletedDataIDs5),
3194
- _step5;
3605
+ _step5;
3606
+
3195
3607
  try {
3196
3608
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3197
3609
  var _id4 = _step5.value;
@@ -3202,10 +3614,12 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
3202
3614
  } finally {
3203
3615
  _iterator5.f();
3204
3616
  }
3617
+
3205
3618
  t.addLine(_addedData5);
3206
3619
  t.updateLine(_updatedData5);
3207
- }
3208
- //绘制边界线
3620
+ } //绘制边界线
3621
+
3622
+
3209
3623
  if (boundaryName instanceof Array && props.boundaryName instanceof Array && !t.deepEqual(boundaryName, props.boundaryName)) {
3210
3624
  var newBDName = Set(boundaryName);
3211
3625
  var oldBDName = Set(props.boundaryName);
@@ -3213,127 +3627,155 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
3213
3627
  var addedBoundaryName = newBDName.subtract(oldBDName).toJS();
3214
3628
  t.removeBaiduBoundary(removedBoundaryName);
3215
3629
  t.addBaiduBoundary(addedBoundaryName);
3216
- }
3217
- // 获取热力图
3630
+ } // 获取热力图
3631
+
3632
+
3218
3633
  if (heatMapData && !t.deepEqual(heatMapData, props.heatMapData)) {
3219
3634
  t.heatMapOverlay(heatMapData);
3220
- }
3221
- // 打开信息窗体
3635
+ } // 打开信息窗体
3636
+
3637
+
3222
3638
  if (infoWindowData && !t.deepEqual(infoWindowData, props.infoWindowData)) {
3223
3639
  t.infoWindow(infoWindowData);
3224
- }
3225
- //添加图片图层
3640
+ } //添加图片图层
3641
+
3642
+
3226
3643
  if (imageOverlays instanceof Array && props.imageOverlays instanceof Array && !t.deepEqual(imageOverlays, props.imageOverlays)) {
3227
3644
  t.imageUrlOverlay(imageOverlays);
3228
- }
3229
- //图元编辑调用
3645
+ } //图元编辑调用
3646
+
3647
+
3230
3648
  if (typeof isDoEdit == 'boolean' && isDoEdit || isDoEdit && isDoEdit !== t.props.isDoEdit) {
3231
3649
  t.doEdit(editGraphicId);
3232
- }
3233
- //关闭图元编辑
3650
+ } //关闭图元编辑
3651
+
3652
+
3234
3653
  if (typeof isEndEdit == 'boolean' && isEndEdit || isEndEdit && isEndEdit !== t.props.isEndEdit) {
3235
3654
  t.endEdit();
3236
- }
3237
- //开启图元绘制
3655
+ } //开启图元绘制
3656
+
3657
+
3238
3658
  if (typeof isDraw == 'boolean' && isDraw || isDraw && isDraw !== t.props.isDraw) {
3239
3659
  t.draw(mapDraw);
3240
- }
3241
- //关闭图元绘制
3660
+ } //关闭图元绘制
3661
+
3662
+
3242
3663
  if (typeof isCloseDraw == 'boolean' && isCloseDraw || isCloseDraw && isCloseDraw !== t.props.isCloseDraw) {
3243
3664
  t.closeDraw();
3244
- }
3245
- //设置中心点
3665
+ } //设置中心点
3666
+
3667
+
3246
3668
  if (typeof setCenter == 'boolean' && setCenter || setCenter && setCenter !== t.props.setCenter) {
3247
3669
  t.setCenter(mapCenter);
3248
- }
3249
- //设置点聚合
3670
+ } //设置点聚合
3671
+
3672
+
3250
3673
  if (typeof setCluster == 'boolean' && setCluster || setCluster && setCluster !== t.props.setCluster) {
3251
3674
  t.cluster(mapCluster);
3252
- }
3253
- // 清除聚合
3675
+ } // 清除聚合
3676
+
3677
+
3254
3678
  if (!setCluster && setCluster !== t.props.setCluster) {
3255
3679
  t.removeCluster(mapCluster);
3256
- }
3257
- //设置比例尺
3680
+ } //设置比例尺
3681
+
3682
+
3258
3683
  if (typeof setZoomLevel == 'boolean' && setZoomLevel || setZoomLevel && setZoomLevel !== t.props.setZoomLevel) {
3259
3684
  t.setZoomLevel(mapZoomLevel);
3260
- }
3261
- //设置最优视野
3685
+ } //设置最优视野
3686
+
3687
+
3262
3688
  if (typeof setVisiblePoints == 'boolean' && setVisiblePoints || setVisiblePoints && setVisiblePoints !== t.props.setVisiblePoints) {
3263
3689
  t.setVisiblePoints(mapVisiblePoints);
3264
- }
3265
- //测距工具调用
3690
+ } //测距工具调用
3691
+
3692
+
3266
3693
  if (typeof isRangingTool == 'boolean' && isRangingTool || isRangingTool && isRangingTool !== t.props.isRangingTool) {
3267
3694
  t.vtxRangingTool(mapRangingTool);
3268
- }
3269
- //开关路况
3695
+ } //开关路况
3696
+
3697
+
3270
3698
  if (isOpenTrafficInfo) {
3271
3699
  t.openTrafficInfo();
3272
3700
  } else {
3273
3701
  t.hideTrafficInfo();
3274
- }
3275
- //设置区域限制
3702
+ } //设置区域限制
3703
+
3704
+
3276
3705
  if (typeof isSetAreaRestriction == 'boolean' && isSetAreaRestriction || isSetAreaRestriction && isSetAreaRestriction !== t.props.isSetAreaRestriction && areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
3277
3706
  t.setAreaRestriction(areaRestriction);
3278
- }
3279
- //关闭区域限制
3707
+ } //关闭区域限制
3708
+
3709
+
3280
3710
  if (typeof isClearAreaRestriction == 'boolean' && isClearAreaRestriction || isClearAreaRestriction && isClearAreaRestriction !== t.props.isClearAreaRestriction) {
3281
3711
  t.clearAreaRestriction();
3282
- }
3283
- //清空地图
3712
+ } //清空地图
3713
+
3714
+
3284
3715
  if (typeof isClearAll == 'boolean' && isClearAll || isClearAll && isClearAll !== t.props.isClearAll) {
3285
3716
  t.clearAll();
3286
- }
3287
- //删除指定图元
3717
+ } //删除指定图元
3718
+
3719
+
3288
3720
  if (typeof isRemove == 'boolean' && isRemove || isRemove && isRemove !== t.props.isRemove) {
3289
3721
  mapRemove.map(function (item, index) {
3290
3722
  t.removeGraphic(item.id, item.type);
3291
3723
  });
3292
- }
3293
- // 比例尺控件位置改变
3724
+ } // 比例尺控件位置改变
3725
+
3726
+
3294
3727
  if (nextProps.showControl && JSON.stringify(nextProps.showControl) != JSON.stringify(t.props.showControl)) {
3295
3728
  t.showControl(nextProps);
3296
- }
3297
- // 比例尺移除
3729
+ } // 比例尺移除
3730
+
3731
+
3298
3732
  if (!nextProps.showControl) {
3299
3733
  t.removeControl();
3300
- }
3301
- // 地图类型控件位置改变
3734
+ } // 地图类型控件位置改变
3735
+
3736
+
3302
3737
  if (nextProps.satelliteSwitch && JSON.stringify(nextProps.satelliteSwitch) != JSON.stringify(t.props.satelliteSwitch)) {
3303
3738
  t.showMapTypeControl(nextProps);
3304
3739
  }
3305
- }
3306
- // 初始化对外方法
3740
+ } // 初始化对外方法
3741
+
3307
3742
  }, {
3308
3743
  key: "initPropsForUser",
3309
3744
  value: function initPropsForUser() {
3310
- var t = this;
3311
- // t.state.gis["getCenter"] = () => {
3745
+ var t = this; // t.state.gis["getCenter"] = () => {
3312
3746
  // return t.getCurrentCenter();
3313
3747
  // }
3748
+
3314
3749
  t.state.gis["setMapCenter"] = function (gt) {
3315
3750
  t.setCenter(gt);
3316
3751
  };
3752
+
3317
3753
  t.state.gis["getZoomLevel"] = function () {
3318
3754
  return t.getZoomLevel();
3319
3755
  };
3756
+
3320
3757
  t.state.gis["showInfoWindow"] = function (obj) {
3321
3758
  return t.showInfoWindow(obj);
3322
3759
  };
3760
+
3323
3761
  t.state.gis["hideInfoWindow"] = function () {
3324
3762
  return t.hideInfoWindow();
3325
3763
  };
3764
+
3326
3765
  t.state.gis["frameSelect"] = function () {
3327
3766
  var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3328
3767
  var callback = arguments.length > 1 ? arguments[1] : undefined;
3329
3768
  return t.frameSelect(obj, callback);
3330
3769
  };
3770
+
3331
3771
  t.state.gis["clearFrameSelect"] = function () {
3332
3772
  return t.clearFrameSelect();
3333
3773
  };
3774
+
3334
3775
  t.state.gis["clearFrameSelectById"] = function (id) {
3335
3776
  return t.clearFrameSelectById(id);
3336
3777
  };
3778
+
3337
3779
  t.state.gis["refresh"] = function () {
3338
3780
  t.refresh();
3339
3781
  };
@@ -3343,18 +3785,25 @@ var BaiduMap = /*#__PURE__*/function (_React$Component) {
3343
3785
  value: function componentWillUnmount() {
3344
3786
  //关闭moveTo定时
3345
3787
  var t = this;
3788
+
3346
3789
  if (t.state.gis) {
3347
3790
  t.state.gis.clearOverlays();
3348
3791
  }
3792
+
3349
3793
  t.state.gis = null;
3794
+
3350
3795
  if (t.moveToTimer) {
3351
3796
  clearInterval(t.moveToTimer);
3352
3797
  }
3798
+
3353
3799
  window.VtxMap && (window.VtxMap[t.state.mapId] = null);
3354
3800
  }
3355
3801
  }]);
3802
+
3356
3803
  return BaiduMap;
3357
3804
  }(_react["default"].Component);
3358
- var _default = exports["default"] = BaiduMap;
3805
+
3806
+ var _default = BaiduMap;
3807
+ exports["default"] = _default;
3359
3808
  module.exports = exports["default"];
3360
3809
  //# sourceMappingURL=Map.js.map