@vtx/map 1.1.37 → 1.1.39

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