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