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