@vtx/map 1.2.23 → 1.2.24

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