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