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