@vtx/map 1.1.49 → 1.1.51
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 +1003 -633
- package/lib/VtxMap/AMap/AMap.js.map +1 -1
- package/lib/VtxMap/BMap/Map.js +1198 -749
- package/lib/VtxMap/BMap/Map.js.map +1 -1
- package/lib/VtxMap/GMap/Map.js +1564 -1046
- package/lib/VtxMap/GMap/Map.js.map +1 -1
- package/lib/VtxMap/Map.js +42 -8
- package/lib/VtxMap/Map.js.map +1 -1
- package/lib/VtxMap/MapToolFunction.js +63 -26
- package/lib/VtxMap/MapToolFunction.js.map +1 -1
- package/lib/VtxMap/OMap/Map.js +1361 -867
- package/lib/VtxMap/OMap/Map.js.map +1 -1
- package/lib/VtxMap/OlMap/Map.js +1243 -722
- package/lib/VtxMap/OlMap/Map.js.map +1 -1
- package/lib/VtxMap/TMap/TMap.js +1059 -652
- package/lib/VtxMap/TMap/TMap.js.map +1 -1
- package/lib/VtxMap/index.js +8 -1
- package/lib/VtxMap/index.js.map +1 -1
- package/lib/VtxMap/mapPlayer.js +123 -67
- package/lib/VtxMap/mapPlayer.js.map +1 -1
- package/lib/VtxMap/optimizingPointMap.js +77 -21
- package/lib/VtxMap/optimizingPointMap.js.map +1 -1
- package/lib/VtxMap/style/css.js +6 -0
- package/lib/VtxMap/style/css.js.map +1 -1
- package/lib/VtxMap/style/index.js +6 -0
- package/lib/VtxMap/style/index.js.map +1 -1
- package/lib/VtxMap/zoomMap.js +41 -12
- package/lib/VtxMap/zoomMap.js.map +1 -1
- package/lib/VtxModal/VtxModal.js +63 -19
- package/lib/VtxModal/VtxModal.js.map +1 -1
- package/lib/VtxModal/draggableModal.js +48 -12
- package/lib/VtxModal/draggableModal.js.map +1 -1
- package/lib/VtxModal/index.js +6 -1
- package/lib/VtxModal/index.js.map +1 -1
- package/lib/VtxModal/style/css.js +6 -0
- package/lib/VtxModal/style/css.js.map +1 -1
- package/lib/VtxModal/style/index.js +6 -0
- package/lib/VtxModal/style/index.js.map +1 -1
- package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js +238 -105
- package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js.map +1 -1
- package/lib/VtxSearchCheckMap/index.js +2 -0
- package/lib/VtxSearchCheckMap/index.js.map +1 -1
- package/lib/VtxSearchCheckMap/mapping.js +2 -1
- package/lib/VtxSearchCheckMap/mapping.js.map +1 -1
- package/lib/VtxSearchCheckMap/style/css.js +19 -0
- package/lib/VtxSearchCheckMap/style/css.js.map +1 -1
- package/lib/VtxSearchCheckMap/style/index.js +19 -0
- package/lib/VtxSearchCheckMap/style/index.js.map +1 -1
- package/lib/VtxSearchMap/VtxSearchMap.js +229 -91
- package/lib/VtxSearchMap/VtxSearchMap.js.map +1 -1
- package/lib/VtxSearchMap/index.js +2 -0
- package/lib/VtxSearchMap/index.js.map +1 -1
- package/lib/VtxSearchMap/mapping.js +2 -1
- package/lib/VtxSearchMap/mapping.js.map +1 -1
- package/lib/VtxSearchMap/style/css.js +19 -0
- package/lib/VtxSearchMap/style/css.js.map +1 -1
- package/lib/VtxSearchMap/style/index.js +19 -0
- package/lib/VtxSearchMap/style/index.js.map +1 -1
- package/lib/default.js +19 -4
- package/lib/default.js.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/util.js +17 -5
- package/lib/utils/util.js.map +1 -1
- package/package.json +1 -1
package/lib/VtxMap/OMap/Map.js
CHANGED
|
@@ -1,62 +1,106 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
9
12
|
var _MapToolFunction = require("../MapToolFunction");
|
|
13
|
+
|
|
10
14
|
var _immutable = _interopRequireDefault(require("immutable"));
|
|
15
|
+
|
|
11
16
|
var _default2 = _interopRequireDefault(require("../../default"));
|
|
17
|
+
|
|
12
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
13
20
|
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; } } }; }
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
|
|
21
|
+
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
17
28
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
29
|
+
|
|
18
30
|
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."); }
|
|
31
|
+
|
|
19
32
|
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); }
|
|
33
|
+
|
|
20
34
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
35
|
+
|
|
21
36
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
22
|
-
|
|
37
|
+
|
|
38
|
+
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; }
|
|
39
|
+
|
|
23
40
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
24
|
-
|
|
41
|
+
|
|
42
|
+
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); } }
|
|
43
|
+
|
|
25
44
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
26
|
-
|
|
27
|
-
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); }
|
|
45
|
+
|
|
28
46
|
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); }
|
|
47
|
+
|
|
29
48
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
49
|
+
|
|
30
50
|
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); }; }
|
|
51
|
+
|
|
31
52
|
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); }
|
|
53
|
+
|
|
32
54
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
55
|
+
|
|
33
56
|
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; } }
|
|
57
|
+
|
|
34
58
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
-
|
|
36
|
-
//公共地址配置
|
|
59
|
+
|
|
60
|
+
var Set = _immutable["default"].Set; //公共地址配置
|
|
61
|
+
|
|
37
62
|
var Map = /*#__PURE__*/function (_React$Component) {
|
|
38
63
|
_inherits(Map, _React$Component);
|
|
64
|
+
|
|
39
65
|
var _super = _createSuper(Map);
|
|
66
|
+
|
|
40
67
|
function Map(props) {
|
|
41
68
|
var _this;
|
|
69
|
+
|
|
42
70
|
_classCallCheck(this, Map);
|
|
71
|
+
|
|
43
72
|
_this = _super.call(this, props);
|
|
44
73
|
_this.GM = new _MapToolFunction.graphicManage(); //初始化 图元管理方法
|
|
74
|
+
|
|
45
75
|
_this.initPointIndex = 0; //初始化地图时记录点当前位置
|
|
76
|
+
|
|
46
77
|
_this._cluster = null; //点聚合对象
|
|
78
|
+
|
|
47
79
|
_this.clusterIdList = []; //点聚合id集合
|
|
80
|
+
|
|
48
81
|
_this._rangingTool = null; //测距对象
|
|
82
|
+
|
|
49
83
|
_this._bmar = null; //区域限制对象
|
|
84
|
+
|
|
50
85
|
_this._drawmanager = null; //图元绘制对象
|
|
86
|
+
|
|
51
87
|
_this.editGraphicChange = null; //编辑方法回调
|
|
88
|
+
|
|
52
89
|
_this.editTimeout = null; //圆编辑回调延迟时间对象
|
|
90
|
+
|
|
53
91
|
_this._boundary = null; //获取行政区域数据的对象
|
|
92
|
+
|
|
54
93
|
_this.moveToTimer = null; //moveTo时间对象
|
|
94
|
+
|
|
55
95
|
_this.heatmap = null; //热力图对象
|
|
96
|
+
|
|
56
97
|
_this.morepoints = []; //海量点数组
|
|
98
|
+
|
|
57
99
|
_this.movePoints = []; //移动点的动画集合
|
|
100
|
+
|
|
58
101
|
_this.editEvent = {}; //编辑监听的事件
|
|
59
102
|
//是否绘制测距
|
|
103
|
+
|
|
60
104
|
_this.rangingTool = {
|
|
61
105
|
isRanging: false,
|
|
62
106
|
//是否开启状态
|
|
@@ -72,6 +116,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
72
116
|
isDbclick: false
|
|
73
117
|
};
|
|
74
118
|
_this.rangingTools = {}; //测距点线缓存
|
|
119
|
+
|
|
75
120
|
_this.mapCreated = false;
|
|
76
121
|
_this.state = {
|
|
77
122
|
gis: null,
|
|
@@ -102,25 +147,31 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
102
147
|
};
|
|
103
148
|
_this.cacheImgRecord = {}; //缓存图片记录,避免多次加载缓存
|
|
104
149
|
// 图片缓存dom位置
|
|
150
|
+
|
|
105
151
|
var cacheImg = document.getElementById('vtxomapdefaultimg');
|
|
152
|
+
|
|
106
153
|
if (!cacheImg) {
|
|
107
154
|
cacheImg = _this.cacheImg = document.createElement('div');
|
|
108
155
|
cacheImg.id = 'vtxomapcacheImg';
|
|
109
156
|
cacheImg.style.display = 'none';
|
|
110
157
|
document.body.appendChild(cacheImg);
|
|
111
158
|
}
|
|
112
|
-
|
|
113
|
-
//缓存默认点位地址
|
|
159
|
+
|
|
160
|
+
_this.cacheImg = cacheImg; //缓存默认点位地址
|
|
161
|
+
|
|
114
162
|
if (!document.getElementById('vtxomapdefaultimg')) {
|
|
115
163
|
var defImg = new Image();
|
|
116
164
|
defImg.src = "".concat(_default2["default"].mapServerURL, "/images/defaultMarker.png");
|
|
117
165
|
defImg.id = 'vtxomapdefaultimg';
|
|
118
166
|
cacheImg.appendChild(defImg);
|
|
119
|
-
}
|
|
120
|
-
|
|
167
|
+
} //加载地图
|
|
168
|
+
|
|
169
|
+
|
|
121
170
|
_this.loadMapJs();
|
|
171
|
+
|
|
122
172
|
return _this;
|
|
123
173
|
}
|
|
174
|
+
|
|
124
175
|
_createClass(Map, [{
|
|
125
176
|
key: "loadMapJs",
|
|
126
177
|
value: function loadMapJs() {
|
|
@@ -148,67 +199,76 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
148
199
|
});
|
|
149
200
|
}
|
|
150
201
|
});
|
|
151
|
-
}
|
|
152
|
-
|
|
202
|
+
} //初始化地图数据
|
|
203
|
+
|
|
153
204
|
}, {
|
|
154
205
|
key: "init",
|
|
155
206
|
value: function init() {
|
|
156
|
-
var t = this;
|
|
157
|
-
|
|
207
|
+
var t = this; //创建地图
|
|
208
|
+
|
|
158
209
|
t.createMap();
|
|
159
210
|
var _this$props = this.props,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
211
|
+
mapPoints = _this$props.mapPoints,
|
|
212
|
+
mapLines = _this$props.mapLines,
|
|
213
|
+
mapPolygons = _this$props.mapPolygons,
|
|
214
|
+
mapCircles = _this$props.mapCircles,
|
|
215
|
+
mapVisiblePoints = _this$props.mapVisiblePoints,
|
|
216
|
+
mapCluster = _this$props.mapCluster,
|
|
217
|
+
mapZoomLevel = _this$props.mapZoomLevel,
|
|
218
|
+
isOpenTrafficInfo = _this$props.isOpenTrafficInfo,
|
|
219
|
+
mapPointCollection = _this$props.mapPointCollection,
|
|
220
|
+
areaRestriction = _this$props.areaRestriction;
|
|
170
221
|
var _this$props2 = this.props,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
222
|
+
boundaryName = _this$props2.boundaryName,
|
|
223
|
+
heatMapData = _this$props2.heatMapData,
|
|
224
|
+
customizedBoundary = _this$props2.customizedBoundary;
|
|
174
225
|
var _this$state = this.state,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
226
|
+
boundaryInfo = _this$state.boundaryInfo,
|
|
227
|
+
pointIds = _this$state.pointIds,
|
|
228
|
+
lineIds = _this$state.lineIds,
|
|
229
|
+
polygonIds = _this$state.polygonIds,
|
|
230
|
+
circleIds = _this$state.circleIds; // //添加点
|
|
231
|
+
|
|
181
232
|
if (mapPoints instanceof Array) {
|
|
182
233
|
t.addPoint(mapPoints);
|
|
183
|
-
}
|
|
184
|
-
|
|
234
|
+
} //添加线
|
|
235
|
+
|
|
236
|
+
|
|
185
237
|
if (mapLines instanceof Array) {
|
|
186
238
|
t.addLine(mapLines);
|
|
187
|
-
}
|
|
188
|
-
|
|
239
|
+
} //添加面
|
|
240
|
+
|
|
241
|
+
|
|
189
242
|
if (mapPolygons instanceof Array) {
|
|
190
243
|
t.addPolygon(mapPolygons);
|
|
191
|
-
}
|
|
192
|
-
|
|
244
|
+
} //添加圆
|
|
245
|
+
|
|
246
|
+
|
|
193
247
|
if (mapCircles instanceof Array) {
|
|
194
248
|
t.addCircle(mapCircles);
|
|
195
|
-
}
|
|
196
|
-
|
|
249
|
+
} // 画热力图
|
|
250
|
+
|
|
251
|
+
|
|
197
252
|
if (heatMapData) {
|
|
198
253
|
t.heatMapOverlay(heatMapData);
|
|
199
254
|
}
|
|
255
|
+
|
|
200
256
|
if (mapPointCollection instanceof Array) {
|
|
201
257
|
t.addPointCollection(mapPointCollection);
|
|
202
258
|
}
|
|
203
259
|
/*设置指定图元展示*/
|
|
260
|
+
|
|
261
|
+
|
|
204
262
|
if (mapVisiblePoints) {
|
|
205
263
|
t.setVisiblePoints(mapVisiblePoints);
|
|
206
|
-
}
|
|
207
|
-
|
|
264
|
+
} //设置点聚合
|
|
265
|
+
|
|
266
|
+
|
|
208
267
|
if (mapCluster instanceof Array) {
|
|
209
268
|
t.cluster(mapCluster);
|
|
210
|
-
}
|
|
211
|
-
|
|
269
|
+
} //开关路况
|
|
270
|
+
|
|
271
|
+
|
|
212
272
|
if (isOpenTrafficInfo) {
|
|
213
273
|
t.openTrafficInfo();
|
|
214
274
|
} else {
|
|
@@ -216,61 +276,69 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
216
276
|
}
|
|
217
277
|
/*地图事件*/
|
|
218
278
|
//初始化地图点击事件
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
t.
|
|
222
|
-
|
|
223
|
-
t.
|
|
224
|
-
|
|
225
|
-
t.
|
|
226
|
-
|
|
227
|
-
t.
|
|
228
|
-
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
t.clickMap(); //地图拖动之前事件
|
|
282
|
+
|
|
283
|
+
t.dragMapStart(); // //地图拖动结束后事件
|
|
284
|
+
|
|
285
|
+
t.dragMapEnd(); // //地图移动之前事件
|
|
286
|
+
|
|
287
|
+
t.moveStart(); // //地图缩放开始前事件
|
|
288
|
+
|
|
289
|
+
t.zoomStart(); // //地图移动结束后事件/地图缩放结束后事件
|
|
290
|
+
|
|
229
291
|
t.moveEndAndZoomEnd();
|
|
230
292
|
this.mapCreated = true;
|
|
231
|
-
}
|
|
232
|
-
|
|
293
|
+
} //创建地图
|
|
294
|
+
|
|
233
295
|
}, {
|
|
234
296
|
key: "createMap",
|
|
235
297
|
value: function createMap() {
|
|
236
298
|
var t = this;
|
|
237
299
|
var _t$props = t.props,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
300
|
+
mapCenter = _t$props.mapCenter,
|
|
301
|
+
mapId = _t$props.mapId,
|
|
302
|
+
mapZoomLevel = _t$props.mapZoomLevel,
|
|
303
|
+
minZoom = _t$props.minZoom,
|
|
304
|
+
maxZoom = _t$props.maxZoom,
|
|
305
|
+
showControl = _t$props.showControl,
|
|
306
|
+
areaRestriction = _t$props.areaRestriction;
|
|
245
307
|
var options = {
|
|
246
308
|
zoom: mapZoomLevel || 10,
|
|
247
309
|
center: mapCenter || [626.3002300508477, 37.90942995363547],
|
|
248
310
|
minZoom: minZoom || 0,
|
|
249
311
|
maxZoom: maxZoom || 22
|
|
250
|
-
};
|
|
251
|
-
|
|
312
|
+
}; //缓存 zoom等级,用于事件判断
|
|
313
|
+
|
|
252
314
|
t.oldZoomLevel = options.zoom;
|
|
315
|
+
|
|
253
316
|
if (window.VtxMap) {
|
|
254
317
|
window.VtxMap[mapId] = null;
|
|
255
318
|
} else {
|
|
256
319
|
window.VtxMap = {};
|
|
257
|
-
}
|
|
258
|
-
|
|
320
|
+
} // 地图控件处理
|
|
321
|
+
|
|
322
|
+
|
|
259
323
|
var isShowControl = false,
|
|
260
|
-
|
|
324
|
+
controlPosition = t.matchControlPosition();
|
|
325
|
+
|
|
261
326
|
if (showControl) {
|
|
262
327
|
controlPosition = t.matchControlPosition(showControl.location);
|
|
263
328
|
isShowControl = !!showControl;
|
|
264
329
|
}
|
|
330
|
+
|
|
265
331
|
var latLngBounds = [];
|
|
332
|
+
|
|
266
333
|
if (areaRestriction && Array.isArray(areaRestriction) && Array.isArray(areaRestriction[0])) {
|
|
267
334
|
//处理 区域限制数据
|
|
268
335
|
latLngBounds = [areaRestriction[0][0], areaRestriction[0][1], areaRestriction[1][0], areaRestriction[1][1]];
|
|
269
336
|
latLngBounds.sort(function (a, b) {
|
|
270
337
|
return a - b;
|
|
271
338
|
});
|
|
272
|
-
}
|
|
273
|
-
|
|
339
|
+
} //创建地图 缓存地图对象
|
|
340
|
+
|
|
341
|
+
|
|
274
342
|
var map = window.VtxMap[mapId] = t.state.gis = new t.omap.Map(document.getElementById(mapId.toString()), {
|
|
275
343
|
center: {
|
|
276
344
|
lng: options.center[0],
|
|
@@ -316,40 +384,55 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
316
384
|
}
|
|
317
385
|
});
|
|
318
386
|
/*=================================start========================================*/
|
|
387
|
+
|
|
319
388
|
/*
|
|
320
389
|
draw对象声明, 绘制返回方法实现
|
|
321
390
|
*/
|
|
391
|
+
|
|
322
392
|
if (!t._drawmanager) {
|
|
323
393
|
t._drawmanager = new google.maps.drawing.DrawingManager({
|
|
324
394
|
drawingControl: false
|
|
325
395
|
});
|
|
396
|
+
|
|
326
397
|
t._drawmanager.setMap(t.state.gis);
|
|
327
398
|
}
|
|
328
399
|
/*=================================start========================================*/
|
|
329
400
|
//初始化点聚合对象
|
|
401
|
+
|
|
402
|
+
|
|
330
403
|
if (!t._cluster) {
|
|
331
404
|
t._cluster = new OMapLib.MarkerClusterer(map, [], {
|
|
332
405
|
maxZoom: options.maxZoom
|
|
333
406
|
});
|
|
334
407
|
}
|
|
335
408
|
/*=================================start========================================*/
|
|
409
|
+
|
|
336
410
|
/*
|
|
337
411
|
声明OverlayView 类
|
|
338
412
|
用于切换lnglat和 pixel
|
|
339
413
|
*/
|
|
414
|
+
|
|
415
|
+
|
|
340
416
|
function CanvasProjectionOverlay() {}
|
|
417
|
+
|
|
341
418
|
CanvasProjectionOverlay.prototype = new google.maps.OverlayView();
|
|
342
419
|
CanvasProjectionOverlay.prototype.constructor = CanvasProjectionOverlay;
|
|
420
|
+
|
|
343
421
|
CanvasProjectionOverlay.prototype.onAdd = function () {};
|
|
422
|
+
|
|
344
423
|
CanvasProjectionOverlay.prototype.draw = function () {};
|
|
424
|
+
|
|
345
425
|
CanvasProjectionOverlay.prototype.onRemove = function () {};
|
|
426
|
+
|
|
346
427
|
this.canvasProjectionOverlay = new CanvasProjectionOverlay();
|
|
347
428
|
this.canvasProjectionOverlay.setMap(map);
|
|
348
429
|
/*=================================start========================================*/
|
|
430
|
+
|
|
349
431
|
/*
|
|
350
432
|
重写marker对象,支持html
|
|
351
433
|
要使用google对象,所以在creatMap中声明
|
|
352
434
|
*/
|
|
435
|
+
|
|
353
436
|
var MyLabel = t.MyLabel = function (map) {
|
|
354
437
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
355
438
|
//编辑
|
|
@@ -357,11 +440,11 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
357
440
|
this.editParam = {
|
|
358
441
|
sx: 0,
|
|
359
442
|
sy: 0
|
|
360
|
-
};
|
|
361
|
-
|
|
443
|
+
}; //地图
|
|
444
|
+
|
|
362
445
|
this.map = map;
|
|
363
|
-
this.isLabel = options.isLabel;
|
|
364
|
-
|
|
446
|
+
this.isLabel = options.isLabel; //基本参数
|
|
447
|
+
|
|
365
448
|
this.labelClass = options.labelClass;
|
|
366
449
|
this.labelContent = options.labelContent;
|
|
367
450
|
this.labelOffset = options.labelOffset || {
|
|
@@ -371,19 +454,21 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
371
454
|
this.lnglat = options.lnglat;
|
|
372
455
|
this._label = null;
|
|
373
456
|
this.funs = {};
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
//添加地图时被调用(setMap时被调用)
|
|
457
|
+
}; //继承OverlayView类
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
MyLabel.prototype = new google.maps.OverlayView(); //添加地图时被调用(setMap时被调用)
|
|
461
|
+
|
|
378
462
|
MyLabel.prototype.onAdd = function () {
|
|
379
463
|
//创建文字标签
|
|
380
464
|
if (!this._label) {
|
|
381
465
|
this._label = document.createElement('div');
|
|
382
466
|
this._label.innerHTML = this.labelContent;
|
|
383
467
|
this._label.style.position = 'absolute';
|
|
384
|
-
this._label.className = this.labelClass;
|
|
385
|
-
|
|
468
|
+
this._label.className = this.labelClass; //获取承载点位的框
|
|
469
|
+
|
|
386
470
|
var panes = this.getPanes();
|
|
471
|
+
|
|
387
472
|
if (this.isLabel) {
|
|
388
473
|
panes.markerLayer.appendChild(this._label);
|
|
389
474
|
} else {
|
|
@@ -393,23 +478,27 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
393
478
|
this._label.innerHTML = this.labelContent;
|
|
394
479
|
this._label.className = this.labelClass;
|
|
395
480
|
}
|
|
481
|
+
|
|
396
482
|
for (var i in this.funs) {
|
|
397
483
|
this.removeListener(i);
|
|
398
484
|
this.addListener(i, this.funs[i]);
|
|
399
485
|
}
|
|
400
|
-
};
|
|
401
|
-
|
|
486
|
+
}; //计算位置, onAdd和缩放和平移之后调用
|
|
487
|
+
|
|
488
|
+
|
|
402
489
|
MyLabel.prototype.draw = function () {
|
|
403
490
|
//返回MapCanvasProjection对象,拥有计算pixel和lnglat的方法
|
|
404
|
-
var overlayProjection = this.getProjection();
|
|
405
|
-
|
|
491
|
+
var overlayProjection = this.getProjection(); //将地理坐标转换成屏幕坐标
|
|
492
|
+
|
|
406
493
|
var position = overlayProjection.fromLatLngToDivPixel(this.lnglat);
|
|
494
|
+
|
|
407
495
|
if (position) {
|
|
408
496
|
this._label.style.left = position.x + parseFloat(this.labelOffset.x) + 'px';
|
|
409
497
|
this._label.style.top = position.y + parseFloat(this.labelOffset.y) + 'px';
|
|
410
498
|
}
|
|
411
|
-
};
|
|
412
|
-
|
|
499
|
+
}; //更新点位信息
|
|
500
|
+
|
|
501
|
+
|
|
413
502
|
MyLabel.prototype.setOptions = function (options) {
|
|
414
503
|
this.labelClass = options.labelClass;
|
|
415
504
|
this.labelContent = options.labelContent;
|
|
@@ -418,52 +507,64 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
418
507
|
y: 0
|
|
419
508
|
};
|
|
420
509
|
this.lnglat = options.lnglat || this.lnglat;
|
|
510
|
+
|
|
421
511
|
if (this._label) {
|
|
422
512
|
this.onAdd();
|
|
423
513
|
}
|
|
424
|
-
};
|
|
425
|
-
|
|
514
|
+
}; //更新点位信息
|
|
515
|
+
|
|
516
|
+
|
|
426
517
|
MyLabel.prototype.setPosition = function (lnglat) {
|
|
427
518
|
this.lnglat = lnglat;
|
|
519
|
+
|
|
428
520
|
if (this._label) {
|
|
429
521
|
this.draw();
|
|
430
522
|
} else {
|
|
431
523
|
//触发onAdd draw
|
|
432
524
|
this.setMap(map);
|
|
433
525
|
}
|
|
434
|
-
};
|
|
435
|
-
|
|
526
|
+
}; //更新点位信息
|
|
527
|
+
|
|
528
|
+
|
|
436
529
|
MyLabel.prototype.getPosition = function () {
|
|
437
530
|
return this.lnglat;
|
|
438
|
-
};
|
|
439
|
-
|
|
531
|
+
}; //更新点位信息
|
|
532
|
+
|
|
533
|
+
|
|
440
534
|
MyLabel.prototype.setZIndex = function (index) {
|
|
441
535
|
if (this._label) {
|
|
442
536
|
this._label.style.ZIndex = index;
|
|
443
537
|
}
|
|
444
|
-
};
|
|
445
|
-
|
|
538
|
+
}; //用于updatePoint时 判断原来的点图元类型
|
|
539
|
+
|
|
540
|
+
|
|
446
541
|
MyLabel.prototype.isMarkerContent = function () {
|
|
447
542
|
return true;
|
|
448
|
-
};
|
|
449
|
-
|
|
543
|
+
}; //被删除时会调用
|
|
544
|
+
|
|
545
|
+
|
|
450
546
|
MyLabel.prototype.onRemove = function () {
|
|
451
547
|
this._label.parentNode.removeChild(this._label);
|
|
548
|
+
|
|
452
549
|
this._label = null;
|
|
453
550
|
};
|
|
551
|
+
|
|
454
552
|
MyLabel.prototype.addListener = function (key, fun) {
|
|
455
553
|
var tt = this;
|
|
554
|
+
|
|
456
555
|
if (key == 'dragend') {
|
|
457
556
|
//编辑返回函数
|
|
458
557
|
this.dragendFun = fun;
|
|
459
558
|
return false;
|
|
460
559
|
}
|
|
560
|
+
|
|
461
561
|
setTimeout(function () {
|
|
462
562
|
if (tt._label) {
|
|
463
563
|
tt.funs[key] = function (event) {
|
|
464
564
|
if (event.stopPropagation) {
|
|
465
565
|
event.stopPropagation();
|
|
466
566
|
}
|
|
567
|
+
|
|
467
568
|
if (!tt.editable) {
|
|
468
569
|
fun({
|
|
469
570
|
latLng: tt.lnglat,
|
|
@@ -472,103 +573,124 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
472
573
|
});
|
|
473
574
|
}
|
|
474
575
|
};
|
|
576
|
+
|
|
475
577
|
tt._label.addEventListener(key, tt.funs[key]);
|
|
476
578
|
} else {
|
|
477
579
|
tt.addListener(key, fun);
|
|
478
580
|
}
|
|
479
581
|
}, 50);
|
|
480
582
|
};
|
|
583
|
+
|
|
481
584
|
MyLabel.prototype.removeListener = function (key) {
|
|
482
585
|
if (key == 'dragend') {
|
|
483
586
|
this.dragendFun = function () {};
|
|
587
|
+
|
|
484
588
|
return false;
|
|
485
589
|
}
|
|
590
|
+
|
|
486
591
|
if (this._label) {
|
|
487
592
|
this._label.removeEventListener(key, this.funs[key]);
|
|
488
593
|
}
|
|
489
|
-
};
|
|
490
|
-
|
|
594
|
+
}; //设置是否可以编辑
|
|
595
|
+
|
|
596
|
+
|
|
491
597
|
MyLabel.prototype.setDraggable = function (_boolean) {
|
|
492
598
|
this.editable = _boolean;
|
|
599
|
+
|
|
493
600
|
if (_boolean) {
|
|
494
601
|
this.edit();
|
|
495
602
|
} else {
|
|
496
603
|
this._label.removeEventListener('mousedown', this.mdown);
|
|
497
604
|
}
|
|
498
|
-
};
|
|
499
|
-
|
|
605
|
+
}; //编辑时 事件和逻辑
|
|
606
|
+
|
|
607
|
+
|
|
500
608
|
MyLabel.prototype.edit = function () {
|
|
501
609
|
var tt = this;
|
|
610
|
+
|
|
502
611
|
tt.mdown = function (event) {
|
|
503
|
-
event.stopPropagation();
|
|
504
|
-
|
|
505
|
-
tt._label.className = 'noselect';
|
|
506
|
-
|
|
612
|
+
event.stopPropagation(); //禁止文本选中
|
|
613
|
+
|
|
614
|
+
tt._label.className = 'noselect'; // 记录原始位置
|
|
615
|
+
|
|
507
616
|
tt.editParam.sx = event.clientX;
|
|
508
617
|
tt.editParam.sy = event.clientY;
|
|
618
|
+
|
|
509
619
|
var mmEvent = function mmEvent(e) {
|
|
510
|
-
e.stopPropagation();
|
|
511
|
-
|
|
620
|
+
e.stopPropagation(); //计算与上一次的差值 累加到label dom上
|
|
621
|
+
|
|
512
622
|
tt._label.style.left = parseFloat(tt._label.style.left.replace('px', '')) + e.clientX - tt.editParam.sx + 'px';
|
|
513
|
-
tt._label.style.top = parseFloat(tt._label.style.top.replace('px', '')) + e.clientY - tt.editParam.sy + 'px';
|
|
514
|
-
|
|
623
|
+
tt._label.style.top = parseFloat(tt._label.style.top.replace('px', '')) + e.clientY - tt.editParam.sy + 'px'; //更新原始位置
|
|
624
|
+
|
|
515
625
|
tt.editParam.sx = e.clientX;
|
|
516
626
|
tt.editParam.sy = e.clientY;
|
|
517
627
|
};
|
|
628
|
+
|
|
518
629
|
var mupEvent = function mupEvent(e) {
|
|
519
|
-
e.stopPropagation();
|
|
520
|
-
|
|
630
|
+
e.stopPropagation(); //计算与上一次的差值 累加到label dom上
|
|
631
|
+
|
|
521
632
|
var x = parseFloat(tt._label.style.left.replace('px', '')) + e.clientX - tt.editParam.sx,
|
|
522
|
-
|
|
523
|
-
|
|
633
|
+
y = parseFloat(tt._label.style.top.replace('px', '')) + e.clientY - tt.editParam.sy; //计算经纬度,固定label的位置
|
|
634
|
+
|
|
524
635
|
tt._label.style.left = x + 'px';
|
|
525
636
|
tt._label.style.top = y + 'px';
|
|
526
637
|
var overlayProjection = tt.getProjection(),
|
|
527
|
-
|
|
528
|
-
tt.setPosition(latlng);
|
|
529
|
-
|
|
638
|
+
latlng = overlayProjection.fromDivPixelToLatLng(new google.maps.Point(x, y));
|
|
639
|
+
tt.setPosition(latlng); // 清空 文本禁选
|
|
640
|
+
|
|
530
641
|
tt._label.className = '';
|
|
531
|
-
tt.dragendFun(e);
|
|
532
|
-
|
|
642
|
+
tt.dragendFun(e); //关闭全局监听
|
|
643
|
+
|
|
533
644
|
document.removeEventListener('mousemove', mmEvent);
|
|
534
645
|
document.removeEventListener('mouseup', mupEvent);
|
|
535
646
|
};
|
|
647
|
+
|
|
536
648
|
document.addEventListener('mousemove', mmEvent);
|
|
537
649
|
document.addEventListener('mouseup', mupEvent);
|
|
538
650
|
};
|
|
651
|
+
|
|
539
652
|
tt._label.addEventListener('mousedown', tt.mdown);
|
|
540
653
|
};
|
|
541
654
|
/*=================================end========================================*/
|
|
542
|
-
|
|
543
|
-
//设置指定图元展示 google只有zoom和center全适应,单适应暂时无法实现
|
|
655
|
+
|
|
656
|
+
} //设置指定图元展示 google只有zoom和center全适应,单适应暂时无法实现
|
|
657
|
+
|
|
544
658
|
}, {
|
|
545
659
|
key: "setVisiblePoints",
|
|
546
660
|
value: function setVisiblePoints(obj) {
|
|
547
661
|
var t = this;
|
|
548
662
|
var ls = [];
|
|
549
663
|
var _t$state = t.state,
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
664
|
+
pointIds = _t$state.pointIds,
|
|
665
|
+
lineIds = _t$state.lineIds,
|
|
666
|
+
polygonIds = _t$state.polygonIds,
|
|
667
|
+
circleIds = _t$state.circleIds;
|
|
668
|
+
|
|
554
669
|
var getLngLats = function getLngLats(ids, type) {
|
|
555
670
|
var alnglat = [],
|
|
556
|
-
|
|
557
|
-
|
|
671
|
+
lngs = [],
|
|
672
|
+
lats = [];
|
|
673
|
+
|
|
558
674
|
if (!type) {
|
|
559
675
|
t.GM.getMoreGraphicParam(ids).map(function (item, index) {
|
|
560
676
|
var _alnglat, _alnglat2;
|
|
677
|
+
|
|
561
678
|
//根据天地图 覆盖物类型获取lnglat
|
|
562
679
|
switch (item.geometryType) {
|
|
563
680
|
case 'point':
|
|
564
681
|
alnglat.push([item.geometry.x, item.geometry.y]);
|
|
565
682
|
break;
|
|
683
|
+
|
|
566
684
|
case 'polyline':
|
|
567
685
|
(_alnglat = alnglat).push.apply(_alnglat, _toConsumableArray(item.geometry.paths));
|
|
686
|
+
|
|
568
687
|
break;
|
|
688
|
+
|
|
569
689
|
case 'polygon':
|
|
570
690
|
(_alnglat2 = alnglat).push.apply(_alnglat2, _toConsumableArray(item.geometry.rings));
|
|
691
|
+
|
|
571
692
|
break;
|
|
693
|
+
|
|
572
694
|
case 'circle':
|
|
573
695
|
alnglat.push([item.geometry.x, item.geometry.y]);
|
|
574
696
|
break;
|
|
@@ -577,6 +699,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
577
699
|
} else {
|
|
578
700
|
alnglat = ids;
|
|
579
701
|
}
|
|
702
|
+
|
|
580
703
|
alnglat.forEach(function (item, index) {
|
|
581
704
|
lngs.push(item[0]);
|
|
582
705
|
lats.push(item[1]);
|
|
@@ -593,59 +716,74 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
593
716
|
lat: lats[lats.length - 1]
|
|
594
717
|
})
|
|
595
718
|
};
|
|
596
|
-
};
|
|
597
|
-
|
|
719
|
+
}; //算出 要展示的图元点位
|
|
720
|
+
|
|
721
|
+
|
|
598
722
|
switch (obj.fitView) {
|
|
599
723
|
case 'point':
|
|
600
724
|
ls = getLngLats(pointIds);
|
|
601
725
|
break;
|
|
726
|
+
|
|
602
727
|
case 'line':
|
|
603
728
|
ls = getLngLats(lineIds);
|
|
604
729
|
break;
|
|
730
|
+
|
|
605
731
|
case 'polygon':
|
|
606
732
|
ls = getLngLats(polygonIds);
|
|
607
733
|
break;
|
|
734
|
+
|
|
608
735
|
case 'circle':
|
|
609
736
|
ls = getLngLats(circleIds);
|
|
610
737
|
break;
|
|
738
|
+
|
|
611
739
|
case 'all':
|
|
612
740
|
ls = getLngLats([].concat(_toConsumableArray(pointIds), _toConsumableArray(lineIds), _toConsumableArray(polygonIds), _toConsumableArray(circleIds)));
|
|
613
741
|
break;
|
|
742
|
+
|
|
614
743
|
default:
|
|
615
744
|
var ids = [];
|
|
745
|
+
|
|
616
746
|
if (obj.fitView instanceof Array) {
|
|
617
747
|
ids = obj.fitView;
|
|
618
748
|
} else if (typeof obj.fitView === 'string') {
|
|
619
749
|
ids = obj.fitView.split(',');
|
|
620
|
-
}
|
|
621
|
-
|
|
750
|
+
} //支持传经纬度
|
|
751
|
+
|
|
752
|
+
|
|
622
753
|
if (ids[0] instanceof Array) {
|
|
623
754
|
ls = getLngLats(ids, 'lnglat');
|
|
624
755
|
} else {
|
|
625
756
|
ls = getLngLats(ids);
|
|
626
757
|
}
|
|
758
|
+
|
|
627
759
|
break;
|
|
628
760
|
}
|
|
761
|
+
|
|
629
762
|
t.state.gis.fitBounds(new google.maps.LatLngBounds(ls.sw, ls.ne));
|
|
630
|
-
}
|
|
631
|
-
|
|
763
|
+
} //设置地图中心位置 lng/经度 lat/纬度
|
|
764
|
+
|
|
632
765
|
}, {
|
|
633
766
|
key: "setCenter",
|
|
634
767
|
value: function setCenter(gt) {
|
|
635
768
|
var t = this;
|
|
636
769
|
var mgt = [626.3002300508477, 37.90942995363547];
|
|
770
|
+
|
|
637
771
|
if (gt) {
|
|
638
772
|
//经纬度 必须存在 否则不操作
|
|
639
773
|
if (!gt[0] || !gt[1]) {
|
|
640
774
|
return false;
|
|
641
|
-
}
|
|
642
|
-
|
|
775
|
+
} //如果设置的经纬度 与当前中心点一样 不操作
|
|
776
|
+
|
|
777
|
+
|
|
643
778
|
var c = t.state.gis.getCenter();
|
|
779
|
+
|
|
644
780
|
if (c.lng == gt[0] && c.lat == gt[1]) {
|
|
645
781
|
return false;
|
|
646
782
|
}
|
|
783
|
+
|
|
647
784
|
mgt = gt;
|
|
648
785
|
}
|
|
786
|
+
|
|
649
787
|
t.state.gis.setCenter(new google.maps.LatLng({
|
|
650
788
|
lng: mgt[0],
|
|
651
789
|
lat: mgt[1]
|
|
@@ -653,42 +791,47 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
653
791
|
t.setState({
|
|
654
792
|
center: mgt
|
|
655
793
|
});
|
|
656
|
-
}
|
|
657
|
-
|
|
794
|
+
} //设置地图比例尺
|
|
795
|
+
|
|
658
796
|
}, {
|
|
659
797
|
key: "setZoomLevel",
|
|
660
798
|
value: function setZoomLevel(zoom) {
|
|
661
799
|
var t = this;
|
|
662
800
|
var z = t.getZoomLevel();
|
|
801
|
+
|
|
663
802
|
if (z == zoom) {
|
|
664
803
|
return false;
|
|
665
804
|
}
|
|
805
|
+
|
|
666
806
|
t.state.gis.setZoom(zoom);
|
|
667
|
-
}
|
|
668
|
-
|
|
807
|
+
} //清空地图所有图元
|
|
808
|
+
|
|
669
809
|
}, {
|
|
670
810
|
key: "clearAll",
|
|
671
811
|
value: function clearAll() {
|
|
672
|
-
var t = this;
|
|
673
|
-
|
|
812
|
+
var t = this; //清空热力图
|
|
813
|
+
|
|
674
814
|
if (t.heatmap) {
|
|
675
815
|
t.heatmap.setMap(null);
|
|
676
816
|
}
|
|
677
|
-
|
|
678
|
-
//先清除所有标记
|
|
817
|
+
|
|
818
|
+
t.heatmap = null; //先清除所有标记
|
|
819
|
+
|
|
679
820
|
if (t.clusterIdList.length) {
|
|
680
821
|
t.clearClusters();
|
|
681
822
|
}
|
|
682
|
-
|
|
683
|
-
//清空点
|
|
823
|
+
|
|
824
|
+
t.clearAllPointCollection(); //清空点
|
|
825
|
+
|
|
684
826
|
for (var i in t.GM.allGraphics) {
|
|
685
827
|
if (t.GM.allGraphics[i]) {
|
|
686
828
|
t.GM.allGraphics[i].setMap(null);
|
|
687
829
|
}
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
//清空历史数据记录
|
|
830
|
+
} //清空缓存数据
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
t.GM.clearAll(); //清空历史数据记录
|
|
834
|
+
|
|
692
835
|
t.setState({
|
|
693
836
|
pointIds: [],
|
|
694
837
|
lineIds: [],
|
|
@@ -703,27 +846,32 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
703
846
|
rectangle: []
|
|
704
847
|
}
|
|
705
848
|
});
|
|
706
|
-
}
|
|
707
|
-
//图元功能处理方法
|
|
849
|
+
} //图元功能处理方法
|
|
708
850
|
//新增点位
|
|
851
|
+
|
|
709
852
|
}, {
|
|
710
853
|
key: "addPoint",
|
|
711
854
|
value: function addPoint(mapPoints, type) {
|
|
712
855
|
var _this2 = this;
|
|
856
|
+
|
|
713
857
|
var t = this;
|
|
858
|
+
|
|
714
859
|
var psids = _toConsumableArray(t.state.pointIds);
|
|
860
|
+
|
|
715
861
|
var apf = function apf() {
|
|
716
862
|
mapPoints.map(function (item, index) {
|
|
717
863
|
//如果id重复,直接跳过不执行.
|
|
718
864
|
if (_this2.GM.isRepetition(item.id)) {
|
|
719
865
|
console.warn("\u52A0\u70B9id: ".concat(item.id, " \u91CD\u590D"));
|
|
720
866
|
return false;
|
|
721
|
-
}
|
|
722
|
-
|
|
867
|
+
} //点位数据不符合,直接跳过
|
|
868
|
+
|
|
869
|
+
|
|
723
870
|
if (!item.longitude || !item.latitude) {
|
|
724
871
|
console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
|
|
725
872
|
return false;
|
|
726
873
|
}
|
|
874
|
+
|
|
727
875
|
var cg = {
|
|
728
876
|
width: 30,
|
|
729
877
|
height: 30,
|
|
@@ -737,6 +885,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
737
885
|
markerContentY: -30,
|
|
738
886
|
deg: 0
|
|
739
887
|
};
|
|
888
|
+
|
|
740
889
|
if (item.markerContent) {
|
|
741
890
|
cg = _objectSpread(_objectSpread({}, cg), {}, {
|
|
742
891
|
markerContentX: 0,
|
|
@@ -744,16 +893,19 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
744
893
|
width: 100,
|
|
745
894
|
height: 30
|
|
746
895
|
});
|
|
747
|
-
}
|
|
748
|
-
|
|
896
|
+
} //初始化默认数据
|
|
897
|
+
|
|
898
|
+
|
|
749
899
|
if (item.config) {
|
|
750
900
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
751
901
|
}
|
|
902
|
+
|
|
752
903
|
var position = new t.omap.LatLng({
|
|
753
904
|
lng: item.longitude,
|
|
754
905
|
lat: item.latitude
|
|
755
906
|
});
|
|
756
907
|
var marker = null;
|
|
908
|
+
|
|
757
909
|
if (item.markerContent) {
|
|
758
910
|
/*自定义html加点
|
|
759
911
|
用Label来实现,无法再添加label(高德有判断,实现不同)*/
|
|
@@ -771,15 +923,17 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
771
923
|
// //添加label
|
|
772
924
|
if (item.canShowLabel && cg.labelContent) {
|
|
773
925
|
//label默认样式
|
|
774
|
-
var labelClass = 'label-content';
|
|
775
|
-
|
|
926
|
+
var labelClass = 'label-content'; //接受label自定义样式
|
|
927
|
+
|
|
776
928
|
if (item.labelClass) {
|
|
777
929
|
labelClass = item.labelClass.split(',').join(' ');
|
|
778
930
|
}
|
|
931
|
+
|
|
779
932
|
var label = new t.MyLabel(t.state.gis, {
|
|
780
933
|
isLabel: true,
|
|
781
934
|
labelClass: labelClass,
|
|
782
935
|
labelContent: cg.labelContent,
|
|
936
|
+
|
|
783
937
|
/*
|
|
784
938
|
为和百度等地图相同的参数 加上g.markerContentY值
|
|
785
939
|
label是使用OverlayView手动实现,与marker没有关联的原因
|
|
@@ -789,12 +943,13 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
789
943
|
y: cg.labelPixelY + cg.markerContentY
|
|
790
944
|
}
|
|
791
945
|
});
|
|
792
|
-
label.setPosition(position);
|
|
793
|
-
|
|
946
|
+
label.setPosition(position); //缓存
|
|
947
|
+
|
|
794
948
|
t.GM.setGraphic("".concat(item.id, "_vtxoMap_label"), label);
|
|
795
949
|
}
|
|
796
|
-
|
|
797
|
-
// 360deg 不需要旋转
|
|
950
|
+
|
|
951
|
+
var iconUrl = ''; // 360deg 不需要旋转
|
|
952
|
+
|
|
798
953
|
if (parseFloat(cg.deg) % 360 != 0) {
|
|
799
954
|
iconUrl = new _MapToolFunction.RotateIcon({
|
|
800
955
|
url: item.url || "".concat(_default2["default"].mapServerURL, "/images/defaultMarker.png"),
|
|
@@ -802,6 +957,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
802
957
|
height: cg.height
|
|
803
958
|
});
|
|
804
959
|
}
|
|
960
|
+
|
|
805
961
|
var icon = {
|
|
806
962
|
anchor: {
|
|
807
963
|
x: -cg.markerContentX,
|
|
@@ -814,26 +970,30 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
814
970
|
x: cg.labelPixelX,
|
|
815
971
|
y: cg.labelPixelY
|
|
816
972
|
}
|
|
817
|
-
};
|
|
818
|
-
|
|
973
|
+
}; //添加点到地图
|
|
974
|
+
|
|
819
975
|
marker = new t.omap.Marker({
|
|
820
976
|
icon: icon,
|
|
821
977
|
position: position,
|
|
822
978
|
map: t.state.gis
|
|
823
979
|
});
|
|
980
|
+
|
|
824
981
|
if (item.canShowLabel && cg.labelContent) {
|
|
825
982
|
marker.ishaveLabel = true;
|
|
826
983
|
}
|
|
827
984
|
}
|
|
985
|
+
|
|
828
986
|
if (cg.zIndex || cg.zIndex === 0) {
|
|
829
987
|
marker.setZIndex(cg.zIndex);
|
|
830
988
|
}
|
|
989
|
+
|
|
831
990
|
if (!item.markerContent && cg.BAnimationType == 0) {
|
|
832
991
|
marker.setAnimation(google.maps.Animation.BOUNCE);
|
|
833
992
|
} else if (!item.markerContent && cg.BAnimationType == 1) {
|
|
834
993
|
marker.setAnimation(google.maps.Animation.DROP);
|
|
835
|
-
}
|
|
836
|
-
|
|
994
|
+
} //点击事件
|
|
995
|
+
|
|
996
|
+
|
|
837
997
|
var mClick = marker.addListener('click', function (e) {
|
|
838
998
|
//避免鼠标在图元上 测距工具不起作用
|
|
839
999
|
if (t.rangingTool.isRanging) {
|
|
@@ -841,18 +1001,18 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
841
1001
|
} else {
|
|
842
1002
|
t.clickGraphic(item.id, e);
|
|
843
1003
|
}
|
|
844
|
-
});
|
|
845
|
-
|
|
1004
|
+
}); //鼠标移入事件
|
|
1005
|
+
|
|
846
1006
|
var mMouseover = marker.addListener('mouseover', function (e) {
|
|
847
1007
|
t.mouseOverGraphic(item.id, e);
|
|
848
|
-
});
|
|
849
|
-
|
|
1008
|
+
}); //鼠标移出事件
|
|
1009
|
+
|
|
850
1010
|
var mMouseout = marker.addListener('mouseout', function (e) {
|
|
851
1011
|
t.mouseOutGraphic(item.id, e);
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
psids.push(item.id);
|
|
855
|
-
|
|
1012
|
+
}); //缓存所有点的id
|
|
1013
|
+
|
|
1014
|
+
psids.push(item.id); //缓存当前点的图元对象和基本数据
|
|
1015
|
+
|
|
856
1016
|
t.GM.setGraphic(item.id, marker).setGraphicParam(item.id, {
|
|
857
1017
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
858
1018
|
other: item
|
|
@@ -869,15 +1029,16 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
869
1029
|
mouseout: mMouseout
|
|
870
1030
|
});
|
|
871
1031
|
});
|
|
1032
|
+
|
|
872
1033
|
if (type !== 'defined') {
|
|
873
1034
|
//所有点缓存在state中
|
|
874
|
-
t.state.pointIds = psids;
|
|
875
|
-
// t.setState({
|
|
1035
|
+
t.state.pointIds = psids; // t.setState({
|
|
876
1036
|
// pointIds: psids
|
|
877
1037
|
// });
|
|
878
1038
|
}
|
|
879
|
-
};
|
|
880
|
-
|
|
1039
|
+
}; //内部 不需要旋转图标的处理方式
|
|
1040
|
+
|
|
1041
|
+
|
|
881
1042
|
if (type == 'nodeg') {
|
|
882
1043
|
apf();
|
|
883
1044
|
} else {
|
|
@@ -890,19 +1051,21 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
890
1051
|
t.cacheImg.appendChild(i);
|
|
891
1052
|
t.cacheImgRecord[item.url] = true;
|
|
892
1053
|
}
|
|
893
|
-
});
|
|
894
|
-
|
|
1054
|
+
}); //定时等待 图片缓存,点位旋转功能需要
|
|
1055
|
+
|
|
895
1056
|
t.addPsTimer = setTimeout(function () {
|
|
896
1057
|
apf();
|
|
897
1058
|
}, 200);
|
|
898
1059
|
}
|
|
899
|
-
}
|
|
900
|
-
|
|
1060
|
+
} //更新点位
|
|
1061
|
+
|
|
901
1062
|
}, {
|
|
902
1063
|
key: "updatePoint",
|
|
903
1064
|
value: function updatePoint(mapPoints, type) {
|
|
904
1065
|
var _this3 = this;
|
|
1066
|
+
|
|
905
1067
|
var t = this;
|
|
1068
|
+
|
|
906
1069
|
var upf = function upf() {
|
|
907
1070
|
mapPoints.map(function (item, index) {
|
|
908
1071
|
//判断图元是否存在.
|
|
@@ -911,17 +1074,20 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
911
1074
|
if (!item.longitude || !item.latitude) {
|
|
912
1075
|
console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
|
|
913
1076
|
return false;
|
|
914
|
-
}
|
|
915
|
-
|
|
1077
|
+
} //获取原有的图元 和 对应的label
|
|
1078
|
+
|
|
1079
|
+
|
|
916
1080
|
var gc = t.GM.getGraphic(item.id),
|
|
917
|
-
|
|
918
|
-
|
|
1081
|
+
gc_label = t.GM.getGraphic("".concat(item.id, "_vtxoMap_label")); //更新前删除聚合
|
|
1082
|
+
|
|
919
1083
|
if (t.clusterIdList.indexOf(item.id) > -1) {
|
|
920
1084
|
t._cluster.removeMarker(gc);
|
|
1085
|
+
|
|
921
1086
|
if (gc_label) {
|
|
922
1087
|
t._cluster.removeMarker(gc_label);
|
|
923
1088
|
}
|
|
924
1089
|
}
|
|
1090
|
+
|
|
925
1091
|
var cg = {
|
|
926
1092
|
width: 30,
|
|
927
1093
|
height: 30,
|
|
@@ -935,6 +1101,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
935
1101
|
markerContentY: -30,
|
|
936
1102
|
deg: 0
|
|
937
1103
|
};
|
|
1104
|
+
|
|
938
1105
|
if (item.markerContent) {
|
|
939
1106
|
cg = _objectSpread(_objectSpread({}, cg), {}, {
|
|
940
1107
|
markerContentX: 0,
|
|
@@ -943,16 +1110,18 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
943
1110
|
height: 30
|
|
944
1111
|
});
|
|
945
1112
|
}
|
|
1113
|
+
|
|
946
1114
|
if (item.config) {
|
|
947
1115
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
948
|
-
}
|
|
949
|
-
|
|
1116
|
+
} //新旧经纬度 旧经纬度配合moveTo使用
|
|
1117
|
+
|
|
1118
|
+
|
|
950
1119
|
var position = new t.omap.LatLng({
|
|
951
1120
|
lng: item.longitude,
|
|
952
1121
|
lat: item.latitude
|
|
953
1122
|
});
|
|
954
|
-
var oldPosition = gc.getPosition();
|
|
955
|
-
|
|
1123
|
+
var oldPosition = gc.getPosition(); //前后点位类型都是markerContent
|
|
1124
|
+
|
|
956
1125
|
if (gc.isMarkerContent && gc.isMarkerContent() && item.markerContent) {
|
|
957
1126
|
/*
|
|
958
1127
|
自定义html加点
|
|
@@ -972,11 +1141,11 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
972
1141
|
//清除事件
|
|
973
1142
|
gc.removeListener('click');
|
|
974
1143
|
gc.removeListener('mouseover');
|
|
975
|
-
gc.removeListener('mouseout');
|
|
976
|
-
|
|
1144
|
+
gc.removeListener('mouseout'); //删除原点位
|
|
1145
|
+
|
|
977
1146
|
gc.setMap(null);
|
|
978
|
-
var iconUrl = '';
|
|
979
|
-
|
|
1147
|
+
var iconUrl = ''; // 360deg 不需要旋转
|
|
1148
|
+
|
|
980
1149
|
if (parseFloat(cg.deg) % 360 != 0) {
|
|
981
1150
|
iconUrl = new _MapToolFunction.RotateIcon({
|
|
982
1151
|
url: item.url || "".concat(_default2["default"].mapServerURL, "/images/defaultMarker.png"),
|
|
@@ -984,6 +1153,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
984
1153
|
height: cg.height
|
|
985
1154
|
});
|
|
986
1155
|
}
|
|
1156
|
+
|
|
987
1157
|
var icon = {
|
|
988
1158
|
anchor: {
|
|
989
1159
|
x: -cg.markerContentX,
|
|
@@ -996,29 +1166,33 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
996
1166
|
x: cg.labelPixelX,
|
|
997
1167
|
y: cg.labelPixelY
|
|
998
1168
|
}
|
|
999
|
-
};
|
|
1000
|
-
|
|
1169
|
+
}; //重新加载点位
|
|
1170
|
+
|
|
1001
1171
|
gc = new t.omap.Marker({
|
|
1002
1172
|
icon: icon,
|
|
1003
1173
|
position: oldPosition,
|
|
1004
1174
|
map: t.state.gis
|
|
1005
|
-
});
|
|
1006
|
-
|
|
1175
|
+
}); //切换 图元对象缓存
|
|
1176
|
+
|
|
1007
1177
|
t.GM.setGraphic(item.id, gc);
|
|
1178
|
+
|
|
1008
1179
|
if (item.canShowLabel && cg.labelContent) {
|
|
1009
1180
|
//label默认样式
|
|
1010
|
-
var labelClass = 'label-content';
|
|
1011
|
-
|
|
1181
|
+
var labelClass = 'label-content'; //接受label自定义样式
|
|
1182
|
+
|
|
1012
1183
|
if (item.labelClass) {
|
|
1013
1184
|
labelClass = item.labelClass.split(',').join(' ');
|
|
1014
1185
|
}
|
|
1186
|
+
|
|
1015
1187
|
if (!gc_label) {
|
|
1016
1188
|
gc_label = new t.MyLabel();
|
|
1017
1189
|
t.GM.setGraphic("".concat(item.id, "_vtxoMap_label"), gc_label);
|
|
1018
1190
|
}
|
|
1191
|
+
|
|
1019
1192
|
gc_label.setOptions({
|
|
1020
1193
|
labelClass: labelClass,
|
|
1021
1194
|
labelContent: cg.labelContent,
|
|
1195
|
+
|
|
1022
1196
|
/*
|
|
1023
1197
|
为和百度等地图相同的参数 加上g.markerContentY值
|
|
1024
1198
|
label是使用OverlayView手动实现,与marker没有关联的原因
|
|
@@ -1029,8 +1203,9 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1029
1203
|
}
|
|
1030
1204
|
});
|
|
1031
1205
|
gc.ishaveLabel = true;
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1206
|
+
} //点击事件
|
|
1207
|
+
|
|
1208
|
+
|
|
1034
1209
|
var mClick = gc.addListener('click', function (e) {
|
|
1035
1210
|
//避免鼠标在图元上 测距工具不起作用
|
|
1036
1211
|
if (t.rangingTool.isRanging) {
|
|
@@ -1038,12 +1213,12 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1038
1213
|
} else {
|
|
1039
1214
|
t.clickGraphic(item.id, e);
|
|
1040
1215
|
}
|
|
1041
|
-
});
|
|
1042
|
-
|
|
1216
|
+
}); //鼠标移入事件
|
|
1217
|
+
|
|
1043
1218
|
var mMouseover = gc.addListener('mouseover', function (e) {
|
|
1044
1219
|
t.mouseOverGraphic(item.id, e);
|
|
1045
|
-
});
|
|
1046
|
-
|
|
1220
|
+
}); //鼠标移出事件
|
|
1221
|
+
|
|
1047
1222
|
var mMouseout = gc.addListener('mouseout', function (e) {
|
|
1048
1223
|
t.mouseOutGraphic(item.id, e);
|
|
1049
1224
|
});
|
|
@@ -1058,20 +1233,24 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1058
1233
|
if (t.GM.getGraphicParam("".concat(item.id, "_omap_event")).click) {
|
|
1059
1234
|
t.GM.getGraphicParam("".concat(item.id, "_omap_event")).click.remove();
|
|
1060
1235
|
}
|
|
1236
|
+
|
|
1061
1237
|
if (t.GM.getGraphicParam("".concat(item.id, "_omap_event")).mouseover) {
|
|
1062
1238
|
t.GM.getGraphicParam("".concat(item.id, "_omap_event")).mouseover.remove();
|
|
1063
1239
|
}
|
|
1240
|
+
|
|
1064
1241
|
if (t.GM.getGraphicParam("".concat(item.id, "_omap_event")).mouseout) {
|
|
1065
1242
|
t.GM.getGraphicParam("".concat(item.id, "_omap_event")).mouseout.remove();
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
//存在 label点位 直接删除
|
|
1243
|
+
} //删除原点位
|
|
1244
|
+
|
|
1245
|
+
|
|
1246
|
+
gc.setMap(null); //存在 label点位 直接删除
|
|
1247
|
+
|
|
1070
1248
|
if (gc_label) {
|
|
1071
1249
|
gc_label.setMap(null);
|
|
1072
1250
|
t.GM.removeGraphic("".concat(item.id, "_vtxoMap_label"));
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1251
|
+
} //重新加载点位 (原有位置加载,配合moveTo方法使用)
|
|
1252
|
+
|
|
1253
|
+
|
|
1075
1254
|
gc = new t.MyLabel(t.state.gis, {
|
|
1076
1255
|
labelContent: item.markerContent,
|
|
1077
1256
|
labelOffset: {
|
|
@@ -1079,10 +1258,10 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1079
1258
|
y: cg.markerContentY
|
|
1080
1259
|
}
|
|
1081
1260
|
});
|
|
1082
|
-
gc.setPosition(oldPosition);
|
|
1083
|
-
|
|
1084
|
-
t.GM.setGraphic(item.id, gc);
|
|
1085
|
-
|
|
1261
|
+
gc.setPosition(oldPosition); //切换 图元对象缓存
|
|
1262
|
+
|
|
1263
|
+
t.GM.setGraphic(item.id, gc); //点击事件
|
|
1264
|
+
|
|
1086
1265
|
var _mClick = gc.addListener('click', function (e) {
|
|
1087
1266
|
//避免鼠标在图元上 测距工具不起作用
|
|
1088
1267
|
if (t.rangingTool.isRanging) {
|
|
@@ -1090,31 +1269,35 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1090
1269
|
} else {
|
|
1091
1270
|
t.clickGraphic(item.id, e);
|
|
1092
1271
|
}
|
|
1093
|
-
});
|
|
1094
|
-
|
|
1272
|
+
}); //鼠标移入事件
|
|
1273
|
+
|
|
1274
|
+
|
|
1095
1275
|
var _mMouseover = gc.addListener('mouseover', function (e) {
|
|
1096
1276
|
t.mouseOverGraphic(item.id, e);
|
|
1097
|
-
});
|
|
1098
|
-
|
|
1277
|
+
}); //鼠标移出事件
|
|
1278
|
+
|
|
1279
|
+
|
|
1099
1280
|
var _mMouseout = gc.addListener('mouseout', function (e) {
|
|
1100
1281
|
t.mouseOutGraphic(item.id, e);
|
|
1101
1282
|
});
|
|
1283
|
+
|
|
1102
1284
|
t.GM.setGraphicParam("".concat(item.id, "_omap_event"), {
|
|
1103
1285
|
click: _mClick,
|
|
1104
1286
|
mouseover: _mMouseover,
|
|
1105
1287
|
mouseout: _mMouseout
|
|
1106
1288
|
});
|
|
1107
1289
|
} else {
|
|
1108
|
-
var _iconUrl = '';
|
|
1109
|
-
|
|
1290
|
+
var _iconUrl = ''; // 360deg 不需要旋转
|
|
1291
|
+
|
|
1110
1292
|
if (parseFloat(cg.deg) % 360 != 0) {
|
|
1111
1293
|
_iconUrl = new _MapToolFunction.RotateIcon({
|
|
1112
1294
|
url: item.url || "".concat(_default2["default"].mapServerURL, "/images/defaultMarker.png"),
|
|
1113
1295
|
width: cg.width,
|
|
1114
1296
|
height: cg.height
|
|
1115
1297
|
});
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1298
|
+
} //前后点位类型都是marker-url
|
|
1299
|
+
|
|
1300
|
+
|
|
1118
1301
|
var _icon = {
|
|
1119
1302
|
anchor: {
|
|
1120
1303
|
x: -cg.markerContentX,
|
|
@@ -1129,20 +1312,24 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1129
1312
|
}
|
|
1130
1313
|
};
|
|
1131
1314
|
gc.setIcon(_icon);
|
|
1315
|
+
|
|
1132
1316
|
if (item.canShowLabel && cg.labelContent) {
|
|
1133
1317
|
//label默认样式
|
|
1134
|
-
var _labelClass = 'label-content';
|
|
1135
|
-
|
|
1318
|
+
var _labelClass = 'label-content'; //接受label自定义样式
|
|
1319
|
+
|
|
1136
1320
|
if (item.labelClass) {
|
|
1137
1321
|
_labelClass = item.labelClass.split(',').join(' ');
|
|
1138
1322
|
}
|
|
1323
|
+
|
|
1139
1324
|
if (!gc_label) {
|
|
1140
1325
|
gc_label = new t.MyLabel();
|
|
1141
1326
|
t.GM.setGraphic("".concat(item.id, "_vtxoMap_label"), gc_label);
|
|
1142
1327
|
}
|
|
1328
|
+
|
|
1143
1329
|
gc_label.setOptions({
|
|
1144
1330
|
labelClass: _labelClass,
|
|
1145
1331
|
labelContent: cg.labelContent,
|
|
1332
|
+
|
|
1146
1333
|
/*
|
|
1147
1334
|
为和百度等地图相同的参数 加上g.markerContentY值
|
|
1148
1335
|
label是使用OverlayView手动实现,与marker没有关联的原因
|
|
@@ -1155,6 +1342,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1155
1342
|
gc.ishaveLabel = true;
|
|
1156
1343
|
}
|
|
1157
1344
|
}
|
|
1345
|
+
|
|
1158
1346
|
if (!item.markerContent && cg.BAnimationType == 0) {
|
|
1159
1347
|
gc.setAnimation(google.maps.Animation.BOUNCE);
|
|
1160
1348
|
} else if (!item.markerContent && cg.BAnimationType == 1) {
|
|
@@ -1162,18 +1350,23 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1162
1350
|
}
|
|
1163
1351
|
/*moveTo*/
|
|
1164
1352
|
//动画效果会延迟执行经纬度的切换
|
|
1353
|
+
|
|
1354
|
+
|
|
1165
1355
|
if (cg.isAnimation) {
|
|
1166
1356
|
t.moveTo(item.id, [item.longitude, item.latitude], cg.animationDelay, cg.autoRotation, item.url, item.urlleft);
|
|
1167
1357
|
} else {
|
|
1168
1358
|
if (gc_label) {
|
|
1169
1359
|
gc_label.setPosition(position);
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1360
|
+
} //修改经纬度
|
|
1361
|
+
|
|
1362
|
+
|
|
1172
1363
|
gc.setPosition(position);
|
|
1173
1364
|
}
|
|
1365
|
+
|
|
1174
1366
|
if (cg.zIndex || cg.zIndex === 0) {
|
|
1175
1367
|
gc.setZIndex(cg.zIndex);
|
|
1176
1368
|
}
|
|
1369
|
+
|
|
1177
1370
|
t.GM.setGraphicParam(item.id, {
|
|
1178
1371
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1179
1372
|
other: item
|
|
@@ -1191,8 +1384,9 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1191
1384
|
}
|
|
1192
1385
|
});
|
|
1193
1386
|
t.moveAnimation();
|
|
1194
|
-
};
|
|
1195
|
-
|
|
1387
|
+
}; //内部 不需要旋转图标的处理方式
|
|
1388
|
+
|
|
1389
|
+
|
|
1196
1390
|
if (type == 'nodeg') {
|
|
1197
1391
|
upf();
|
|
1198
1392
|
} else {
|
|
@@ -1205,51 +1399,59 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1205
1399
|
t.cacheImg.appendChild(i);
|
|
1206
1400
|
t.cacheImgRecord[item.url] = true;
|
|
1207
1401
|
}
|
|
1402
|
+
|
|
1208
1403
|
if (item.urlleft && !t.cacheImgRecord[item.urlleft]) {
|
|
1209
1404
|
var _i = new Image();
|
|
1405
|
+
|
|
1210
1406
|
_i.src = item.urlleft;
|
|
1211
1407
|
t.cacheImg.appendChild(_i);
|
|
1212
1408
|
t.cacheImgRecord[item.urlleft] = true;
|
|
1213
1409
|
}
|
|
1214
|
-
});
|
|
1215
|
-
|
|
1410
|
+
}); // 定时等待 图片缓存,点位旋转功能需要
|
|
1411
|
+
|
|
1216
1412
|
t.upPsTimer = setTimeout(function () {
|
|
1217
1413
|
upf();
|
|
1218
1414
|
}, 200);
|
|
1219
1415
|
}
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1416
|
+
} //添加线
|
|
1417
|
+
|
|
1222
1418
|
}, {
|
|
1223
1419
|
key: "addLine",
|
|
1224
1420
|
value: function addLine(mapLines, type) {
|
|
1225
1421
|
var t = this;
|
|
1226
|
-
|
|
1227
|
-
//遍历添加线(图元)
|
|
1422
|
+
|
|
1423
|
+
var lsids = _toConsumableArray(t.state.lineIds); //遍历添加线(图元)
|
|
1424
|
+
|
|
1425
|
+
|
|
1228
1426
|
mapLines.map(function (item, index) {
|
|
1229
1427
|
//如果id重复,直接跳过不执行.
|
|
1230
1428
|
if (t.GM.isRepetition(item.id)) {
|
|
1231
1429
|
console.warn("\u591A\u6298\u7EBFid: ".concat(item.id, " \u91CD\u590D"));
|
|
1232
1430
|
return false;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1431
|
+
} //多折线点位数据不符合,直接跳过
|
|
1432
|
+
|
|
1433
|
+
|
|
1235
1434
|
if (!(item.paths && item.paths.length >= 2)) {
|
|
1236
1435
|
console.warn("\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF");
|
|
1237
1436
|
return false;
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1437
|
+
} //初始化默认参数
|
|
1438
|
+
|
|
1439
|
+
|
|
1240
1440
|
var cg = {
|
|
1241
1441
|
color: '#277ffa',
|
|
1242
1442
|
pellucidity: 0.9,
|
|
1243
1443
|
lineWidth: 5,
|
|
1244
1444
|
lineType: 'solid',
|
|
1245
1445
|
isHidden: false
|
|
1246
|
-
};
|
|
1247
|
-
|
|
1446
|
+
}; //合并参数
|
|
1447
|
+
|
|
1248
1448
|
if (item.config) {
|
|
1249
1449
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1450
|
+
} // 线样式
|
|
1451
|
+
|
|
1452
|
+
|
|
1252
1453
|
var icons = [];
|
|
1454
|
+
|
|
1253
1455
|
if (cg.lineType == 'dashed') {
|
|
1254
1456
|
var lineSymbol = {
|
|
1255
1457
|
path: 'M 0,-1 0,1',
|
|
@@ -1261,38 +1463,40 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1261
1463
|
offset: '0',
|
|
1262
1464
|
repeat: '20px'
|
|
1263
1465
|
}];
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1466
|
+
} //处理线的点数组
|
|
1467
|
+
|
|
1468
|
+
|
|
1266
1469
|
var linePath = item.paths.map(function (item, index) {
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1470
|
+
return new google.maps.LatLng({
|
|
1471
|
+
lng: item[0],
|
|
1472
|
+
lat: item[1]
|
|
1473
|
+
});
|
|
1474
|
+
}),
|
|
1475
|
+
//处理线的参数
|
|
1476
|
+
lineOption = {
|
|
1477
|
+
strokeColor: cg.color,
|
|
1478
|
+
// 线颜色
|
|
1479
|
+
strokeWeight: cg.lineWidth,
|
|
1480
|
+
// 线宽
|
|
1481
|
+
strokeOpacity: cg.lineType == 'dashed' ? 0 : cg.pellucidity,
|
|
1482
|
+
// 线透明度
|
|
1483
|
+
icons: icons
|
|
1484
|
+
}; //创建线对象
|
|
1485
|
+
|
|
1283
1486
|
var line = new google.maps.Polyline(_objectSpread(_objectSpread({}, lineOption), {}, {
|
|
1284
1487
|
path: linePath
|
|
1285
|
-
}));
|
|
1286
|
-
|
|
1488
|
+
})); //判断线显示和隐藏
|
|
1489
|
+
|
|
1287
1490
|
if (cg.isHidden) {
|
|
1288
1491
|
line.setVisible(false);
|
|
1289
1492
|
} else {
|
|
1290
1493
|
line.setVisible(true);
|
|
1291
1494
|
}
|
|
1292
|
-
|
|
1293
|
-
//添加线至地图
|
|
1294
|
-
|
|
1295
|
-
//点击事件
|
|
1495
|
+
|
|
1496
|
+
lsids.push(item.id); //添加线至地图
|
|
1497
|
+
|
|
1498
|
+
line.setMap(t.state.gis); //点击事件
|
|
1499
|
+
|
|
1296
1500
|
var mClick = line.addListener('click', function (e) {
|
|
1297
1501
|
//避免鼠标在图元上 测距工具不起作用
|
|
1298
1502
|
if (t.rangingTool.isRanging) {
|
|
@@ -1300,12 +1504,12 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1300
1504
|
} else {
|
|
1301
1505
|
t.clickGraphic(item.id, e);
|
|
1302
1506
|
}
|
|
1303
|
-
});
|
|
1304
|
-
|
|
1507
|
+
}); //鼠标移入事件
|
|
1508
|
+
|
|
1305
1509
|
var mMouseover = line.addListener('mouseover', function (e) {
|
|
1306
1510
|
t.mouseOverGraphic(item.id, e);
|
|
1307
|
-
});
|
|
1308
|
-
|
|
1511
|
+
}); //鼠标移出事件
|
|
1512
|
+
|
|
1309
1513
|
var mMouseout = line.addListener('mouseout', function (e) {
|
|
1310
1514
|
t.mouseOutGraphic(item.id, e);
|
|
1311
1515
|
});
|
|
@@ -1325,19 +1529,19 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1325
1529
|
mouseout: mMouseout
|
|
1326
1530
|
});
|
|
1327
1531
|
});
|
|
1532
|
+
|
|
1328
1533
|
if (type !== 'defined') {
|
|
1329
|
-
t.state.lineIds = lsids;
|
|
1330
|
-
// t.setState({
|
|
1534
|
+
t.state.lineIds = lsids; // t.setState({
|
|
1331
1535
|
// lineIds: lsids
|
|
1332
1536
|
// });
|
|
1333
1537
|
}
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1538
|
+
} //更新线
|
|
1539
|
+
|
|
1336
1540
|
}, {
|
|
1337
1541
|
key: "updateLine",
|
|
1338
1542
|
value: function updateLine(mapLines) {
|
|
1339
|
-
var t = this;
|
|
1340
|
-
|
|
1543
|
+
var t = this; //遍历添加线(图元)
|
|
1544
|
+
|
|
1341
1545
|
mapLines.map(function (item, index) {
|
|
1342
1546
|
//判断图元是否存在.
|
|
1343
1547
|
if (t.GM.isRepetition(item.id)) {
|
|
@@ -1350,8 +1554,9 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1350
1554
|
console.warn("\u66F4\u65B0\u7684\u591A\u6298\u7EBFid\u4E0D\u5B58\u5728!");
|
|
1351
1555
|
return false;
|
|
1352
1556
|
}
|
|
1353
|
-
|
|
1354
|
-
//初始化默认参数
|
|
1557
|
+
|
|
1558
|
+
var gc = t.GM.getGraphic(item.id); //初始化默认参数
|
|
1559
|
+
|
|
1355
1560
|
var cg = {
|
|
1356
1561
|
color: '#277ffa',
|
|
1357
1562
|
pellucidity: 0.9,
|
|
@@ -1359,13 +1564,15 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1359
1564
|
lineType: 'solid',
|
|
1360
1565
|
//'solid' 'dashed'
|
|
1361
1566
|
isHidden: false
|
|
1362
|
-
};
|
|
1363
|
-
|
|
1567
|
+
}; //合并参数
|
|
1568
|
+
|
|
1364
1569
|
if (item.config) {
|
|
1365
1570
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1571
|
+
} // 线样式
|
|
1572
|
+
|
|
1573
|
+
|
|
1368
1574
|
var icons = [];
|
|
1575
|
+
|
|
1369
1576
|
if (cg.lineType == 'dashed') {
|
|
1370
1577
|
var lineSymbol = {
|
|
1371
1578
|
path: 'M 0,-1 0,1',
|
|
@@ -1377,34 +1584,36 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1377
1584
|
offset: '0',
|
|
1378
1585
|
repeat: '20px'
|
|
1379
1586
|
}];
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1587
|
+
} //处理线的点数组
|
|
1588
|
+
|
|
1589
|
+
|
|
1382
1590
|
var linePath = item.paths.map(function (item, index) {
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
gc.setPath(linePath);
|
|
1400
|
-
|
|
1401
|
-
gc.setOptions(lineOption);
|
|
1402
|
-
|
|
1591
|
+
return new google.maps.LatLng({
|
|
1592
|
+
lng: item[0],
|
|
1593
|
+
lat: item[1]
|
|
1594
|
+
});
|
|
1595
|
+
}),
|
|
1596
|
+
//处理线的参数
|
|
1597
|
+
lineOption = {
|
|
1598
|
+
strokeColor: cg.color,
|
|
1599
|
+
// 线颜色
|
|
1600
|
+
strokeWeight: cg.lineWidth,
|
|
1601
|
+
// 线宽
|
|
1602
|
+
strokeOpacity: cg.lineType == 'dashed' ? 0 : cg.pellucidity,
|
|
1603
|
+
// 线透明度
|
|
1604
|
+
icons: icons
|
|
1605
|
+
}; //修改线点位数据
|
|
1606
|
+
|
|
1607
|
+
gc.setPath(linePath); //修改线配置
|
|
1608
|
+
|
|
1609
|
+
gc.setOptions(lineOption); //判断线显示和隐藏
|
|
1610
|
+
|
|
1403
1611
|
if (cg.isHidden) {
|
|
1404
1612
|
gc.setVisible(false);
|
|
1405
1613
|
} else {
|
|
1406
1614
|
gc.setVisible(true);
|
|
1407
1615
|
}
|
|
1616
|
+
|
|
1408
1617
|
t.GM.setGraphicParam(item.id, {
|
|
1409
1618
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1410
1619
|
paths: item.paths,
|
|
@@ -1417,60 +1626,66 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1417
1626
|
}
|
|
1418
1627
|
});
|
|
1419
1628
|
});
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1629
|
+
} //添加面
|
|
1630
|
+
|
|
1422
1631
|
}, {
|
|
1423
1632
|
key: "addPolygon",
|
|
1424
1633
|
value: function addPolygon(mapPolygons) {
|
|
1425
1634
|
var t = this;
|
|
1426
|
-
|
|
1427
|
-
//遍历添加面(图元)
|
|
1635
|
+
|
|
1636
|
+
var pgsids = _toConsumableArray(t.state.polygonIds); //遍历添加面(图元)
|
|
1637
|
+
|
|
1638
|
+
|
|
1428
1639
|
mapPolygons.map(function (item, index) {
|
|
1429
1640
|
//如果id重复,直接跳过不执行.
|
|
1430
1641
|
if (t.GM.isRepetition(item.id)) {
|
|
1431
1642
|
console.warn("\u591A\u8FB9\u5F62id: ".concat(item.id, " \u91CD\u590D"));
|
|
1432
1643
|
return false;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1644
|
+
} //多边形点位数据不符合,直接跳过
|
|
1645
|
+
|
|
1646
|
+
|
|
1435
1647
|
if (!(item.rings && item.rings.length >= 3)) {
|
|
1436
1648
|
console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
|
|
1437
1649
|
return false;
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1650
|
+
} //初始化参数
|
|
1651
|
+
|
|
1652
|
+
|
|
1440
1653
|
var cg = {
|
|
1441
1654
|
lineType: 'solid',
|
|
1442
1655
|
lineWidth: 5,
|
|
1443
1656
|
lineColor: '#277ffa',
|
|
1444
1657
|
lineOpacity: 1,
|
|
1445
1658
|
color: '#fff',
|
|
1446
|
-
pellucidity: 0.5
|
|
1447
|
-
|
|
1659
|
+
pellucidity: 0.5 // isHidden: false //后期需要再加
|
|
1660
|
+
|
|
1448
1661
|
};
|
|
1662
|
+
|
|
1449
1663
|
if (item.config) {
|
|
1450
1664
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1665
|
+
} //面的参数
|
|
1666
|
+
|
|
1667
|
+
|
|
1453
1668
|
var polygonOption = {
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
});
|
|
1669
|
+
strokeColor: cg.lineColor,
|
|
1670
|
+
strokeOpacity: cg.lineOpacity,
|
|
1671
|
+
strokeWeight: cg.lineWidth,
|
|
1672
|
+
strokeStyle: cg.lineType,
|
|
1673
|
+
fillColor: cg.color,
|
|
1674
|
+
fillOpacity: cg.pellucidity
|
|
1675
|
+
},
|
|
1676
|
+
polygonPath = item.rings.map(function (item, index) {
|
|
1677
|
+
return new google.maps.LatLng({
|
|
1678
|
+
lng: item[0],
|
|
1679
|
+
lat: item[1]
|
|
1466
1680
|
});
|
|
1467
|
-
//创建面对象
|
|
1681
|
+
}); //创建面对象
|
|
1682
|
+
|
|
1468
1683
|
var polygon = new google.maps.Polygon(_objectSpread(_objectSpread({}, polygonOption), {}, {
|
|
1469
1684
|
paths: polygonPath
|
|
1470
|
-
}));
|
|
1471
|
-
|
|
1472
|
-
polygon.setMap(t.state.gis);
|
|
1473
|
-
|
|
1685
|
+
})); //添加面至地图
|
|
1686
|
+
|
|
1687
|
+
polygon.setMap(t.state.gis); //点击事件
|
|
1688
|
+
|
|
1474
1689
|
var mClick = polygon.addListener('click', function (e) {
|
|
1475
1690
|
//避免鼠标在图元上 测距工具不起作用
|
|
1476
1691
|
if (t.rangingTool.isRanging) {
|
|
@@ -1478,18 +1693,18 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1478
1693
|
} else {
|
|
1479
1694
|
t.clickGraphic(item.id, e);
|
|
1480
1695
|
}
|
|
1481
|
-
});
|
|
1482
|
-
|
|
1696
|
+
}); //鼠标移入事件
|
|
1697
|
+
|
|
1483
1698
|
var mMouseover = polygon.addListener('mouseover', function (e) {
|
|
1484
1699
|
t.mouseOverGraphic(item.id, e);
|
|
1485
|
-
});
|
|
1486
|
-
|
|
1700
|
+
}); //鼠标移出事件
|
|
1701
|
+
|
|
1487
1702
|
var mMouseout = polygon.addListener('mouseout', function (e) {
|
|
1488
1703
|
t.mouseOutGraphic(item.id, e);
|
|
1489
|
-
});
|
|
1490
|
-
|
|
1491
|
-
pgsids.push(item.id);
|
|
1492
|
-
|
|
1704
|
+
}); //缓存面id
|
|
1705
|
+
|
|
1706
|
+
pgsids.push(item.id); //缓存面图元对象和对于传入数据
|
|
1707
|
+
|
|
1493
1708
|
t.GM.setGraphic(item.id, polygon).setGraphicParam(item.id, {
|
|
1494
1709
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1495
1710
|
rings: item.rings,
|
|
@@ -1506,12 +1721,11 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1506
1721
|
mouseout: mMouseout
|
|
1507
1722
|
});
|
|
1508
1723
|
});
|
|
1509
|
-
t.state.polygonIds = pgsids;
|
|
1510
|
-
// t.setState({
|
|
1724
|
+
t.state.polygonIds = pgsids; // t.setState({
|
|
1511
1725
|
// polygonIds: pgsids
|
|
1512
1726
|
// });
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1727
|
+
} //更新面
|
|
1728
|
+
|
|
1515
1729
|
}, {
|
|
1516
1730
|
key: "updatePolygon",
|
|
1517
1731
|
value: function updatePolygon(mapPolygons) {
|
|
@@ -1523,40 +1737,43 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1523
1737
|
if (!(item.rings && item.rings.length >= 3)) {
|
|
1524
1738
|
console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
|
|
1525
1739
|
return false;
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
//初始化参数
|
|
1740
|
+
} //获取原有的图元
|
|
1741
|
+
|
|
1742
|
+
|
|
1743
|
+
var gc = t.GM.getGraphic(item.id); //初始化参数
|
|
1744
|
+
|
|
1530
1745
|
var cg = {
|
|
1531
1746
|
lineType: 'solid',
|
|
1532
1747
|
lineWidth: 5,
|
|
1533
1748
|
lineColor: '#277ffa',
|
|
1534
1749
|
lineOpacity: 1,
|
|
1535
1750
|
color: '#fff',
|
|
1536
|
-
pellucidity: 0.5
|
|
1537
|
-
|
|
1751
|
+
pellucidity: 0.5 // isHidden: false //后期需要再加
|
|
1752
|
+
|
|
1538
1753
|
};
|
|
1754
|
+
|
|
1539
1755
|
if (item.config) {
|
|
1540
1756
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1757
|
+
} //面的参数
|
|
1758
|
+
|
|
1759
|
+
|
|
1543
1760
|
var polygonOption = {
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
});
|
|
1761
|
+
strokeColor: cg.lineColor,
|
|
1762
|
+
strokeOpacity: cg.lineOpacity,
|
|
1763
|
+
strokeWeight: cg.lineWidth,
|
|
1764
|
+
strokeStyle: cg.lineType,
|
|
1765
|
+
fillColor: cg.color,
|
|
1766
|
+
fillOpacity: cg.pellucidity
|
|
1767
|
+
},
|
|
1768
|
+
polygonPath = item.rings.map(function (item, index) {
|
|
1769
|
+
return new google.maps.LatLng({
|
|
1770
|
+
lng: item[0],
|
|
1771
|
+
lat: item[1]
|
|
1556
1772
|
});
|
|
1557
|
-
//更新经纬度
|
|
1558
|
-
|
|
1559
|
-
//更新 多边形 参数
|
|
1773
|
+
}); //更新经纬度
|
|
1774
|
+
|
|
1775
|
+
gc.setPath(polygonPath); //更新 多边形 参数
|
|
1776
|
+
|
|
1560
1777
|
gc.setOptions(polygonOption);
|
|
1561
1778
|
t.GM.setGraphicParam(item.id, {
|
|
1562
1779
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -1574,57 +1791,63 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1574
1791
|
return false;
|
|
1575
1792
|
}
|
|
1576
1793
|
});
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1794
|
+
} //添加圆 circle
|
|
1795
|
+
|
|
1579
1796
|
}, {
|
|
1580
1797
|
key: "addCircle",
|
|
1581
1798
|
value: function addCircle(mapCircles) {
|
|
1582
1799
|
var t = this;
|
|
1800
|
+
|
|
1583
1801
|
var ccsids = _toConsumableArray(t.state.circleIds);
|
|
1802
|
+
|
|
1584
1803
|
mapCircles.map(function (item, index) {
|
|
1585
1804
|
//如果id重复,直接跳过不执行.
|
|
1586
1805
|
if (t.GM.isRepetition(item.id)) {
|
|
1587
1806
|
console.warn("\u5706id: ".concat(item.id, " \u91CD\u590D"));
|
|
1588
1807
|
return false;
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1808
|
+
} //圆 点位数据不符合,直接跳过
|
|
1809
|
+
|
|
1810
|
+
|
|
1591
1811
|
if (!item.longitude || !item.latitude) {
|
|
1592
1812
|
console.warn("\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
|
|
1593
1813
|
return false;
|
|
1594
1814
|
}
|
|
1815
|
+
|
|
1595
1816
|
var cg = {
|
|
1596
1817
|
lineType: 'solid',
|
|
1597
1818
|
lineWidth: 5,
|
|
1598
1819
|
lineColor: '#277ffa',
|
|
1599
1820
|
lineOpacity: 1,
|
|
1600
1821
|
color: '#fff',
|
|
1601
|
-
pellucidity: 0.5
|
|
1602
|
-
|
|
1822
|
+
pellucidity: 0.5 // isHidden: false //后期需要在加
|
|
1823
|
+
|
|
1603
1824
|
};
|
|
1825
|
+
|
|
1604
1826
|
if (item.config) {
|
|
1605
1827
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1828
|
+
} //初始化配置数据
|
|
1829
|
+
|
|
1830
|
+
|
|
1608
1831
|
var circleOption = {
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1832
|
+
strokeColor: cg.lineColor,
|
|
1833
|
+
strokeOpacity: cg.lineOpacity,
|
|
1834
|
+
strokeWeight: cg.lineWidth,
|
|
1835
|
+
strokeStyle: cg.lineType,
|
|
1836
|
+
fillColor: cg.color,
|
|
1837
|
+
fillOpacity: cg.pellucidity
|
|
1838
|
+
},
|
|
1839
|
+
centerPoint = new google.maps.LatLng({
|
|
1840
|
+
lng: item.longitude,
|
|
1841
|
+
lat: item.latitude
|
|
1842
|
+
}); //创建圆图元实例
|
|
1843
|
+
|
|
1621
1844
|
var circle = new google.maps.Circle(_objectSpread(_objectSpread({}, circleOption), {}, {
|
|
1622
1845
|
radius: item.radius,
|
|
1623
1846
|
center: centerPoint
|
|
1624
|
-
}));
|
|
1625
|
-
|
|
1626
|
-
circle.setMap(t.state.gis);
|
|
1627
|
-
|
|
1847
|
+
})); //添加圆至地图
|
|
1848
|
+
|
|
1849
|
+
circle.setMap(t.state.gis); //点击事件
|
|
1850
|
+
|
|
1628
1851
|
var mClick = circle.addListener('click', function (e) {
|
|
1629
1852
|
//避免鼠标在图元上 测距工具不起作用
|
|
1630
1853
|
if (t.rangingTool.isRanging) {
|
|
@@ -1632,17 +1855,17 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1632
1855
|
} else {
|
|
1633
1856
|
t.clickGraphic(item.id, e);
|
|
1634
1857
|
}
|
|
1635
|
-
});
|
|
1636
|
-
|
|
1858
|
+
}); //鼠标移入事件
|
|
1859
|
+
|
|
1637
1860
|
var mMouseover = circle.addListener('mouseover', function (e) {
|
|
1638
1861
|
t.mouseOverGraphic(item.id, e);
|
|
1639
|
-
});
|
|
1640
|
-
|
|
1862
|
+
}); //鼠标移出事件
|
|
1863
|
+
|
|
1641
1864
|
var mMouseout = circle.addListener('mouseout', function (e) {
|
|
1642
1865
|
t.mouseOutGraphic(item.id, e);
|
|
1643
1866
|
});
|
|
1644
|
-
ccsids.push(item.id);
|
|
1645
|
-
|
|
1867
|
+
ccsids.push(item.id); //缓存数据
|
|
1868
|
+
|
|
1646
1869
|
t.GM.setGraphic(item.id, circle).setGraphicParam(item.id, {
|
|
1647
1870
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1648
1871
|
other: item
|
|
@@ -1660,12 +1883,11 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1660
1883
|
mouseout: mMouseout
|
|
1661
1884
|
});
|
|
1662
1885
|
});
|
|
1663
|
-
t.state.circleIds = ccsids;
|
|
1664
|
-
// t.setState({
|
|
1886
|
+
t.state.circleIds = ccsids; // t.setState({
|
|
1665
1887
|
// circleIds: ccsids
|
|
1666
1888
|
// });
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1889
|
+
} //更新圆
|
|
1890
|
+
|
|
1669
1891
|
}, {
|
|
1670
1892
|
key: "updateCircle",
|
|
1671
1893
|
value: function updateCircle(mapCircles) {
|
|
@@ -1677,42 +1899,45 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1677
1899
|
if (!item.longitude || !item.latitude) {
|
|
1678
1900
|
console.warn("\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
|
|
1679
1901
|
return false;
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
//获取原有的面属性,转换key值
|
|
1902
|
+
} //获取原有的图元
|
|
1903
|
+
|
|
1904
|
+
|
|
1905
|
+
var gc = t.GM.getGraphic(item.id); //获取原有的面属性,转换key值
|
|
1906
|
+
|
|
1684
1907
|
var cg = {
|
|
1685
1908
|
lineType: 'solid',
|
|
1686
1909
|
lineWidth: 5,
|
|
1687
1910
|
lineColor: '#277ffa',
|
|
1688
1911
|
lineOpacity: 1,
|
|
1689
1912
|
color: '#fff',
|
|
1690
|
-
pellucidity: 0.5
|
|
1691
|
-
|
|
1913
|
+
pellucidity: 0.5 // isHidden: false //后期需要在加
|
|
1914
|
+
|
|
1692
1915
|
};
|
|
1916
|
+
|
|
1693
1917
|
if (item.config) {
|
|
1694
1918
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1919
|
+
} //初始化配置数据
|
|
1920
|
+
|
|
1921
|
+
|
|
1697
1922
|
var circleOption = {
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
gc.setCenter(centerPoint);
|
|
1711
|
-
|
|
1712
|
-
gc.setRadius(item.radius);
|
|
1713
|
-
|
|
1714
|
-
gc.setOptions(circleOption);
|
|
1715
|
-
|
|
1923
|
+
strokeColor: cg.lineColor,
|
|
1924
|
+
strokeOpacity: cg.lineOpacity,
|
|
1925
|
+
strokeWeight: cg.lineWidth,
|
|
1926
|
+
strokeStyle: cg.lineType,
|
|
1927
|
+
fillColor: cg.color,
|
|
1928
|
+
fillOpacity: cg.pellucidity
|
|
1929
|
+
},
|
|
1930
|
+
centerPoint = new google.maps.LatLng({
|
|
1931
|
+
lng: item.longitude,
|
|
1932
|
+
lat: item.latitude
|
|
1933
|
+
}); //修改中心点
|
|
1934
|
+
|
|
1935
|
+
gc.setCenter(centerPoint); //修改半径
|
|
1936
|
+
|
|
1937
|
+
gc.setRadius(item.radius); //修改圆 参数
|
|
1938
|
+
|
|
1939
|
+
gc.setOptions(circleOption); //缓存图元的数据,便于后期操作
|
|
1940
|
+
|
|
1716
1941
|
t.GM.setGraphicParam(item.id, {
|
|
1717
1942
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1718
1943
|
other: item
|
|
@@ -1730,8 +1955,8 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1730
1955
|
return false;
|
|
1731
1956
|
}
|
|
1732
1957
|
});
|
|
1733
|
-
}
|
|
1734
|
-
|
|
1958
|
+
} //热力图
|
|
1959
|
+
|
|
1735
1960
|
}, {
|
|
1736
1961
|
key: "heatMapOverlay",
|
|
1737
1962
|
value: function heatMapOverlay() {
|
|
@@ -1743,36 +1968,43 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1743
1968
|
visible: true,
|
|
1744
1969
|
opacity: 0.7
|
|
1745
1970
|
};
|
|
1971
|
+
|
|
1746
1972
|
if (d.config) {
|
|
1747
1973
|
cg = _objectSpread(_objectSpread({}, cg), d.config);
|
|
1748
1974
|
}
|
|
1975
|
+
|
|
1749
1976
|
if (!t.heatmap) {
|
|
1750
1977
|
t.heatmap = new google.maps.visualization.HeatmapLayer({
|
|
1751
1978
|
map: t.state.gis
|
|
1752
1979
|
});
|
|
1753
1980
|
}
|
|
1981
|
+
|
|
1754
1982
|
var option = {
|
|
1755
1983
|
radius: cg.radius,
|
|
1756
1984
|
//百度是1-100,高德是0-1
|
|
1757
|
-
opacity: cg.visible ? cg.opacity : 0
|
|
1758
|
-
|
|
1985
|
+
opacity: cg.visible ? cg.opacity : 0 // maxIntensity: cg.max
|
|
1986
|
+
|
|
1759
1987
|
};
|
|
1988
|
+
|
|
1760
1989
|
if (cg.gradient) {
|
|
1761
|
-
option.gradient = ['rgba(102,255, 0,0)'];
|
|
1762
|
-
|
|
1990
|
+
option.gradient = ['rgba(102,255, 0,0)']; //将gradient排序,与其他地图的热力图数据一致
|
|
1991
|
+
|
|
1763
1992
|
var sortArray = [];
|
|
1993
|
+
|
|
1764
1994
|
for (var i in cg.gradient) {
|
|
1765
1995
|
sortArray.push({
|
|
1766
1996
|
key: i,
|
|
1767
1997
|
value: cg.gradient[i]
|
|
1768
1998
|
});
|
|
1769
1999
|
}
|
|
2000
|
+
|
|
1770
2001
|
option.gradient = [].concat(_toConsumableArray(option.gradient), _toConsumableArray(sortArray.sort(function (a, b) {
|
|
1771
2002
|
return a.key > b.key;
|
|
1772
2003
|
}).map(function (item) {
|
|
1773
2004
|
return item.value;
|
|
1774
2005
|
})));
|
|
1775
2006
|
}
|
|
2007
|
+
|
|
1776
2008
|
t.heatmap.setOptions(option);
|
|
1777
2009
|
t.heatmap.setData((d.data || []).map(function (item, index) {
|
|
1778
2010
|
return new google.maps.LatLng({
|
|
@@ -1780,16 +2012,17 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1780
2012
|
lat: item.lat
|
|
1781
2013
|
});
|
|
1782
2014
|
}));
|
|
1783
|
-
}
|
|
1784
|
-
|
|
2015
|
+
} //添加海量点
|
|
2016
|
+
|
|
1785
2017
|
}, {
|
|
1786
2018
|
key: "addPointCollection",
|
|
1787
2019
|
value: function addPointCollection() {
|
|
1788
2020
|
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1789
|
-
var t = this;
|
|
1790
|
-
|
|
2021
|
+
var t = this; //处理海量点
|
|
2022
|
+
|
|
1791
2023
|
var panes = t.canvasProjectionOverlay.getPanes(),
|
|
1792
|
-
|
|
2024
|
+
ftp = t.canvasProjectionOverlay.getProjection();
|
|
2025
|
+
|
|
1793
2026
|
if (panes) {
|
|
1794
2027
|
if (!t.pointCollectionId) {
|
|
1795
2028
|
t.pointCollectionId = "".concat(t.props.mapId, "_vtx_gmap_html_pointCollection");
|
|
@@ -1800,6 +2033,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1800
2033
|
divpc.id = t.pointCollectionId;
|
|
1801
2034
|
panes.markerLayer.appendChild(divpc);
|
|
1802
2035
|
}
|
|
2036
|
+
|
|
1803
2037
|
data.map(function (item, index) {
|
|
1804
2038
|
var d = item || {};
|
|
1805
2039
|
var points = (d.points || []).map(function (d, i) {
|
|
@@ -1826,18 +2060,20 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1826
2060
|
if (t.addpointCollectionTimer) {
|
|
1827
2061
|
clearTimeout(t.addpointCollectionTimer);
|
|
1828
2062
|
}
|
|
2063
|
+
|
|
1829
2064
|
t.addpointCollectionTimer = setTimeout(function () {
|
|
1830
2065
|
t.addPointCollection(data);
|
|
1831
2066
|
}, 50);
|
|
1832
2067
|
}
|
|
1833
|
-
}
|
|
1834
|
-
|
|
2068
|
+
} //更新海量点
|
|
2069
|
+
|
|
1835
2070
|
}, {
|
|
1836
2071
|
key: "updatePointCollection",
|
|
1837
2072
|
value: function updatePointCollection() {
|
|
1838
2073
|
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1839
2074
|
var t = this;
|
|
1840
2075
|
var ftp = t.canvasProjectionOverlay.getProjection();
|
|
2076
|
+
|
|
1841
2077
|
if (ftp) {
|
|
1842
2078
|
data.map(function (ds, ind) {
|
|
1843
2079
|
t.morepoints.map(function (item, index) {
|
|
@@ -1862,12 +2098,13 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1862
2098
|
if (t.updatePointCollectionTimer) {
|
|
1863
2099
|
clearTimeout(t.updatePointCollectionTimer);
|
|
1864
2100
|
}
|
|
2101
|
+
|
|
1865
2102
|
t.updatePointCollectionTimer = setTimeout(function () {
|
|
1866
2103
|
t.addPointCollection(data);
|
|
1867
2104
|
}, 50);
|
|
1868
2105
|
}
|
|
1869
|
-
}
|
|
1870
|
-
|
|
2106
|
+
} //删除海量点
|
|
2107
|
+
|
|
1871
2108
|
}, {
|
|
1872
2109
|
key: "clearPointCollection",
|
|
1873
2110
|
value: function clearPointCollection() {
|
|
@@ -1880,8 +2117,8 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1880
2117
|
}
|
|
1881
2118
|
});
|
|
1882
2119
|
});
|
|
1883
|
-
}
|
|
1884
|
-
|
|
2120
|
+
} //删除全部海量点
|
|
2121
|
+
|
|
1885
2122
|
}, {
|
|
1886
2123
|
key: "clearAllPointCollection",
|
|
1887
2124
|
value: function clearAllPointCollection() {
|
|
@@ -1889,115 +2126,139 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
1889
2126
|
t.morepoints.map(function (item, index) {
|
|
1890
2127
|
item.value.clear();
|
|
1891
2128
|
});
|
|
1892
|
-
}
|
|
1893
|
-
|
|
2129
|
+
} //删除图元
|
|
2130
|
+
|
|
1894
2131
|
}, {
|
|
1895
2132
|
key: "removeGraphic",
|
|
1896
2133
|
value: function removeGraphic(id, type) {
|
|
1897
2134
|
var t = this;
|
|
1898
2135
|
var graphic = t.GM.getGraphic(id),
|
|
1899
|
-
|
|
1900
|
-
|
|
2136
|
+
gc_label = t.GM.getGraphic("".concat(id, "_vtxoMap_label")); //删除点聚合效果
|
|
2137
|
+
|
|
1901
2138
|
if (t.clusterIdList.indexOf(id) > -1) {
|
|
1902
2139
|
t.removeCluster(id);
|
|
1903
2140
|
}
|
|
2141
|
+
|
|
1904
2142
|
if (graphic) {
|
|
1905
2143
|
//清除地图中图元
|
|
1906
|
-
graphic.setMap(null);
|
|
1907
|
-
|
|
2144
|
+
graphic.setMap(null); //清除对应id的图元数据缓存
|
|
2145
|
+
|
|
1908
2146
|
t.GM.removeGraphic(id);
|
|
1909
2147
|
} else {
|
|
1910
2148
|
return false;
|
|
1911
|
-
}
|
|
1912
|
-
|
|
2149
|
+
} //删除点位label
|
|
2150
|
+
|
|
2151
|
+
|
|
1913
2152
|
if (gc_label) {
|
|
1914
2153
|
gc_label.setMap(null);
|
|
1915
2154
|
t.GM.removeGraphic("".concat(id, "_vtxoMap_label"));
|
|
1916
2155
|
}
|
|
2156
|
+
|
|
1917
2157
|
for (var i = 0; i < t.movePoints.length; i++) {
|
|
1918
2158
|
if (t.movePoints[i].id == id) {
|
|
1919
2159
|
t.movePoints.splice(i, 1);
|
|
1920
2160
|
continue;
|
|
1921
2161
|
}
|
|
1922
2162
|
}
|
|
2163
|
+
|
|
1923
2164
|
var ids = [];
|
|
2165
|
+
|
|
1924
2166
|
switch (type) {
|
|
1925
2167
|
case 'point':
|
|
1926
2168
|
ids = t.state.pointIds;
|
|
1927
2169
|
break;
|
|
2170
|
+
|
|
1928
2171
|
case 'line':
|
|
1929
2172
|
ids = t.state.lineIds;
|
|
1930
2173
|
break;
|
|
2174
|
+
|
|
1931
2175
|
case 'polygon':
|
|
1932
2176
|
ids = t.state.polygonIds;
|
|
1933
2177
|
break;
|
|
2178
|
+
|
|
1934
2179
|
case 'circle':
|
|
1935
2180
|
ids = t.state.circleIds;
|
|
1936
2181
|
break;
|
|
2182
|
+
|
|
1937
2183
|
case 'draw':
|
|
1938
2184
|
if (t.state.drawIds.point.indexOf(id) > -1) {
|
|
1939
2185
|
t.state.drawIds.point.splice(t.state.drawIds.point.indexOf(id), 1);
|
|
1940
2186
|
}
|
|
2187
|
+
|
|
1941
2188
|
if (t.state.drawIds.polyline.indexOf(id) > -1) {
|
|
1942
2189
|
t.state.drawIds.polyline.splice(t.state.drawIds.polyline.indexOf(id), 1);
|
|
1943
2190
|
}
|
|
2191
|
+
|
|
1944
2192
|
if (t.state.drawIds.polygon.indexOf(id) > -1) {
|
|
1945
2193
|
t.state.drawIds.polygon.splice(t.state.drawIds.polygon.indexOf(id), 1);
|
|
1946
2194
|
}
|
|
2195
|
+
|
|
1947
2196
|
if (t.state.drawIds.circle.indexOf(id) > -1) {
|
|
1948
2197
|
t.state.drawIds.circle.splice(t.state.drawIds.circle.indexOf(id), 1);
|
|
1949
2198
|
}
|
|
2199
|
+
|
|
1950
2200
|
if (t.state.drawIds.rectangle.indexOf(id) > -1) {
|
|
1951
2201
|
t.state.drawIds.rectangle.splice(t.state.drawIds.rectangle.indexOf(id), 1);
|
|
1952
2202
|
}
|
|
2203
|
+
|
|
1953
2204
|
break;
|
|
2205
|
+
|
|
1954
2206
|
default:
|
|
1955
2207
|
if (t.state.pointIds.indexOf(id) > -1) {
|
|
1956
2208
|
t.state.pointIds.splice(t.state.pointIds.indexOf(id), 1);
|
|
1957
2209
|
}
|
|
2210
|
+
|
|
1958
2211
|
if (t.state.lineIds.indexOf(id) > -1) {
|
|
1959
2212
|
t.state.lineIds.splice(t.state.lineIds.indexOf(id), 1);
|
|
1960
2213
|
}
|
|
2214
|
+
|
|
1961
2215
|
if (t.state.polygonIds.indexOf(id) > -1) {
|
|
1962
2216
|
t.state.polygonIds.splice(t.state.polygonIds.indexOf(id), 1);
|
|
1963
2217
|
}
|
|
2218
|
+
|
|
1964
2219
|
if (t.state.circleIds.indexOf(id) > -1) {
|
|
1965
2220
|
t.state.circleIds.splice(t.state.circleIds.indexOf(id), 1);
|
|
1966
2221
|
}
|
|
2222
|
+
|
|
1967
2223
|
break;
|
|
1968
2224
|
}
|
|
2225
|
+
|
|
1969
2226
|
if (id == t.state.editId) {
|
|
1970
2227
|
t.state.editId = '';
|
|
1971
2228
|
}
|
|
2229
|
+
|
|
1972
2230
|
if (ids.indexOf(id) != -1) {
|
|
1973
2231
|
ids.splice(ids.indexOf(id), 1);
|
|
1974
2232
|
}
|
|
1975
2233
|
}
|
|
1976
2234
|
/*根据图元id,使图元变成可编辑状态*/
|
|
2235
|
+
|
|
1977
2236
|
}, {
|
|
1978
2237
|
key: "doEdit",
|
|
1979
2238
|
value: function doEdit(id) {
|
|
1980
|
-
var t = this;
|
|
1981
|
-
|
|
2239
|
+
var t = this; //获取编辑点的图元和参数
|
|
2240
|
+
|
|
1982
2241
|
var graphic = t.GM.getGraphic(id),
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
if (!graphic) return false;
|
|
1986
|
-
|
|
2242
|
+
gLabel = t.GM.getGraphic("".concat(id, "_vtxoMap_label")),
|
|
2243
|
+
gtp = t.GM.getGraphicParam(id);
|
|
2244
|
+
if (!graphic) return false; //关闭先前编辑的图元
|
|
2245
|
+
|
|
1987
2246
|
if (!!t.state.editId) {
|
|
1988
2247
|
t.endEdit();
|
|
1989
2248
|
}
|
|
2249
|
+
|
|
1990
2250
|
if (!t.editGraphicChange) {
|
|
1991
2251
|
//编辑变动后
|
|
1992
2252
|
t.editGraphicChange = function (e) {
|
|
1993
2253
|
var id = t.state.editId,
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2254
|
+
param = t.getGraphic(id),
|
|
2255
|
+
obj = {
|
|
2256
|
+
param: param,
|
|
2257
|
+
e: e,
|
|
2258
|
+
id: id,
|
|
2259
|
+
geometry: param.geometry
|
|
2260
|
+
};
|
|
2261
|
+
|
|
2001
2262
|
if (param.geometry.type == 'polygon') {
|
|
2002
2263
|
if (google.maps.geometry && google.maps.geometry.spherical) {
|
|
2003
2264
|
obj.area = google.maps.geometry.spherical.computeArea(param.mapLayer.getPath().getArray());
|
|
@@ -2005,14 +2266,18 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2005
2266
|
obj.area = 0;
|
|
2006
2267
|
}
|
|
2007
2268
|
}
|
|
2269
|
+
|
|
2008
2270
|
if (param.geometry.type == 'polyline') {
|
|
2009
2271
|
obj.distance = t.calculateDistance(param.geometry.paths);
|
|
2010
2272
|
}
|
|
2273
|
+
|
|
2011
2274
|
if (param.geometry.type == 'circle') {
|
|
2012
2275
|
obj.area = Math.pow(param.geometry.radius, 2) * Math.PI;
|
|
2276
|
+
|
|
2013
2277
|
if (t.editTimeout) {
|
|
2014
2278
|
clearTimeout(t.editTimeout);
|
|
2015
2279
|
}
|
|
2280
|
+
|
|
2016
2281
|
t.editTimeout = setTimeout(function () {
|
|
2017
2282
|
t.setState({
|
|
2018
2283
|
editGraphic: obj
|
|
@@ -2029,46 +2294,53 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2029
2294
|
}
|
|
2030
2295
|
};
|
|
2031
2296
|
}
|
|
2297
|
+
|
|
2032
2298
|
switch (gtp.geometryType) {
|
|
2033
2299
|
case 'point':
|
|
2034
2300
|
graphic.setDraggable(true);
|
|
2035
|
-
t.editEvent['dragend'] = graphic.addListener("dragend", t.editGraphicChange);
|
|
2036
|
-
|
|
2301
|
+
t.editEvent['dragend'] = graphic.addListener("dragend", t.editGraphicChange); //判断是否是 markerContent 再判断是否有label
|
|
2302
|
+
|
|
2037
2303
|
if (!gtp.attributes.markerContent && gLabel) {
|
|
2038
2304
|
//label事件对象 便于删除
|
|
2039
2305
|
t.editPointLabel = graphic.addListener("drag", function (event) {
|
|
2040
2306
|
gLabel.setPosition(event.latLng);
|
|
2041
2307
|
});
|
|
2042
2308
|
}
|
|
2309
|
+
|
|
2043
2310
|
break;
|
|
2311
|
+
|
|
2044
2312
|
case 'polyline':
|
|
2045
2313
|
case 'polygon':
|
|
2046
2314
|
case 'rectangle':
|
|
2047
2315
|
graphic.setEditable(true);
|
|
2048
2316
|
t.editEvent['mouseup'] = graphic.addListener("mouseup", t.editGraphicChange);
|
|
2049
2317
|
break;
|
|
2318
|
+
|
|
2050
2319
|
case 'circle':
|
|
2051
2320
|
graphic.setEditable(true);
|
|
2052
2321
|
t.editEvent['center_changed'] = graphic.addListener("center_changed", t.editGraphicChange);
|
|
2053
2322
|
t.editEvent['radius_changed'] = graphic.addListener("radius_changed", t.editGraphicChange);
|
|
2054
2323
|
break;
|
|
2055
2324
|
}
|
|
2325
|
+
|
|
2056
2326
|
t.setState({
|
|
2057
2327
|
editId: id
|
|
2058
2328
|
});
|
|
2059
|
-
}
|
|
2060
|
-
|
|
2329
|
+
} //关闭编辑
|
|
2330
|
+
|
|
2061
2331
|
}, {
|
|
2062
2332
|
key: "endEdit",
|
|
2063
2333
|
value: function endEdit() {
|
|
2064
|
-
var t = this;
|
|
2065
|
-
|
|
2334
|
+
var t = this; //获取编辑点的图元和参数
|
|
2335
|
+
|
|
2066
2336
|
var graphic = t.GM.getGraphic(t.state.editId);
|
|
2067
2337
|
var gtp = t.GM.getGraphicParam(t.state.editId);
|
|
2068
2338
|
if (!graphic) return false;
|
|
2339
|
+
|
|
2069
2340
|
switch (gtp.geometryType) {
|
|
2070
2341
|
case 'point':
|
|
2071
2342
|
graphic.setDraggable(false);
|
|
2343
|
+
|
|
2072
2344
|
if (graphic.removeListener) {
|
|
2073
2345
|
graphic.removeListener("dragend", t.editGraphicChange);
|
|
2074
2346
|
} else {
|
|
@@ -2077,27 +2349,34 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2077
2349
|
t.editEvent[i].remove();
|
|
2078
2350
|
}
|
|
2079
2351
|
}
|
|
2352
|
+
|
|
2080
2353
|
if (t.editPointLabel) {
|
|
2081
2354
|
t.editPointLabel.remove();
|
|
2082
2355
|
t.editPointLabel = null;
|
|
2083
2356
|
}
|
|
2084
2357
|
}
|
|
2358
|
+
|
|
2085
2359
|
break;
|
|
2360
|
+
|
|
2086
2361
|
case 'polyline':
|
|
2087
2362
|
case 'polygon':
|
|
2088
2363
|
case 'rectangle':
|
|
2089
2364
|
case 'circle':
|
|
2090
2365
|
graphic.setEditable(false);
|
|
2366
|
+
|
|
2091
2367
|
for (var _i2 in t.editEvent) {
|
|
2092
2368
|
if (t.editEvent[_i2]) {
|
|
2093
2369
|
t.editEvent[_i2].remove();
|
|
2094
2370
|
}
|
|
2095
2371
|
}
|
|
2372
|
+
|
|
2096
2373
|
break;
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2374
|
+
} //事件缓存制空,避免异常
|
|
2375
|
+
|
|
2376
|
+
|
|
2099
2377
|
t.editEvent = {};
|
|
2100
2378
|
var editGraphic = t.state.editGraphic;
|
|
2379
|
+
|
|
2101
2380
|
if (editGraphic) {
|
|
2102
2381
|
t.setState({
|
|
2103
2382
|
editId: '',
|
|
@@ -2106,29 +2385,33 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2106
2385
|
t.props.editGraphicChange(editGraphic);
|
|
2107
2386
|
});
|
|
2108
2387
|
}
|
|
2109
|
-
}
|
|
2110
|
-
|
|
2388
|
+
} //绘制图元
|
|
2389
|
+
|
|
2111
2390
|
}, {
|
|
2112
2391
|
key: "draw",
|
|
2113
2392
|
value: function draw(obj) {
|
|
2114
2393
|
var t = this,
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
t._drawmanager.setDrawingMode(null);
|
|
2118
|
-
|
|
2394
|
+
drawParam = {}; //先关闭(防止连点)
|
|
2395
|
+
|
|
2396
|
+
t._drawmanager.setDrawingMode(null); //初始化参数
|
|
2397
|
+
|
|
2398
|
+
|
|
2119
2399
|
drawParam.geometryType = obj.geometryType || 'point';
|
|
2120
2400
|
drawParam.parameter = obj.parameter ? _objectSpread({}, obj.parameter) : {};
|
|
2121
2401
|
drawParam.data = obj.data ? _objectSpread({}, obj.data) : {};
|
|
2122
|
-
drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime());
|
|
2123
|
-
|
|
2402
|
+
drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime()); //判断id是否存在
|
|
2403
|
+
|
|
2124
2404
|
var len = t.state.drawIds[drawParam.geometryType].indexOf(drawParam.data.id);
|
|
2405
|
+
|
|
2125
2406
|
if (len > -1) {
|
|
2126
2407
|
//如果id存在 删除存在的图元,清除drawId中的id数据
|
|
2127
2408
|
t.removeGraphic(drawParam.data.id);
|
|
2128
2409
|
t.state.drawIds[drawParam.geometryType].splice(len, 1);
|
|
2129
2410
|
}
|
|
2411
|
+
|
|
2130
2412
|
var param = {};
|
|
2131
2413
|
var paramgcr = {};
|
|
2414
|
+
|
|
2132
2415
|
if (drawParam.geometryType == 'polygon' || drawParam.geometryType == 'circle' || drawParam.geometryType == 'rectangle') {
|
|
2133
2416
|
paramgcr.fillColor = drawParam.parameter.color;
|
|
2134
2417
|
paramgcr.strokeColor = drawParam.parameter.lineColor;
|
|
@@ -2151,6 +2434,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2151
2434
|
type: drawParam.geometryType
|
|
2152
2435
|
};
|
|
2153
2436
|
}
|
|
2437
|
+
|
|
2154
2438
|
switch (drawParam.geometryType) {
|
|
2155
2439
|
case 'point':
|
|
2156
2440
|
var icon = {
|
|
@@ -2162,18 +2446,23 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2162
2446
|
scaledSize: new t.omap.Size(drawParam.parameter.width || 30, drawParam.parameter.height || 30),
|
|
2163
2447
|
url: drawParam.parameter.url || "".concat(_default2["default"].mapServerURL, "/images/defaultMarker.png")
|
|
2164
2448
|
};
|
|
2449
|
+
|
|
2165
2450
|
t._drawmanager.setOptions({
|
|
2166
2451
|
drawingControl: false,
|
|
2167
2452
|
markerOptions: {
|
|
2168
2453
|
icon: icon
|
|
2169
2454
|
}
|
|
2170
2455
|
});
|
|
2456
|
+
|
|
2171
2457
|
t._drawmanager.setDrawingMode('marker');
|
|
2458
|
+
|
|
2172
2459
|
t._drawmanagerEvent = t._drawmanager.addListener('markercomplete', function (e) {
|
|
2173
2460
|
//清楚事件监听
|
|
2174
|
-
t._drawmanagerEvent.remove();
|
|
2175
|
-
|
|
2461
|
+
t._drawmanagerEvent.remove(); //关闭绘制功能
|
|
2462
|
+
|
|
2463
|
+
|
|
2176
2464
|
t._drawmanager.setDrawingMode(null);
|
|
2465
|
+
|
|
2177
2466
|
t.GM.setGraphic(drawParam.data.id, e);
|
|
2178
2467
|
var backobj = {
|
|
2179
2468
|
id: drawParam.data.id,
|
|
@@ -2192,8 +2481,8 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2192
2481
|
},
|
|
2193
2482
|
geometryType: 'point',
|
|
2194
2483
|
mapLayer: e
|
|
2195
|
-
};
|
|
2196
|
-
|
|
2484
|
+
}; //点击事件
|
|
2485
|
+
|
|
2197
2486
|
var mClick = e.addListener('click', function (e) {
|
|
2198
2487
|
//避免鼠标在图元上 测距工具不起作用
|
|
2199
2488
|
if (t.rangingTool.isRanging) {
|
|
@@ -2201,12 +2490,12 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2201
2490
|
} else {
|
|
2202
2491
|
t.clickGraphic(drawParam.data.id, e);
|
|
2203
2492
|
}
|
|
2204
|
-
});
|
|
2205
|
-
|
|
2493
|
+
}); //鼠标移入事件
|
|
2494
|
+
|
|
2206
2495
|
var mMouseover = e.addListener('mouseover', function (e) {
|
|
2207
2496
|
t.mouseOverGraphic(drawParam.data.id, e);
|
|
2208
|
-
});
|
|
2209
|
-
|
|
2497
|
+
}); //鼠标移出事件
|
|
2498
|
+
|
|
2210
2499
|
var mMouseout = e.addListener('mouseout', function (e) {
|
|
2211
2500
|
t.mouseOutGraphic(drawParam.data.id, e);
|
|
2212
2501
|
});
|
|
@@ -2215,25 +2504,32 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2215
2504
|
mouseover: mMouseover,
|
|
2216
2505
|
mouseout: mMouseout
|
|
2217
2506
|
});
|
|
2507
|
+
|
|
2218
2508
|
if ('drawEnd' in t.props) {
|
|
2219
2509
|
t.props.drawEnd(backobj);
|
|
2220
2510
|
}
|
|
2221
2511
|
});
|
|
2222
2512
|
break;
|
|
2513
|
+
|
|
2223
2514
|
case 'polyline':
|
|
2224
2515
|
param.strokeColor = drawParam.parameter.color;
|
|
2225
2516
|
param.strokeOpacity = drawParam.parameter.pellucidity;
|
|
2226
2517
|
param.strokeWeight = drawParam.parameter.lineWidth;
|
|
2518
|
+
|
|
2227
2519
|
t._drawmanager.setOptions({
|
|
2228
2520
|
drawingControl: false,
|
|
2229
2521
|
polylineOptions: param
|
|
2230
2522
|
});
|
|
2523
|
+
|
|
2231
2524
|
t._drawmanager.setDrawingMode('polyline');
|
|
2525
|
+
|
|
2232
2526
|
t._drawmanagerEvent = t._drawmanager.addListener('polylinecomplete', function (e) {
|
|
2233
2527
|
//清楚事件监听
|
|
2234
|
-
t._drawmanagerEvent.remove();
|
|
2235
|
-
|
|
2528
|
+
t._drawmanagerEvent.remove(); //关闭绘制功能
|
|
2529
|
+
|
|
2530
|
+
|
|
2236
2531
|
t._drawmanager.setDrawingMode(null);
|
|
2532
|
+
|
|
2237
2533
|
t.GM.setGraphic(drawParam.data.id, e);
|
|
2238
2534
|
var paths = [];
|
|
2239
2535
|
var lnglatAry = (e.getPath().getArray() || []).map(function (item, index) {
|
|
@@ -2265,8 +2561,8 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2265
2561
|
paths: (0, _MapToolFunction.getMaxMin)(paths).path
|
|
2266
2562
|
},
|
|
2267
2563
|
lnglatAry: lnglatAry
|
|
2268
|
-
};
|
|
2269
|
-
|
|
2564
|
+
}; //点击事件
|
|
2565
|
+
|
|
2270
2566
|
var mClick = e.addListener('click', function (e) {
|
|
2271
2567
|
//避免鼠标在图元上 测距工具不起作用
|
|
2272
2568
|
if (t.rangingTool.isRanging) {
|
|
@@ -2274,12 +2570,12 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2274
2570
|
} else {
|
|
2275
2571
|
t.clickGraphic(drawParam.data.id, e);
|
|
2276
2572
|
}
|
|
2277
|
-
});
|
|
2278
|
-
|
|
2573
|
+
}); //鼠标移入事件
|
|
2574
|
+
|
|
2279
2575
|
var mMouseover = e.addListener('mouseover', function (e) {
|
|
2280
2576
|
t.mouseOverGraphic(drawParam.data.id, e);
|
|
2281
|
-
});
|
|
2282
|
-
|
|
2577
|
+
}); //鼠标移出事件
|
|
2578
|
+
|
|
2283
2579
|
var mMouseout = e.addListener('mouseout', function (e) {
|
|
2284
2580
|
t.mouseOutGraphic(drawParam.data.id, e);
|
|
2285
2581
|
});
|
|
@@ -2288,25 +2584,31 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2288
2584
|
mouseover: mMouseover,
|
|
2289
2585
|
mouseout: mMouseout
|
|
2290
2586
|
});
|
|
2587
|
+
|
|
2291
2588
|
if ('drawEnd' in t.props) {
|
|
2292
2589
|
t.props.drawEnd(backobj);
|
|
2293
2590
|
}
|
|
2294
2591
|
});
|
|
2295
2592
|
break;
|
|
2593
|
+
|
|
2296
2594
|
case 'polygon':
|
|
2297
2595
|
t._drawmanager.setOptions({
|
|
2298
2596
|
drawingControl: false,
|
|
2299
2597
|
polygonOptions: paramgcr
|
|
2300
2598
|
});
|
|
2599
|
+
|
|
2301
2600
|
t._drawmanager.setDrawingMode('polygon');
|
|
2601
|
+
|
|
2302
2602
|
t._drawmanagerEvent = t._drawmanager.addListener('polygoncomplete', function (e) {
|
|
2303
2603
|
//清楚事件监听
|
|
2304
|
-
t._drawmanagerEvent.remove();
|
|
2305
|
-
|
|
2604
|
+
t._drawmanagerEvent.remove(); //关闭绘制功能
|
|
2605
|
+
|
|
2606
|
+
|
|
2306
2607
|
t._drawmanager.setDrawingMode(null);
|
|
2608
|
+
|
|
2307
2609
|
t.GM.setGraphic(drawParam.data.id, e);
|
|
2308
2610
|
var paths = [],
|
|
2309
|
-
|
|
2611
|
+
area = t.calculateArea(drawParam.data.id);
|
|
2310
2612
|
var lnglatAry = (e.getPath().getArray() || []).map(function (item, index) {
|
|
2311
2613
|
paths.push({
|
|
2312
2614
|
lng: item.lng(),
|
|
@@ -2340,8 +2642,8 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2340
2642
|
},
|
|
2341
2643
|
lnglatAry: lnglatAry,
|
|
2342
2644
|
area: area
|
|
2343
|
-
};
|
|
2344
|
-
|
|
2645
|
+
}; //点击事件
|
|
2646
|
+
|
|
2345
2647
|
var mClick = e.addListener('click', function (e) {
|
|
2346
2648
|
//避免鼠标在图元上 测距工具不起作用
|
|
2347
2649
|
if (t.rangingTool.isRanging) {
|
|
@@ -2349,12 +2651,12 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2349
2651
|
} else {
|
|
2350
2652
|
t.clickGraphic(drawParam.data.id, e);
|
|
2351
2653
|
}
|
|
2352
|
-
});
|
|
2353
|
-
|
|
2654
|
+
}); //鼠标移入事件
|
|
2655
|
+
|
|
2354
2656
|
var mMouseover = e.addListener('mouseover', function (e) {
|
|
2355
2657
|
t.mouseOverGraphic(drawParam.data.id, e);
|
|
2356
|
-
});
|
|
2357
|
-
|
|
2658
|
+
}); //鼠标移出事件
|
|
2659
|
+
|
|
2358
2660
|
var mMouseout = e.addListener('mouseout', function (e) {
|
|
2359
2661
|
t.mouseOutGraphic(drawParam.data.id, e);
|
|
2360
2662
|
});
|
|
@@ -2363,22 +2665,28 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2363
2665
|
mouseover: mMouseover,
|
|
2364
2666
|
mouseout: mMouseout
|
|
2365
2667
|
});
|
|
2668
|
+
|
|
2366
2669
|
if ('drawEnd' in t.props) {
|
|
2367
2670
|
t.props.drawEnd(backobj);
|
|
2368
2671
|
}
|
|
2369
2672
|
});
|
|
2370
2673
|
break;
|
|
2674
|
+
|
|
2371
2675
|
case 'circle':
|
|
2372
2676
|
t._drawmanager.setOptions({
|
|
2373
2677
|
drawingControl: false,
|
|
2374
2678
|
circleOptions: paramgcr
|
|
2375
2679
|
});
|
|
2680
|
+
|
|
2376
2681
|
t._drawmanager.setDrawingMode('circle');
|
|
2682
|
+
|
|
2377
2683
|
t._drawmanagerEvent = t._drawmanager.addListener('circlecomplete', function (e) {
|
|
2378
2684
|
//清楚事件监听
|
|
2379
|
-
t._drawmanagerEvent.remove();
|
|
2380
|
-
|
|
2685
|
+
t._drawmanagerEvent.remove(); //关闭绘制功能
|
|
2686
|
+
|
|
2687
|
+
|
|
2381
2688
|
t._drawmanager.setDrawingMode(null);
|
|
2689
|
+
|
|
2382
2690
|
t.GM.setGraphic(drawParam.data.id, e);
|
|
2383
2691
|
var area = Math.PI * Math.pow(e.getRadius(), 2);
|
|
2384
2692
|
var backobj = {
|
|
@@ -2403,8 +2711,8 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2403
2711
|
area: area
|
|
2404
2712
|
},
|
|
2405
2713
|
area: area
|
|
2406
|
-
};
|
|
2407
|
-
|
|
2714
|
+
}; //点击事件
|
|
2715
|
+
|
|
2408
2716
|
var mClick = e.addListener('click', function (e) {
|
|
2409
2717
|
//避免鼠标在图元上 测距工具不起作用
|
|
2410
2718
|
if (t.rangingTool.isRanging) {
|
|
@@ -2412,12 +2720,12 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2412
2720
|
} else {
|
|
2413
2721
|
t.clickGraphic(drawParam.data.id, e);
|
|
2414
2722
|
}
|
|
2415
|
-
});
|
|
2416
|
-
|
|
2723
|
+
}); //鼠标移入事件
|
|
2724
|
+
|
|
2417
2725
|
var mMouseover = e.addListener('mouseover', function (e) {
|
|
2418
2726
|
t.mouseOverGraphic(drawParam.data.id, e);
|
|
2419
|
-
});
|
|
2420
|
-
|
|
2727
|
+
}); //鼠标移出事件
|
|
2728
|
+
|
|
2421
2729
|
var mMouseout = e.addListener('mouseout', function (e) {
|
|
2422
2730
|
t.mouseOutGraphic(drawParam.data.id, e);
|
|
2423
2731
|
});
|
|
@@ -2426,22 +2734,28 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2426
2734
|
mouseover: mMouseover,
|
|
2427
2735
|
mouseout: mMouseout
|
|
2428
2736
|
});
|
|
2737
|
+
|
|
2429
2738
|
if ('drawEnd' in t.props) {
|
|
2430
2739
|
t.props.drawEnd(backobj);
|
|
2431
2740
|
}
|
|
2432
2741
|
});
|
|
2433
2742
|
break;
|
|
2743
|
+
|
|
2434
2744
|
case 'rectangle':
|
|
2435
2745
|
t._drawmanager.setOptions({
|
|
2436
2746
|
drawingControl: false,
|
|
2437
2747
|
rectangleOptions: paramgcr
|
|
2438
2748
|
});
|
|
2749
|
+
|
|
2439
2750
|
t._drawmanager.setDrawingMode('rectangle');
|
|
2751
|
+
|
|
2440
2752
|
t._drawmanagerEvent = t._drawmanager.addListener('rectanglecomplete', function (e) {
|
|
2441
2753
|
//清楚事件监听
|
|
2442
|
-
t._drawmanagerEvent.remove();
|
|
2443
|
-
|
|
2754
|
+
t._drawmanagerEvent.remove(); //关闭绘制功能
|
|
2755
|
+
|
|
2756
|
+
|
|
2444
2757
|
t._drawmanager.setDrawingMode(null);
|
|
2758
|
+
|
|
2445
2759
|
t.GM.setGraphic(drawParam.data.id, e);
|
|
2446
2760
|
var lnglatJson = e.getBounds().toJSON();
|
|
2447
2761
|
var paths = [{
|
|
@@ -2487,8 +2801,8 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2487
2801
|
},
|
|
2488
2802
|
lnglatAry: lnglatAry,
|
|
2489
2803
|
area: area
|
|
2490
|
-
};
|
|
2491
|
-
|
|
2804
|
+
}; //点击事件
|
|
2805
|
+
|
|
2492
2806
|
var mClick = e.addListener('click', function (e) {
|
|
2493
2807
|
//避免鼠标在图元上 测距工具不起作用
|
|
2494
2808
|
if (t.rangingTool.isRanging) {
|
|
@@ -2496,12 +2810,12 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2496
2810
|
} else {
|
|
2497
2811
|
t.clickGraphic(drawParam.data.id, e);
|
|
2498
2812
|
}
|
|
2499
|
-
});
|
|
2500
|
-
|
|
2813
|
+
}); //鼠标移入事件
|
|
2814
|
+
|
|
2501
2815
|
var mMouseover = e.addListener('mouseover', function (e) {
|
|
2502
2816
|
t.mouseOverGraphic(drawParam.data.id, e);
|
|
2503
|
-
});
|
|
2504
|
-
|
|
2817
|
+
}); //鼠标移出事件
|
|
2818
|
+
|
|
2505
2819
|
var mMouseout = e.addListener('mouseout', function (e) {
|
|
2506
2820
|
t.mouseOutGraphic(drawParam.data.id, e);
|
|
2507
2821
|
});
|
|
@@ -2510,51 +2824,58 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2510
2824
|
mouseover: mMouseover,
|
|
2511
2825
|
mouseout: mMouseout
|
|
2512
2826
|
});
|
|
2827
|
+
|
|
2513
2828
|
if ('drawEnd' in t.props) {
|
|
2514
2829
|
t.props.drawEnd(backobj);
|
|
2515
2830
|
}
|
|
2516
2831
|
});
|
|
2517
2832
|
break;
|
|
2518
|
-
}
|
|
2519
|
-
|
|
2833
|
+
} //保存绘制图元的id便于后期比对
|
|
2834
|
+
|
|
2835
|
+
|
|
2520
2836
|
t.state.drawIds[drawParam.geometryType].push(drawParam.data.id);
|
|
2521
|
-
}
|
|
2522
|
-
|
|
2837
|
+
} //关闭绘制图元
|
|
2838
|
+
|
|
2523
2839
|
}, {
|
|
2524
2840
|
key: "closeDraw",
|
|
2525
2841
|
value: function closeDraw() {
|
|
2526
2842
|
var t = this;
|
|
2843
|
+
|
|
2527
2844
|
t._drawmanager.setDrawingMode(null);
|
|
2528
2845
|
}
|
|
2529
2846
|
/*
|
|
2530
2847
|
事件处理
|
|
2531
2848
|
*/
|
|
2532
2849
|
//点击图元事件
|
|
2850
|
+
|
|
2533
2851
|
}, {
|
|
2534
2852
|
key: "clickGraphic",
|
|
2535
2853
|
value: function clickGraphic(id, e) {
|
|
2536
|
-
var t = this;
|
|
2537
|
-
|
|
2854
|
+
var t = this; //判断是否点击的测距关闭点位
|
|
2855
|
+
|
|
2538
2856
|
if (id && id.indexOf('vtx_g_rang_end') > -1) {
|
|
2539
2857
|
var index = t.GM.getGraphicParam(id).attributes.index;
|
|
2540
2858
|
var ls = t.rangingTools[index].line,
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
t.removeGraphic(ls.id, 'line');
|
|
2544
|
-
|
|
2545
|
-
t.removeGraphic(id, 'point');
|
|
2546
|
-
|
|
2859
|
+
ps = t.rangingTools[index].points; //删除测距线
|
|
2860
|
+
|
|
2861
|
+
t.removeGraphic(ls.id, 'line'); //删除关闭点
|
|
2862
|
+
|
|
2863
|
+
t.removeGraphic(id, 'point'); //删除中间点
|
|
2864
|
+
|
|
2547
2865
|
for (var i = 0; i < ps.length; i++) {
|
|
2548
2866
|
t.removeGraphic(ps[i].id, 'point');
|
|
2549
|
-
}
|
|
2550
|
-
|
|
2867
|
+
} //清除测距数据缓存
|
|
2868
|
+
|
|
2869
|
+
|
|
2551
2870
|
delete t.rangingTools[index];
|
|
2552
2871
|
} else {
|
|
2553
2872
|
if (id.indexOf('vtx_g_rang_') > -1) {
|
|
2554
2873
|
return false;
|
|
2555
|
-
}
|
|
2556
|
-
|
|
2874
|
+
} //编辑中的图元关闭其他事件返回
|
|
2875
|
+
|
|
2876
|
+
|
|
2557
2877
|
if (t.state.editId == id) return false;
|
|
2878
|
+
|
|
2558
2879
|
if (typeof t.props.clickGraphic === "function") {
|
|
2559
2880
|
var param = t.getGraphic(id);
|
|
2560
2881
|
var obj = {
|
|
@@ -2573,18 +2894,20 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2573
2894
|
t.props.clickGraphic(obj);
|
|
2574
2895
|
}
|
|
2575
2896
|
}
|
|
2576
|
-
}
|
|
2577
|
-
|
|
2897
|
+
} //图元鼠标悬浮事件
|
|
2898
|
+
|
|
2578
2899
|
}, {
|
|
2579
2900
|
key: "mouseOverGraphic",
|
|
2580
2901
|
value: function mouseOverGraphic(id, e) {
|
|
2581
|
-
var t = this;
|
|
2582
|
-
|
|
2902
|
+
var t = this; //编辑中的图元关闭其他事件返回
|
|
2903
|
+
|
|
2583
2904
|
if (t.state.editId == id) return false;
|
|
2905
|
+
|
|
2584
2906
|
if (typeof t.props.mouseOverGraphic === 'function') {
|
|
2585
2907
|
if (id.indexOf('vtx_g_rang_') > -1) {
|
|
2586
2908
|
return false;
|
|
2587
2909
|
}
|
|
2910
|
+
|
|
2588
2911
|
var obj = {
|
|
2589
2912
|
e: e,
|
|
2590
2913
|
id: id,
|
|
@@ -2595,18 +2918,20 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2595
2918
|
};
|
|
2596
2919
|
t.props.mouseOverGraphic(obj);
|
|
2597
2920
|
}
|
|
2598
|
-
}
|
|
2599
|
-
|
|
2921
|
+
} //图元鼠标移开事件
|
|
2922
|
+
|
|
2600
2923
|
}, {
|
|
2601
2924
|
key: "mouseOutGraphic",
|
|
2602
2925
|
value: function mouseOutGraphic(id, e) {
|
|
2603
|
-
var t = this;
|
|
2604
|
-
|
|
2926
|
+
var t = this; //编辑中的图元关闭其他事件返回
|
|
2927
|
+
|
|
2605
2928
|
if (t.state.editId == id) return false;
|
|
2929
|
+
|
|
2606
2930
|
if (typeof t.props.mouseOutGraphic === "function") {
|
|
2607
2931
|
if (id.indexOf('vtx_g_rang_') > -1) {
|
|
2608
2932
|
return false;
|
|
2609
2933
|
}
|
|
2934
|
+
|
|
2610
2935
|
var obj = {
|
|
2611
2936
|
e: e,
|
|
2612
2937
|
id: id,
|
|
@@ -2622,65 +2947,73 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2622
2947
|
地图服务功能
|
|
2623
2948
|
*/
|
|
2624
2949
|
//开启路况
|
|
2950
|
+
|
|
2625
2951
|
}, {
|
|
2626
2952
|
key: "openTrafficInfo",
|
|
2627
2953
|
value: function openTrafficInfo() {
|
|
2628
2954
|
var t = this;
|
|
2955
|
+
|
|
2629
2956
|
if (!t.trafficLayer) {
|
|
2630
2957
|
t.trafficLayer = new google.maps.TrafficLayer();
|
|
2631
2958
|
}
|
|
2959
|
+
|
|
2632
2960
|
t.trafficLayer.setMap(t.state.gis);
|
|
2633
|
-
}
|
|
2634
|
-
|
|
2961
|
+
} //关闭路况
|
|
2962
|
+
|
|
2635
2963
|
}, {
|
|
2636
2964
|
key: "hideTrafficInfo",
|
|
2637
2965
|
value: function hideTrafficInfo() {
|
|
2638
2966
|
var t = this;
|
|
2967
|
+
|
|
2639
2968
|
if (t.trafficLayer) {
|
|
2640
2969
|
t.trafficLayer.setMap(null);
|
|
2641
2970
|
}
|
|
2642
|
-
}
|
|
2643
|
-
|
|
2971
|
+
} //测距功能
|
|
2972
|
+
|
|
2644
2973
|
}, {
|
|
2645
2974
|
key: "vtxRangingTool",
|
|
2646
2975
|
value: function vtxRangingTool(mapRangingTool) {
|
|
2647
2976
|
var t = this;
|
|
2648
2977
|
var _t$state2 = t.state,
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2978
|
+
lineIds = _t$state2.lineIds,
|
|
2979
|
+
polygonIds = _t$state2.polygonIds,
|
|
2980
|
+
circleIds = _t$state2.circleIds;
|
|
2652
2981
|
var gids = [].concat(_toConsumableArray(lineIds), _toConsumableArray(polygonIds), _toConsumableArray(circleIds));
|
|
2653
2982
|
t.state.gis.disableDoubleClickZoom = true;
|
|
2654
|
-
t.state.gis.draggableCursor = 'crosshair';
|
|
2655
|
-
|
|
2983
|
+
t.state.gis.draggableCursor = 'crosshair'; //开启测距状态
|
|
2984
|
+
|
|
2656
2985
|
if (!t.rangingTool.isRanging) {
|
|
2657
2986
|
t.rangingTool.isRanging = true;
|
|
2658
|
-
}
|
|
2659
|
-
|
|
2987
|
+
} //初始测距回调
|
|
2988
|
+
|
|
2989
|
+
|
|
2660
2990
|
if (!t.rangingTool.mapRangingTool) {
|
|
2661
2991
|
t.rangingTool.mapRangingTool = mapRangingTool;
|
|
2662
2992
|
}
|
|
2993
|
+
|
|
2663
2994
|
if (!t.rangingToolFun) {
|
|
2664
2995
|
/*测距功能*/
|
|
2665
2996
|
t.rangingToolFun = function (e, status) {
|
|
2666
2997
|
var fun = function fun() {
|
|
2667
2998
|
t.rangingTool.isDbclick = false;
|
|
2999
|
+
|
|
2668
3000
|
if (t.rangingTool.isRanging) {
|
|
2669
3001
|
//测距开始
|
|
2670
3002
|
//点击位置
|
|
2671
3003
|
var ftp = t.canvasProjectionOverlay.getProjection(),
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
3004
|
+
lnglat = ftp.fromContainerPixelToLatLng(new google.maps.Point(e.va.x - t.mapLeft, e.va.y - t.mapTop)),
|
|
3005
|
+
lnlt = [lnglat.lng(), lnglat.lat()]; //2个点以上 计算长度
|
|
3006
|
+
|
|
2675
3007
|
if (t.rangingTool.points.length > 0) {
|
|
2676
3008
|
t.rangingTool.distance += t.calculatePointsDistance(lnlt, [t.rangingTool.points[t.rangingTool.points.length - 1].longitude, t.rangingTool.points[t.rangingTool.points.length - 1].latitude]);
|
|
2677
3009
|
} else {
|
|
2678
3010
|
t.rangingTool.line.paths = [];
|
|
2679
3011
|
}
|
|
2680
|
-
|
|
2681
|
-
//处理距离展示
|
|
2682
|
-
|
|
2683
|
-
//加点
|
|
3012
|
+
|
|
3013
|
+
t.rangingTool.line.paths.push([].concat(lnlt)); //处理距离展示
|
|
3014
|
+
|
|
3015
|
+
var distext = t.rangingTool.distance > 0 ? t.rangingTool.distance > 1000 ? "\u603B\u957F:".concat(Math.round(t.rangingTool.distance / 10) / 100, "\u516C\u91CC") : "\u603B\u957F:".concat(t.rangingTool.distance, "\u7C73") : '起点'; //加点
|
|
3016
|
+
|
|
2684
3017
|
var point = {
|
|
2685
3018
|
id: t.rangingTool.points.length + 'vtx_g_rang_p' + Math.random(),
|
|
2686
3019
|
longitude: lnlt[0],
|
|
@@ -2690,11 +3023,12 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2690
3023
|
markerContentX: -5.5,
|
|
2691
3024
|
markerContentY: -12.5
|
|
2692
3025
|
}
|
|
2693
|
-
};
|
|
2694
|
-
|
|
2695
|
-
t.addPoint([point]);
|
|
2696
|
-
|
|
3026
|
+
}; //用addpoint方法加点
|
|
3027
|
+
|
|
3028
|
+
t.addPoint([point]); //缓存点信息
|
|
3029
|
+
|
|
2697
3030
|
t.rangingTool.points.push(point);
|
|
3031
|
+
|
|
2698
3032
|
if (t.rangingTool.line.paths.length == 2) {
|
|
2699
3033
|
//加线
|
|
2700
3034
|
t.rangingTool.line = {
|
|
@@ -2711,11 +3045,12 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2711
3045
|
t.updateLine([_objectSpread(_objectSpread({}, t.rangingTool.line), {}, {
|
|
2712
3046
|
paths: _toConsumableArray(t.rangingTool.line.paths)
|
|
2713
3047
|
})]);
|
|
2714
|
-
}
|
|
2715
|
-
|
|
3048
|
+
} //双击 测距结束
|
|
3049
|
+
|
|
3050
|
+
|
|
2716
3051
|
if (status == 'dbl') {
|
|
2717
|
-
var rangkey = new Date().getTime() + Math.random();
|
|
2718
|
-
|
|
3052
|
+
var rangkey = new Date().getTime() + Math.random(); //加结束点
|
|
3053
|
+
|
|
2719
3054
|
var end = {
|
|
2720
3055
|
id: 'vtx_g_rang_end' + Math.random(),
|
|
2721
3056
|
longitude: lnlt[0],
|
|
@@ -2728,15 +3063,15 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2728
3063
|
markerContentY: -20
|
|
2729
3064
|
},
|
|
2730
3065
|
index: rangkey
|
|
2731
|
-
};
|
|
2732
|
-
|
|
2733
|
-
t.addPoint([end]);
|
|
2734
|
-
|
|
3066
|
+
}; //用addpoint方法加点
|
|
3067
|
+
|
|
3068
|
+
t.addPoint([end]); //删除提示框
|
|
3069
|
+
|
|
2735
3070
|
t.removeGraphic('vtx_g_rang_showRangTool', 'point');
|
|
2736
|
-
t.removeGraphic('vtx_g_rang_showRangTool_line', 'line');
|
|
2737
|
-
|
|
2738
|
-
t.rangingTools[rangkey] = _objectSpread({}, t.rangingTool);
|
|
2739
|
-
|
|
3071
|
+
t.removeGraphic('vtx_g_rang_showRangTool_line', 'line'); //缓存当前这一条测距数据
|
|
3072
|
+
|
|
3073
|
+
t.rangingTools[rangkey] = _objectSpread({}, t.rangingTool); //回调测距参数
|
|
3074
|
+
|
|
2740
3075
|
if (t.rangingTool.mapRangingTool) {
|
|
2741
3076
|
t.rangingTool.mapRangingTool({
|
|
2742
3077
|
distance: t.rangingTool.distance,
|
|
@@ -2746,6 +3081,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2746
3081
|
}
|
|
2747
3082
|
}
|
|
2748
3083
|
};
|
|
3084
|
+
|
|
2749
3085
|
if (status !== 'dbl') {
|
|
2750
3086
|
//100毫秒内点击2次 则结束
|
|
2751
3087
|
if (!t.rangingTool.isDbclick) {
|
|
@@ -2754,9 +3090,11 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2754
3090
|
if (t.rangingTool.dbclickTimer) {
|
|
2755
3091
|
clearTimeout(t.rangingTool.dbclickTimer);
|
|
2756
3092
|
}
|
|
3093
|
+
|
|
2757
3094
|
t.rangingTool.isDbclick = false;
|
|
2758
3095
|
t.rangingToolEndFun(e);
|
|
2759
3096
|
}
|
|
3097
|
+
|
|
2760
3098
|
t.rangingTool.dbclickTimer = setTimeout(function () {
|
|
2761
3099
|
fun();
|
|
2762
3100
|
}, 200);
|
|
@@ -2765,20 +3103,23 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2765
3103
|
}
|
|
2766
3104
|
};
|
|
2767
3105
|
}
|
|
3106
|
+
|
|
2768
3107
|
if (!t.rangingToolMoveFun) {
|
|
2769
3108
|
t.rangingToolMoveFun = function (e) {
|
|
2770
3109
|
//获取测距提示点位
|
|
2771
|
-
var rp = _objectSpread({}, t.GM.getGraphicParam('vtx_g_rang_showRangTool').attributes);
|
|
2772
|
-
|
|
3110
|
+
var rp = _objectSpread({}, t.GM.getGraphicParam('vtx_g_rang_showRangTool').attributes); //删除多余数据,避免other层级太多
|
|
3111
|
+
|
|
3112
|
+
|
|
2773
3113
|
delete rp.other;
|
|
2774
3114
|
var rcontent = rp.markerContent;
|
|
3115
|
+
|
|
2775
3116
|
if (t.rangingTool.points.length > 0) {
|
|
2776
|
-
var distance = t.calculatePointsDistance([e.latLng.lng(), e.latLng.lat()], [t.rangingTool.points[t.rangingTool.points.length - 1].longitude, t.rangingTool.points[t.rangingTool.points.length - 1].latitude], t.state.gis, t.grwkid);
|
|
2777
|
-
|
|
3117
|
+
var distance = t.calculatePointsDistance([e.latLng.lng(), e.latLng.lat()], [t.rangingTool.points[t.rangingTool.points.length - 1].longitude, t.rangingTool.points[t.rangingTool.points.length - 1].latitude], t.state.gis, t.grwkid); // 实时计算距离
|
|
3118
|
+
|
|
2778
3119
|
distance += t.rangingTool.distance;
|
|
2779
3120
|
var distext = distance > 1000 ? "\u603B\u957F:".concat(Math.round(distance / 10) / 100, "\u516C\u91CC") : "\u603B\u957F:".concat(distance, "\u7C73");
|
|
2780
|
-
rcontent = "\n <div class='vtx-g-rang-showRangTool'>\n <div>".concat(distext, "</div>\n <div>\u5355\u51FB\u786E\u5B9A\u5730\u70B9,\u53CC\u51FB\u7ED3\u675F</div>\n </div>\n ");
|
|
2781
|
-
|
|
3121
|
+
rcontent = "\n <div class='vtx-g-rang-showRangTool'>\n <div>".concat(distext, "</div>\n <div>\u5355\u51FB\u786E\u5B9A\u5730\u70B9,\u53CC\u51FB\u7ED3\u675F</div>\n </div>\n "); //测距移动的线
|
|
3122
|
+
|
|
2782
3123
|
var sl = {
|
|
2783
3124
|
id: 'vtx_g_rang_showRangTool_line',
|
|
2784
3125
|
paths: [[t.rangingTool.points[t.rangingTool.points.length - 1].longitude, t.rangingTool.points[t.rangingTool.points.length - 1].latitude], [e.latLng.lng(), e.latLng.lat()]],
|
|
@@ -2789,6 +3130,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2789
3130
|
pellucidity: 0.5
|
|
2790
3131
|
}
|
|
2791
3132
|
};
|
|
3133
|
+
|
|
2792
3134
|
if (!t.GM.getGraphic('vtx_g_rang_showRangTool_line')) {
|
|
2793
3135
|
t.addLine([sl]);
|
|
2794
3136
|
t.GM.getGraphic('vtx_g_rang_showRangTool_line').addListener('dblclick', function (e) {
|
|
@@ -2798,6 +3140,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2798
3140
|
t.updateLine([sl]);
|
|
2799
3141
|
}
|
|
2800
3142
|
}
|
|
3143
|
+
|
|
2801
3144
|
rp = _objectSpread(_objectSpread({}, rp), {}, {
|
|
2802
3145
|
longitude: e.latLng.lng(),
|
|
2803
3146
|
latitude: e.latLng.lat(),
|
|
@@ -2806,15 +3149,16 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2806
3149
|
t.updatePoint([rp], 'nodeg');
|
|
2807
3150
|
};
|
|
2808
3151
|
}
|
|
3152
|
+
|
|
2809
3153
|
if (!t.rangingToolEndFun) {
|
|
2810
3154
|
t.rangingToolEndFun = function (e) {
|
|
2811
|
-
t.state.gis.disableDoubleClickZoom = false;
|
|
2812
|
-
|
|
3155
|
+
t.state.gis.disableDoubleClickZoom = false; //测距完结
|
|
3156
|
+
|
|
2813
3157
|
if (t.rangingTool.isRanging) {
|
|
2814
3158
|
if (t.rangingTool.points.length > 0) {
|
|
2815
3159
|
//处理点击和双击事件逻辑
|
|
2816
|
-
t.rangingToolFun(e, 'dbl');
|
|
2817
|
-
|
|
3160
|
+
t.rangingToolFun(e, 'dbl'); //回调测距参数
|
|
3161
|
+
|
|
2818
3162
|
if (t.rangingTool.mapRangingTool) {
|
|
2819
3163
|
t.rangingTool.mapRangingTool({
|
|
2820
3164
|
distance: t.rangingTool.distance,
|
|
@@ -2824,13 +3168,15 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2824
3168
|
} else {
|
|
2825
3169
|
//删除提示框
|
|
2826
3170
|
t.removeGraphic('vtx_g_rang_showRangTool', 'point');
|
|
2827
|
-
}
|
|
2828
|
-
|
|
3171
|
+
} //关闭监听事件
|
|
3172
|
+
|
|
3173
|
+
|
|
2829
3174
|
for (var i in t.rangingTool.eventList) {
|
|
2830
3175
|
if (t.rangingTool.eventList[i]) {
|
|
2831
3176
|
t.rangingTool.eventList[i].remove();
|
|
2832
3177
|
}
|
|
2833
3178
|
}
|
|
3179
|
+
|
|
2834
3180
|
t.rangingTool = _objectSpread(_objectSpread({}, t.rangingTool), {}, {
|
|
2835
3181
|
isRanging: false,
|
|
2836
3182
|
//是否开启状态
|
|
@@ -2848,16 +3194,17 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2848
3194
|
t.state.gis.draggableCursor = 'url("http://maps.gstatic.cn/mapfiles/openhand_8_8.cur"), default';
|
|
2849
3195
|
}
|
|
2850
3196
|
};
|
|
2851
|
-
}
|
|
2852
|
-
|
|
3197
|
+
} //避免鼠标在图元上 测距工具不起作用
|
|
3198
|
+
|
|
3199
|
+
|
|
2853
3200
|
gids.forEach(function (item) {
|
|
2854
3201
|
t.rangingTool.eventList[item] = t.GM.getGraphic(item).addListener('mousemove', function (e) {
|
|
2855
3202
|
if (t.rangingTool.isRanging && t.rangingToolMoveFun) {
|
|
2856
3203
|
t.rangingToolMoveFun(e);
|
|
2857
3204
|
}
|
|
2858
3205
|
});
|
|
2859
|
-
});
|
|
2860
|
-
|
|
3206
|
+
}); //地图鼠标移入事件
|
|
3207
|
+
|
|
2861
3208
|
t.rangingTool.eventList['mouseover'] = t.state.gis.addListener('mouseover', function (e) {
|
|
2862
3209
|
//鼠标移出地图时,删除测距显示点
|
|
2863
3210
|
if (t.rangingTool.isRanging) {
|
|
@@ -2873,57 +3220,61 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2873
3220
|
};
|
|
2874
3221
|
t.addPoint([rp], 'nodeg');
|
|
2875
3222
|
}
|
|
2876
|
-
});
|
|
2877
|
-
|
|
3223
|
+
}); //地图鼠标移出事件
|
|
3224
|
+
|
|
2878
3225
|
t.rangingTool.eventList['mouseout'] = t.state.gis.addListener('mouseout', function (e) {
|
|
2879
3226
|
//鼠标移出地图时,删除测距显示点
|
|
2880
3227
|
if (t.rangingTool.isRanging) {
|
|
2881
3228
|
t.removeGraphic('vtx_g_rang_showRangTool', 'point');
|
|
2882
3229
|
}
|
|
2883
|
-
});
|
|
2884
|
-
|
|
3230
|
+
}); //地图鼠标移动事件
|
|
3231
|
+
|
|
2885
3232
|
t.rangingTool.eventList['mousemove'] = t.state.gis.addListener('mousemove', function (e) {
|
|
2886
3233
|
//鼠标移动地图时,删除测距显示点
|
|
2887
3234
|
if (t.rangingTool.isRanging && t.rangingToolMoveFun) {
|
|
2888
3235
|
t.rangingToolMoveFun(e);
|
|
2889
3236
|
}
|
|
2890
|
-
});
|
|
2891
|
-
|
|
3237
|
+
}); //双击事件
|
|
3238
|
+
|
|
2892
3239
|
t.rangingTool.eventList['dblclick'] = t.state.gis.addListener('dblclick', function (e) {
|
|
2893
3240
|
t.rangingToolEndFun(e);
|
|
2894
3241
|
});
|
|
2895
|
-
}
|
|
2896
|
-
|
|
3242
|
+
} //聚合地图图元(arg为空时聚合全部点)
|
|
3243
|
+
|
|
2897
3244
|
}, {
|
|
2898
3245
|
key: "cluster",
|
|
2899
3246
|
value: function cluster(arg) {
|
|
2900
3247
|
var t = this;
|
|
2901
3248
|
var ary = t.clusterToolFunction(arg);
|
|
3249
|
+
|
|
2902
3250
|
t._cluster.addMarkers(ary);
|
|
2903
|
-
}
|
|
2904
|
-
|
|
3251
|
+
} //删除点聚合效果
|
|
3252
|
+
|
|
2905
3253
|
}, {
|
|
2906
3254
|
key: "removeCluster",
|
|
2907
3255
|
value: function removeCluster(arg) {
|
|
2908
3256
|
var t = this;
|
|
2909
3257
|
var ary = t.clusterToolFunction(arg);
|
|
3258
|
+
|
|
2910
3259
|
if (ary.length > 0) {
|
|
2911
3260
|
t._cluster.removeMarkers(ary);
|
|
2912
3261
|
}
|
|
2913
|
-
}
|
|
2914
|
-
|
|
3262
|
+
} //清空聚合效果
|
|
3263
|
+
|
|
2915
3264
|
}, {
|
|
2916
3265
|
key: "clearClusters",
|
|
2917
3266
|
value: function clearClusters() {
|
|
2918
3267
|
var t = this;
|
|
3268
|
+
|
|
2919
3269
|
t._cluster.clearMarkers();
|
|
2920
|
-
}
|
|
2921
|
-
|
|
3270
|
+
} //聚合功能公共方法(获取图元集合)
|
|
3271
|
+
|
|
2922
3272
|
}, {
|
|
2923
3273
|
key: "clusterToolFunction",
|
|
2924
3274
|
value: function clusterToolFunction(arg) {
|
|
2925
3275
|
var t = this;
|
|
2926
3276
|
var ary = [];
|
|
3277
|
+
|
|
2927
3278
|
if (!arg) {
|
|
2928
3279
|
var pointIds = t.state.pointIds;
|
|
2929
3280
|
ary = pointIds.filter(function (item, index) {
|
|
@@ -2936,26 +3287,31 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2936
3287
|
ary = arg.split(',');
|
|
2937
3288
|
}
|
|
2938
3289
|
}
|
|
2939
|
-
|
|
2940
|
-
//过滤moveTo的点位
|
|
3290
|
+
|
|
3291
|
+
t.clusterIdList = ary; //过滤moveTo的点位
|
|
2941
3292
|
//缓存所有聚合的点位
|
|
3293
|
+
|
|
2942
3294
|
var allps = [];
|
|
3295
|
+
|
|
2943
3296
|
for (var i = 0; i < ary.length; i++) {
|
|
2944
3297
|
var gc = t.GM.getGraphic(ary[i]);
|
|
2945
|
-
allps.push(gc);
|
|
2946
|
-
|
|
3298
|
+
allps.push(gc); //加入label图元
|
|
3299
|
+
|
|
2947
3300
|
if (gc.ishaveLabel) {
|
|
2948
3301
|
allps.push(t.GM.getGraphic("".concat(ary[i], "_vtxoMap_label")));
|
|
2949
3302
|
}
|
|
2950
3303
|
}
|
|
3304
|
+
|
|
2951
3305
|
return allps;
|
|
2952
3306
|
}
|
|
2953
3307
|
/*地图事件处理*/
|
|
2954
3308
|
//地图点击事件
|
|
3309
|
+
|
|
2955
3310
|
}, {
|
|
2956
3311
|
key: "clickMap",
|
|
2957
3312
|
value: function clickMap() {
|
|
2958
3313
|
var t = this;
|
|
3314
|
+
|
|
2959
3315
|
if (typeof t.props.clickMap === "function") {
|
|
2960
3316
|
t.state.gis.addListener('click', function (e) {
|
|
2961
3317
|
//测距点击事件
|
|
@@ -2973,12 +3329,13 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2973
3329
|
}
|
|
2974
3330
|
});
|
|
2975
3331
|
}
|
|
2976
|
-
}
|
|
2977
|
-
|
|
3332
|
+
} //地图拖动之前事件
|
|
3333
|
+
|
|
2978
3334
|
}, {
|
|
2979
3335
|
key: "dragMapStart",
|
|
2980
3336
|
value: function dragMapStart() {
|
|
2981
3337
|
var t = this;
|
|
3338
|
+
|
|
2982
3339
|
if (typeof t.props.dragMapStart === 'function') {
|
|
2983
3340
|
t.state.gis.addListener('dragstart', function (e) {
|
|
2984
3341
|
var obj = t.getMapExtent();
|
|
@@ -2986,12 +3343,13 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2986
3343
|
t.props.dragMapStart(obj);
|
|
2987
3344
|
});
|
|
2988
3345
|
}
|
|
2989
|
-
}
|
|
2990
|
-
|
|
3346
|
+
} //地图拖动结束后事件
|
|
3347
|
+
|
|
2991
3348
|
}, {
|
|
2992
3349
|
key: "dragMapEnd",
|
|
2993
3350
|
value: function dragMapEnd() {
|
|
2994
3351
|
var t = this;
|
|
3352
|
+
|
|
2995
3353
|
if (typeof t.props.dragMapEnd === 'function') {
|
|
2996
3354
|
t.state.gis.addListener('dragend', function (e) {
|
|
2997
3355
|
var obj = t.getMapExtent();
|
|
@@ -2999,20 +3357,22 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
2999
3357
|
t.props.dragMapEnd(obj);
|
|
3000
3358
|
});
|
|
3001
3359
|
}
|
|
3002
|
-
}
|
|
3003
|
-
|
|
3360
|
+
} //地图移动之前事件
|
|
3361
|
+
|
|
3004
3362
|
}, {
|
|
3005
3363
|
key: "moveStart",
|
|
3006
3364
|
value: function moveStart() {
|
|
3007
3365
|
var t = this;
|
|
3366
|
+
|
|
3008
3367
|
if (typeof t.props.moveStart === 'function') {
|
|
3009
3368
|
t.state.gis.addListener('bounds_changed', function (e) {
|
|
3010
3369
|
if (t.pointCollectionId) {
|
|
3011
3370
|
$("#".concat(t.pointCollectionId)).css({
|
|
3012
3371
|
visibility: 'hidden'
|
|
3013
3372
|
});
|
|
3014
|
-
}
|
|
3015
|
-
|
|
3373
|
+
} //区别是否在移动状态
|
|
3374
|
+
|
|
3375
|
+
|
|
3016
3376
|
if (!t.isZoomming && !t.isMoving) {
|
|
3017
3377
|
if (t.oldZoomLevel == t.state.gis.getZoom()) {
|
|
3018
3378
|
t.isMoving = true;
|
|
@@ -3023,12 +3383,13 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3023
3383
|
}
|
|
3024
3384
|
});
|
|
3025
3385
|
}
|
|
3026
|
-
}
|
|
3027
|
-
|
|
3386
|
+
} //google地图没有move事件和zoomEnd事件,通过模拟实现
|
|
3387
|
+
|
|
3028
3388
|
}, {
|
|
3029
3389
|
key: "moveEndAndZoomEnd",
|
|
3030
3390
|
value: function moveEndAndZoomEnd() {
|
|
3031
3391
|
var t = this;
|
|
3392
|
+
|
|
3032
3393
|
if (typeof t.props.moveEnd === 'function' || typeof t.props.zoomEnd === 'function' || typeof t.props.moveStart === 'function' || typeof t.props.zoomStart === 'function') {
|
|
3033
3394
|
t.state.gis.addListener('idle', function (e) {
|
|
3034
3395
|
if (t.pointCollectionId) {
|
|
@@ -3036,17 +3397,21 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3036
3397
|
visibility: 'inherit'
|
|
3037
3398
|
});
|
|
3038
3399
|
}
|
|
3400
|
+
|
|
3039
3401
|
var obj = t.getMapExtent();
|
|
3040
|
-
obj.e = e;
|
|
3041
|
-
|
|
3402
|
+
obj.e = e; //区别是否在移动状态-同时判断是moveEnd还是zoomEnd
|
|
3403
|
+
|
|
3042
3404
|
if (t.isMoving) {
|
|
3043
3405
|
t.isMoving = false;
|
|
3044
3406
|
}
|
|
3407
|
+
|
|
3045
3408
|
if (t.isZoomming) {
|
|
3046
3409
|
t.isZoomming = false;
|
|
3047
3410
|
}
|
|
3411
|
+
|
|
3048
3412
|
if (t.oldZoomLevel != t.state.gis.getZoom()) {
|
|
3049
3413
|
t.oldZoomLevel = t.state.gis.getZoom();
|
|
3414
|
+
|
|
3050
3415
|
if (typeof t.props.zoomEnd === 'function') {
|
|
3051
3416
|
t.props.zoomEnd(obj);
|
|
3052
3417
|
}
|
|
@@ -3054,19 +3419,21 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3054
3419
|
if (typeof t.props.moveEnd === 'function') {
|
|
3055
3420
|
t.props.moveEnd(obj);
|
|
3056
3421
|
}
|
|
3057
|
-
}
|
|
3058
|
-
|
|
3422
|
+
} //更新海量点
|
|
3423
|
+
|
|
3424
|
+
|
|
3059
3425
|
if (t.props.mapPointCollection) {
|
|
3060
3426
|
t.updatePointCollection(t.props.mapPointCollection);
|
|
3061
3427
|
}
|
|
3062
3428
|
});
|
|
3063
3429
|
}
|
|
3064
|
-
}
|
|
3065
|
-
|
|
3430
|
+
} //地图更改缩放级别开始时触发触发此事件
|
|
3431
|
+
|
|
3066
3432
|
}, {
|
|
3067
3433
|
key: "zoomStart",
|
|
3068
3434
|
value: function zoomStart() {
|
|
3069
3435
|
var t = this;
|
|
3436
|
+
|
|
3070
3437
|
if (typeof t.props.zoomStart === 'function') {
|
|
3071
3438
|
t.state.gis.addListener('zoom_changed', function (e) {
|
|
3072
3439
|
if (t.pointCollectionId) {
|
|
@@ -3074,6 +3441,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3074
3441
|
visibility: 'hidden'
|
|
3075
3442
|
});
|
|
3076
3443
|
}
|
|
3444
|
+
|
|
3077
3445
|
if (!t.isZoomming) {
|
|
3078
3446
|
t.isZoomming = true;
|
|
3079
3447
|
var obj = t.getMapExtent();
|
|
@@ -3082,44 +3450,51 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3082
3450
|
}
|
|
3083
3451
|
});
|
|
3084
3452
|
}
|
|
3085
|
-
}
|
|
3086
|
-
//对外使用方法
|
|
3453
|
+
} //对外使用方法
|
|
3087
3454
|
//显示隐藏的图元
|
|
3455
|
+
|
|
3088
3456
|
}, {
|
|
3089
3457
|
key: "showGraphicById",
|
|
3090
3458
|
value: function showGraphicById(id) {
|
|
3091
3459
|
var t = this;
|
|
3460
|
+
|
|
3092
3461
|
if (t.GM.getGraphic(id)) {
|
|
3093
3462
|
t.GM.getGraphic(id).setVisible(true);
|
|
3094
3463
|
}
|
|
3095
|
-
}
|
|
3096
|
-
|
|
3464
|
+
} //隐藏图元
|
|
3465
|
+
|
|
3097
3466
|
}, {
|
|
3098
3467
|
key: "hideGraphicById",
|
|
3099
3468
|
value: function hideGraphicById(id) {
|
|
3100
3469
|
var t = this;
|
|
3470
|
+
|
|
3101
3471
|
if (t.GM.getGraphic(id)) {
|
|
3102
3472
|
t.GM.getGraphic(id).hide(false);
|
|
3103
3473
|
}
|
|
3104
|
-
}
|
|
3105
|
-
//内部公共方法区
|
|
3474
|
+
} //内部公共方法区
|
|
3106
3475
|
//获取图元数据
|
|
3476
|
+
|
|
3107
3477
|
}, {
|
|
3108
3478
|
key: "getGraphic",
|
|
3109
3479
|
value: function getGraphic(id) {
|
|
3110
3480
|
var t = this;
|
|
3481
|
+
|
|
3111
3482
|
if (!id) {
|
|
3112
3483
|
return false;
|
|
3113
3484
|
}
|
|
3485
|
+
|
|
3114
3486
|
var gp = t.GM.getGraphicParam(id);
|
|
3115
3487
|
var gg = t.GM.getGraphic(id);
|
|
3488
|
+
|
|
3116
3489
|
if (!gg) {
|
|
3117
3490
|
return false;
|
|
3118
3491
|
}
|
|
3492
|
+
|
|
3119
3493
|
var p = {},
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3494
|
+
pts = [],
|
|
3495
|
+
lng = 0,
|
|
3496
|
+
lat = 0;
|
|
3497
|
+
|
|
3123
3498
|
switch (gp.geometryType) {
|
|
3124
3499
|
case 'point':
|
|
3125
3500
|
lng = gg.getPosition().lng();
|
|
@@ -3140,6 +3515,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3140
3515
|
})
|
|
3141
3516
|
});
|
|
3142
3517
|
break;
|
|
3518
|
+
|
|
3143
3519
|
case 'polyline':
|
|
3144
3520
|
pts = gg.getPath().getArray().map(function (item, index) {
|
|
3145
3521
|
return [item.lng(), item.lat()];
|
|
@@ -3157,6 +3533,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3157
3533
|
})
|
|
3158
3534
|
});
|
|
3159
3535
|
break;
|
|
3536
|
+
|
|
3160
3537
|
case 'polygon':
|
|
3161
3538
|
pts = gg.getPath().getArray().map(function (item, index) {
|
|
3162
3539
|
return [item.lng(), item.lat()];
|
|
@@ -3174,6 +3551,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3174
3551
|
})
|
|
3175
3552
|
});
|
|
3176
3553
|
break;
|
|
3554
|
+
|
|
3177
3555
|
case 'circle':
|
|
3178
3556
|
lng = gg.getCenter().lng();
|
|
3179
3557
|
lat = gg.getCenter().lat();
|
|
@@ -3198,9 +3576,10 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3198
3576
|
});
|
|
3199
3577
|
break;
|
|
3200
3578
|
}
|
|
3579
|
+
|
|
3201
3580
|
return p;
|
|
3202
|
-
}
|
|
3203
|
-
|
|
3581
|
+
} //获取地图当前的位置状态信息
|
|
3582
|
+
|
|
3204
3583
|
}, {
|
|
3205
3584
|
key: "getMapExtent",
|
|
3206
3585
|
value: function getMapExtent() {
|
|
@@ -3223,44 +3602,50 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3223
3602
|
};
|
|
3224
3603
|
obj.radius = t.calculatePointsDistance([obj.nowCenter.lng(), obj.nowCenter.lat()], [obj.northEast.lng, obj.northEast.lat]);
|
|
3225
3604
|
return obj;
|
|
3226
|
-
}
|
|
3227
|
-
|
|
3605
|
+
} //获取当前比例尺
|
|
3606
|
+
|
|
3228
3607
|
}, {
|
|
3229
3608
|
key: "getZoomLevel",
|
|
3230
3609
|
value: function getZoomLevel() {
|
|
3231
3610
|
var t = this;
|
|
3232
3611
|
return t.state.gis.getZoom();
|
|
3233
|
-
}
|
|
3234
|
-
|
|
3612
|
+
} //处理线和面的 经纬度数据
|
|
3613
|
+
|
|
3235
3614
|
}, {
|
|
3236
3615
|
key: "dealData",
|
|
3237
3616
|
value: function dealData(ms) {
|
|
3238
3617
|
//区别点和圆的经纬度数据处理
|
|
3239
3618
|
var lnglatAry = [],
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3619
|
+
_extent = {
|
|
3620
|
+
xmax: 0,
|
|
3621
|
+
xmin: 0,
|
|
3622
|
+
ymax: 0,
|
|
3623
|
+
ymin: 0
|
|
3624
|
+
},
|
|
3625
|
+
path = [];
|
|
3626
|
+
|
|
3247
3627
|
if ('getPath' in ms) {
|
|
3248
3628
|
path = ms.getPath().getArray();
|
|
3249
3629
|
path = path.map(function (item, index) {
|
|
3250
3630
|
var lng = item.lng(),
|
|
3251
|
-
|
|
3631
|
+
lat = item.lat();
|
|
3632
|
+
|
|
3252
3633
|
if (lng > _extent.xmax) {
|
|
3253
3634
|
_extent.xmax = lng;
|
|
3254
3635
|
}
|
|
3636
|
+
|
|
3255
3637
|
if (lng < _extent.xmin || _extent.xmin == 0) {
|
|
3256
3638
|
_extent.xmin = lng;
|
|
3257
3639
|
}
|
|
3640
|
+
|
|
3258
3641
|
if (lat > _extent.ymax) {
|
|
3259
3642
|
_extent.ymax = lat;
|
|
3260
3643
|
}
|
|
3644
|
+
|
|
3261
3645
|
if (lat < _extent.ymin || _extent.ymin == 0) {
|
|
3262
3646
|
_extent.ymin = lat;
|
|
3263
3647
|
}
|
|
3648
|
+
|
|
3264
3649
|
lnglatAry.push({
|
|
3265
3650
|
lngX: lng,
|
|
3266
3651
|
latX: lat
|
|
@@ -3268,122 +3653,142 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3268
3653
|
return [lng, lat];
|
|
3269
3654
|
});
|
|
3270
3655
|
}
|
|
3656
|
+
|
|
3271
3657
|
return {
|
|
3272
3658
|
lnglatAry: lnglatAry,
|
|
3273
3659
|
_extent: _extent,
|
|
3274
3660
|
path: path
|
|
3275
3661
|
};
|
|
3276
|
-
}
|
|
3277
|
-
|
|
3662
|
+
} //点位移动动画效果
|
|
3663
|
+
|
|
3278
3664
|
}, {
|
|
3279
3665
|
key: "moveAnimation",
|
|
3280
3666
|
value: function moveAnimation() {
|
|
3281
3667
|
var t = this;
|
|
3668
|
+
|
|
3282
3669
|
if (t.moveToTimer) {
|
|
3283
3670
|
clearInterval(t.moveToTimer);
|
|
3284
3671
|
}
|
|
3672
|
+
|
|
3285
3673
|
t.moveToTimer = setInterval(function () {
|
|
3286
3674
|
for (var i = 0; i < t.movePoints.length; i++) {
|
|
3287
3675
|
t.movePoints[i].waitTime += 10;
|
|
3288
3676
|
t.movePoints[i].deleteTime -= 10;
|
|
3289
3677
|
}
|
|
3678
|
+
|
|
3290
3679
|
t.movePoints.sort(function (x, y) {
|
|
3291
3680
|
return y.waitTime - x.waitTime;
|
|
3292
3681
|
});
|
|
3293
3682
|
var nowMovePoints = t.movePoints.slice(0, 10),
|
|
3294
|
-
|
|
3683
|
+
deleteIndex = [];
|
|
3684
|
+
|
|
3295
3685
|
for (var _i3 = 0; _i3 < nowMovePoints.length; _i3++) {
|
|
3296
3686
|
var _nowMovePoints$_i = nowMovePoints[_i3],
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3687
|
+
id = _nowMovePoints$_i.id,
|
|
3688
|
+
rx = _nowMovePoints$_i.rx,
|
|
3689
|
+
ry = _nowMovePoints$_i.ry,
|
|
3690
|
+
waitTime = _nowMovePoints$_i.waitTime,
|
|
3691
|
+
deleteTime = _nowMovePoints$_i.deleteTime;
|
|
3302
3692
|
var gc = t.GM.getGraphic(id),
|
|
3303
|
-
|
|
3693
|
+
gc_label = t.GM.getGraphic("".concat(id, "_vtxoMap_label"));
|
|
3694
|
+
|
|
3304
3695
|
if (!gc) {
|
|
3305
3696
|
clearInterval(t.moveToTimer);
|
|
3306
3697
|
} else {
|
|
3307
3698
|
if (gc.isAdded) {
|
|
3308
3699
|
t._cluster.removeMarker(gc);
|
|
3309
3700
|
}
|
|
3701
|
+
|
|
3310
3702
|
if (gc_label && gc_label.isAdded) {
|
|
3311
3703
|
t._cluster.removeMarker(gc_label);
|
|
3312
3704
|
}
|
|
3705
|
+
|
|
3313
3706
|
var gg = gc.getPosition();
|
|
3314
3707
|
var tx = gg.lng() + rx,
|
|
3315
|
-
|
|
3708
|
+
ty = gg.lat() + ry;
|
|
3316
3709
|
gc.setPosition(new t.omap.LatLng({
|
|
3317
3710
|
lng: tx,
|
|
3318
3711
|
lat: ty
|
|
3319
3712
|
}));
|
|
3713
|
+
|
|
3320
3714
|
if (gc_label) {
|
|
3321
3715
|
gc_label.setPosition(new t.omap.LatLng({
|
|
3322
3716
|
lng: tx,
|
|
3323
3717
|
lat: ty
|
|
3324
3718
|
}));
|
|
3325
3719
|
}
|
|
3720
|
+
|
|
3326
3721
|
t.movePoints[_i3].waitTime = 0;
|
|
3722
|
+
|
|
3327
3723
|
if (deleteTime <= 0) {
|
|
3328
3724
|
deleteIndex.push(_i3);
|
|
3329
3725
|
}
|
|
3330
3726
|
}
|
|
3331
3727
|
}
|
|
3728
|
+
|
|
3332
3729
|
deleteIndex.sort(function (a, b) {
|
|
3333
3730
|
return b - a;
|
|
3334
3731
|
});
|
|
3732
|
+
|
|
3335
3733
|
for (var _i4 = 0; _i4 < deleteIndex.length; _i4++) {
|
|
3336
3734
|
var _t$movePoints$deleteI = t.movePoints[deleteIndex[_i4]],
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3735
|
+
_id = _t$movePoints$deleteI.id,
|
|
3736
|
+
_rx = _t$movePoints$deleteI.rx,
|
|
3737
|
+
_ry = _t$movePoints$deleteI.ry,
|
|
3738
|
+
_waitTime = _t$movePoints$deleteI.waitTime,
|
|
3739
|
+
_deleteTime = _t$movePoints$deleteI.deleteTime,
|
|
3740
|
+
_gc = t.GM.getGraphic(_id),
|
|
3741
|
+
_gc_label = t.GM.getGraphic("".concat(_id, "_vtxoMap_label"));
|
|
3742
|
+
|
|
3344
3743
|
if (t.clusterIdList.indexOf(_id) > -1) {
|
|
3345
3744
|
t._cluster.addMarker(_gc);
|
|
3745
|
+
|
|
3346
3746
|
if (_gc_label) {
|
|
3347
3747
|
t._cluster.addMarker(_gc_label);
|
|
3348
3748
|
}
|
|
3349
3749
|
}
|
|
3750
|
+
|
|
3350
3751
|
t.movePoints.splice(deleteIndex[_i4], 1);
|
|
3351
3752
|
}
|
|
3753
|
+
|
|
3352
3754
|
if (nowMovePoints.length == 0) {
|
|
3353
3755
|
clearInterval(t.moveToTimer);
|
|
3354
3756
|
}
|
|
3355
3757
|
}, 10);
|
|
3356
|
-
}
|
|
3357
|
-
|
|
3758
|
+
} //点位移动逻辑
|
|
3759
|
+
|
|
3358
3760
|
}, {
|
|
3359
3761
|
key: "moveTo",
|
|
3360
3762
|
value: function moveTo(id, lnglat, delay, autoRotation, urlright, urlleft) {
|
|
3361
3763
|
var t = this,
|
|
3362
|
-
|
|
3363
|
-
|
|
3764
|
+
timer = 10,
|
|
3765
|
+
gc = t.GM.getGraphic(id);
|
|
3364
3766
|
delay = eval(delay || 3) * 1000;
|
|
3365
3767
|
var count = delay / timer;
|
|
3366
3768
|
var s = gc.getPosition(),
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3769
|
+
e = new t.omap.LatLng({
|
|
3770
|
+
lng: lnglat[0],
|
|
3771
|
+
lat: lnglat[1]
|
|
3772
|
+
});
|
|
3773
|
+
|
|
3371
3774
|
if (s.equals(e)) {
|
|
3372
3775
|
return false;
|
|
3373
3776
|
} else {
|
|
3374
|
-
var url = null;
|
|
3375
|
-
|
|
3777
|
+
var url = null; //计算角度,旋转
|
|
3778
|
+
|
|
3376
3779
|
if (autoRotation && !gc.isMarkerContent) {
|
|
3377
3780
|
var ddeg = t.rotateDeg(s, e);
|
|
3781
|
+
|
|
3378
3782
|
if (urlleft && ddeg < -90 && ddeg > -270) {
|
|
3379
3783
|
ddeg += 180;
|
|
3380
3784
|
url = urlleft;
|
|
3381
3785
|
} else {
|
|
3382
3786
|
url = urlright;
|
|
3383
3787
|
}
|
|
3788
|
+
|
|
3384
3789
|
var icon = gc.getIcon(),
|
|
3385
|
-
|
|
3386
|
-
|
|
3790
|
+
iconUrl = ''; // 360deg 不需要旋转
|
|
3791
|
+
|
|
3387
3792
|
if (ddeg % 360 != 0) {
|
|
3388
3793
|
iconUrl = new _MapToolFunction.RotateIcon({
|
|
3389
3794
|
url: url,
|
|
@@ -3391,14 +3796,17 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3391
3796
|
height: icon.size.height
|
|
3392
3797
|
});
|
|
3393
3798
|
}
|
|
3799
|
+
|
|
3394
3800
|
gc.setIcon(_objectSpread(_objectSpread({}, icon), {}, {
|
|
3395
3801
|
url: iconUrl.setRotation(ddeg).getUrl()
|
|
3396
3802
|
}));
|
|
3397
|
-
}
|
|
3398
|
-
|
|
3803
|
+
} //拆分延迟移动定位
|
|
3804
|
+
|
|
3805
|
+
|
|
3399
3806
|
var rx = (e.lng() - s.lng()) / count,
|
|
3400
|
-
|
|
3807
|
+
ry = (e.lat() - s.lat()) / count;
|
|
3401
3808
|
var isHave = false;
|
|
3809
|
+
|
|
3402
3810
|
for (var i = 0; i < t.movePoints.length; i++) {
|
|
3403
3811
|
if (t.movePoints[i].id == id) {
|
|
3404
3812
|
t.movePoints.splice(i, 1, {
|
|
@@ -3411,6 +3819,7 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3411
3819
|
isHave = true;
|
|
3412
3820
|
}
|
|
3413
3821
|
}
|
|
3822
|
+
|
|
3414
3823
|
if (!isHave) {
|
|
3415
3824
|
t.movePoints.push({
|
|
3416
3825
|
id: id,
|
|
@@ -3421,16 +3830,17 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3421
3830
|
});
|
|
3422
3831
|
}
|
|
3423
3832
|
}
|
|
3424
|
-
}
|
|
3425
|
-
|
|
3833
|
+
} //点位角度旋转(以指向东(右)为0°)
|
|
3834
|
+
|
|
3426
3835
|
}, {
|
|
3427
3836
|
key: "rotateDeg",
|
|
3428
3837
|
value: function rotateDeg(sp, ep) {
|
|
3429
3838
|
var t = this,
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3839
|
+
deg = 0,
|
|
3840
|
+
ftp = t.canvasProjectionOverlay.getProjection(),
|
|
3841
|
+
spLngLat = sp,
|
|
3842
|
+
epLngLat = ep;
|
|
3843
|
+
|
|
3434
3844
|
if (ftp) {
|
|
3435
3845
|
if (Array.isArray(sp)) {
|
|
3436
3846
|
spLngLat = new t.omap.LatLng({
|
|
@@ -3438,25 +3848,29 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3438
3848
|
lat: sp[1]
|
|
3439
3849
|
});
|
|
3440
3850
|
}
|
|
3851
|
+
|
|
3441
3852
|
if (Array.isArray(ep)) {
|
|
3442
3853
|
spLngLat = new t.omap.LatLng({
|
|
3443
3854
|
lng: ep[0],
|
|
3444
3855
|
lat: ep[1]
|
|
3445
3856
|
});
|
|
3446
3857
|
}
|
|
3858
|
+
|
|
3447
3859
|
var s = ftp.fromLatLngToContainerPixel(spLngLat),
|
|
3448
|
-
|
|
3449
|
-
|
|
3860
|
+
//获取当前点位的经纬度
|
|
3861
|
+
e = ftp.fromLatLngToContainerPixel(epLngLat);
|
|
3862
|
+
|
|
3450
3863
|
if (e.x != s.x) {
|
|
3451
3864
|
var tan = (e.y - s.y) / (e.x - s.x),
|
|
3452
|
-
|
|
3453
|
-
deg = atan * 360 / (2 * Math.PI);
|
|
3454
|
-
|
|
3865
|
+
atan = Math.atan(tan);
|
|
3866
|
+
deg = atan * 360 / (2 * Math.PI); //degree correction;
|
|
3867
|
+
|
|
3455
3868
|
if (e.x < s.x) {
|
|
3456
3869
|
deg = -deg + 90 + 90;
|
|
3457
3870
|
} else {
|
|
3458
3871
|
deg = -deg;
|
|
3459
3872
|
}
|
|
3873
|
+
|
|
3460
3874
|
deg = -deg;
|
|
3461
3875
|
} else {
|
|
3462
3876
|
var disy = e.y - s.y;
|
|
@@ -3466,35 +3880,43 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3466
3880
|
deg = -bias * 90;
|
|
3467
3881
|
}
|
|
3468
3882
|
}
|
|
3883
|
+
|
|
3469
3884
|
return deg;
|
|
3470
3885
|
}
|
|
3471
3886
|
/*
|
|
3472
3887
|
匹配控件位置方法
|
|
3473
3888
|
(谷歌地图有8个方位,为了统一,只使用左上,左下,右上,右下)
|
|
3474
3889
|
*/
|
|
3890
|
+
|
|
3475
3891
|
}, {
|
|
3476
3892
|
key: "matchControlPosition",
|
|
3477
3893
|
value: function matchControlPosition(location) {
|
|
3478
3894
|
var position = google.maps.ControlPosition.RIGHT_BOTTOM;
|
|
3895
|
+
|
|
3479
3896
|
switch (location) {
|
|
3480
3897
|
case 'tl':
|
|
3481
3898
|
position = google.maps.ControlPosition.LEFT_TOP;
|
|
3482
3899
|
break;
|
|
3900
|
+
|
|
3483
3901
|
case 'bl':
|
|
3484
3902
|
position = google.maps.ControlPosition.LEFT_BOTTOM;
|
|
3485
3903
|
break;
|
|
3904
|
+
|
|
3486
3905
|
case 'tr':
|
|
3487
3906
|
position = google.maps.ControlPosition.RIGHT_TOP;
|
|
3488
3907
|
break;
|
|
3908
|
+
|
|
3489
3909
|
case 'br':
|
|
3490
3910
|
position = google.maps.ControlPosition.RIGHT_BOTTOM;
|
|
3491
3911
|
break;
|
|
3492
3912
|
}
|
|
3913
|
+
|
|
3493
3914
|
return position;
|
|
3494
3915
|
}
|
|
3495
3916
|
/*
|
|
3496
3917
|
地图内部需要公共方法
|
|
3497
3918
|
*/
|
|
3919
|
+
|
|
3498
3920
|
}, {
|
|
3499
3921
|
key: "calculatePointsDistance",
|
|
3500
3922
|
value: function calculatePointsDistance(fp, ep) {
|
|
@@ -3507,45 +3929,49 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3507
3929
|
lat: ep[1]
|
|
3508
3930
|
})) * 100) / 100;
|
|
3509
3931
|
}
|
|
3932
|
+
|
|
3510
3933
|
return 0;
|
|
3511
|
-
}
|
|
3512
|
-
|
|
3934
|
+
} //计算多个点的距离(常用于线计算)
|
|
3935
|
+
|
|
3513
3936
|
}, {
|
|
3514
3937
|
key: "calculateDistance",
|
|
3515
3938
|
value: function calculateDistance(ps) {
|
|
3516
3939
|
var t = this,
|
|
3517
|
-
|
|
3940
|
+
totalDistance = 0;
|
|
3941
|
+
|
|
3518
3942
|
if (ps.length < 0) {
|
|
3519
3943
|
return false;
|
|
3520
3944
|
}
|
|
3945
|
+
|
|
3521
3946
|
for (var i = 0; i < ps.length; i++) {
|
|
3522
3947
|
if (i < ps.length - 1) {
|
|
3523
3948
|
totalDistance += t.calculatePointsDistance(ps[i], ps[i + 1]);
|
|
3524
3949
|
}
|
|
3525
3950
|
}
|
|
3951
|
+
|
|
3526
3952
|
return Math.round(totalDistance * 100) / 100;
|
|
3527
|
-
}
|
|
3528
|
-
|
|
3953
|
+
} //计算图元面积(面,圆)
|
|
3954
|
+
|
|
3529
3955
|
}, {
|
|
3530
3956
|
key: "calculateArea",
|
|
3531
3957
|
value: function calculateArea(id) {
|
|
3532
3958
|
var t = this;
|
|
3533
3959
|
return google.maps.geometry.spherical.computeArea(t.GM.getGraphic(id).getPath().getArray());
|
|
3534
|
-
}
|
|
3535
|
-
|
|
3960
|
+
} //计算多个点的距离(常用于线计算)[入参是 google 经纬度对象数组]
|
|
3961
|
+
|
|
3536
3962
|
}, {
|
|
3537
3963
|
key: "calculateGraphicDistance",
|
|
3538
3964
|
value: function calculateGraphicDistance(ary) {
|
|
3539
3965
|
var t = this;
|
|
3540
3966
|
return google.maps.geometry.spherical.computeLength(ary);
|
|
3541
|
-
}
|
|
3542
|
-
|
|
3967
|
+
} //对比对象数据是否相等
|
|
3968
|
+
|
|
3543
3969
|
}, {
|
|
3544
3970
|
key: "deepEqual",
|
|
3545
3971
|
value: function deepEqual(a, b) {
|
|
3546
3972
|
return _immutable["default"].is(_immutable["default"].fromJS(a), _immutable["default"].fromJS(b));
|
|
3547
|
-
}
|
|
3548
|
-
|
|
3973
|
+
} //数据解析(分析,新增,更新,删除对应的数据)
|
|
3974
|
+
|
|
3549
3975
|
}, {
|
|
3550
3976
|
key: "dataMatch",
|
|
3551
3977
|
value: function dataMatch(oldData, newData, type) {
|
|
@@ -3576,13 +4002,14 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3576
4002
|
updatedData: updatedData,
|
|
3577
4003
|
replacedData: replacedData
|
|
3578
4004
|
};
|
|
3579
|
-
}
|
|
3580
|
-
|
|
4005
|
+
} //处理需要增加图元的数据(避免意外问题)
|
|
4006
|
+
|
|
3581
4007
|
}, {
|
|
3582
4008
|
key: "dealAdd",
|
|
3583
4009
|
value: function dealAdd(ary, ids) {
|
|
3584
4010
|
var ads = [],
|
|
3585
|
-
|
|
4011
|
+
otherupds = [];
|
|
4012
|
+
|
|
3586
4013
|
for (var i = 0; i < ary.length; i++) {
|
|
3587
4014
|
if (ids.indexOf(ary[i].id) > -1) {
|
|
3588
4015
|
otherupds.push(ary[i]);
|
|
@@ -3590,17 +4017,19 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3590
4017
|
ads.push(ary[i]);
|
|
3591
4018
|
}
|
|
3592
4019
|
}
|
|
4020
|
+
|
|
3593
4021
|
return {
|
|
3594
4022
|
ads: ads,
|
|
3595
4023
|
otherupds: otherupds
|
|
3596
4024
|
};
|
|
3597
|
-
}
|
|
3598
|
-
|
|
4025
|
+
} //处理需要更新图元的数据(避免意外问题)
|
|
4026
|
+
|
|
3599
4027
|
}, {
|
|
3600
4028
|
key: "dealUpdate",
|
|
3601
4029
|
value: function dealUpdate(ary, ids) {
|
|
3602
4030
|
var upds = [],
|
|
3603
|
-
|
|
4031
|
+
otherads = [];
|
|
4032
|
+
|
|
3604
4033
|
for (var i = 0; i < ary.length; i++) {
|
|
3605
4034
|
if (ids.indexOf(ary[i].id) > -1) {
|
|
3606
4035
|
upds.push(ary[i]);
|
|
@@ -3608,12 +4037,13 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3608
4037
|
otherads.push(ary[i]);
|
|
3609
4038
|
}
|
|
3610
4039
|
}
|
|
4040
|
+
|
|
3611
4041
|
return {
|
|
3612
4042
|
upds: upds,
|
|
3613
4043
|
otherads: otherads
|
|
3614
4044
|
};
|
|
3615
|
-
}
|
|
3616
|
-
|
|
4045
|
+
} //渲染
|
|
4046
|
+
|
|
3617
4047
|
}, {
|
|
3618
4048
|
key: "render",
|
|
3619
4049
|
value: function render() {
|
|
@@ -3626,8 +4056,8 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3626
4056
|
height: '100%'
|
|
3627
4057
|
}
|
|
3628
4058
|
});
|
|
3629
|
-
}
|
|
3630
|
-
|
|
4059
|
+
} //初始化
|
|
4060
|
+
|
|
3631
4061
|
}, {
|
|
3632
4062
|
key: "componentDidMount",
|
|
3633
4063
|
value: function componentDidMount() {
|
|
@@ -3637,81 +4067,82 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3637
4067
|
t.mapTop = document.getElementById(t.props.mapId).offsetTop;
|
|
3638
4068
|
t.init();
|
|
3639
4069
|
});
|
|
3640
|
-
}
|
|
3641
|
-
|
|
4070
|
+
} //重新渲染结束
|
|
4071
|
+
|
|
3642
4072
|
}, {
|
|
3643
4073
|
key: "componentDidUpdate",
|
|
3644
|
-
value: function componentDidUpdate(prevProps, prevState) {}
|
|
3645
|
-
|
|
4074
|
+
value: function componentDidUpdate(prevProps, prevState) {} //已加载组件,收到新的参数时调用
|
|
4075
|
+
|
|
3646
4076
|
}, {
|
|
3647
4077
|
key: "UNSAFE_componentWillReceiveProps",
|
|
3648
4078
|
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
3649
|
-
var t = this;
|
|
3650
|
-
|
|
4079
|
+
var t = this; //点/线旧数据
|
|
4080
|
+
|
|
3651
4081
|
var _t$state3 = t.state,
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
4082
|
+
pointIds = _t$state3.pointIds,
|
|
4083
|
+
lineIds = _t$state3.lineIds,
|
|
4084
|
+
polygonIds = _t$state3.polygonIds,
|
|
4085
|
+
circleIds = _t$state3.circleIds,
|
|
4086
|
+
drawIds = _t$state3.drawIds;
|
|
3657
4087
|
var point = drawIds.point,
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
4088
|
+
polyline = drawIds.polyline,
|
|
4089
|
+
polygon = drawIds.polygon,
|
|
4090
|
+
circle = drawIds.circle,
|
|
4091
|
+
rectangle = drawIds.rectangle; //点/线新数据
|
|
4092
|
+
|
|
3663
4093
|
var _nextProps$mapPoints = nextProps.mapPoints,
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
var props = t.props;
|
|
3701
|
-
|
|
3702
|
-
// 等待地图加载
|
|
3703
|
-
if (!t.mapCreated) return;
|
|
4094
|
+
mapPoints = _nextProps$mapPoints === void 0 ? [] : _nextProps$mapPoints,
|
|
4095
|
+
_nextProps$mapLines = nextProps.mapLines,
|
|
4096
|
+
mapLines = _nextProps$mapLines === void 0 ? [] : _nextProps$mapLines,
|
|
4097
|
+
_nextProps$mapPolygon = nextProps.mapPolygons,
|
|
4098
|
+
mapPolygons = _nextProps$mapPolygon === void 0 ? [] : _nextProps$mapPolygon,
|
|
4099
|
+
_nextProps$mapCircles = nextProps.mapCircles,
|
|
4100
|
+
mapCircles = _nextProps$mapCircles === void 0 ? [] : _nextProps$mapCircles,
|
|
4101
|
+
_nextProps$customized = nextProps.customizedBoundary,
|
|
4102
|
+
customizedBoundary = _nextProps$customized === void 0 ? [] : _nextProps$customized,
|
|
4103
|
+
isOpenTrafficInfo = nextProps.isOpenTrafficInfo,
|
|
4104
|
+
boundaryName = nextProps.boundaryName,
|
|
4105
|
+
heatMapData = nextProps.heatMapData,
|
|
4106
|
+
mapVisiblePoints = nextProps.mapVisiblePoints,
|
|
4107
|
+
setVisiblePoints = nextProps.setVisiblePoints,
|
|
4108
|
+
setCenter = nextProps.setCenter,
|
|
4109
|
+
mapCenter = nextProps.mapCenter,
|
|
4110
|
+
setZoomLevel = nextProps.setZoomLevel,
|
|
4111
|
+
mapZoomLevel = nextProps.mapZoomLevel,
|
|
4112
|
+
setCluster = nextProps.setCluster,
|
|
4113
|
+
mapCluster = nextProps.mapCluster,
|
|
4114
|
+
isRangingTool = nextProps.isRangingTool,
|
|
4115
|
+
mapRangingTool = nextProps.mapRangingTool,
|
|
4116
|
+
isRemove = nextProps.isRemove,
|
|
4117
|
+
mapRemove = nextProps.mapRemove,
|
|
4118
|
+
mapDraw = nextProps.mapDraw,
|
|
4119
|
+
isDraw = nextProps.isDraw,
|
|
4120
|
+
isCloseDraw = nextProps.isCloseDraw,
|
|
4121
|
+
editGraphicId = nextProps.editGraphicId,
|
|
4122
|
+
isDoEdit = nextProps.isDoEdit,
|
|
4123
|
+
isEndEdit = nextProps.isEndEdit,
|
|
4124
|
+
mapPointCollection = nextProps.mapPointCollection,
|
|
4125
|
+
isclearAllPointCollection = nextProps.isclearAllPointCollection,
|
|
4126
|
+
isSetAreaRestriction = nextProps.isSetAreaRestriction,
|
|
4127
|
+
areaRestriction = nextProps.areaRestriction,
|
|
4128
|
+
isClearAreaRestriction = nextProps.isClearAreaRestriction,
|
|
4129
|
+
isClearAll = nextProps.isClearAll;
|
|
4130
|
+
var props = t.props; // 等待地图加载
|
|
3704
4131
|
|
|
4132
|
+
if (!t.mapCreated) return;
|
|
3705
4133
|
/*添加海量点*/
|
|
4134
|
+
|
|
3706
4135
|
if (mapPointCollection instanceof Array && props.mapPointCollection instanceof Array && !t.deepEqual(mapPointCollection, props.mapPointCollection)) {
|
|
3707
4136
|
var _t$dataMatch = t.dataMatch(props.mapPointCollection, mapPointCollection, 'id'),
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
4137
|
+
deletedDataIDs = _t$dataMatch.deletedDataIDs,
|
|
4138
|
+
addedData = _t$dataMatch.addedData,
|
|
4139
|
+
updatedData = _t$dataMatch.updatedData;
|
|
4140
|
+
|
|
3711
4141
|
t.clearPointCollection(deletedDataIDs);
|
|
3712
4142
|
t.addPointCollection(addedData);
|
|
3713
4143
|
t.updatePointCollection(updatedData);
|
|
3714
4144
|
}
|
|
4145
|
+
|
|
3715
4146
|
if (typeof isclearAllPointCollection == 'boolean' && isclearAllPointCollection || isclearAllPointCollection && isclearAllPointCollection !== t.props.isclearAllPointCollection) {
|
|
3716
4147
|
t.clearAllPointCollection();
|
|
3717
4148
|
}
|
|
@@ -3720,10 +4151,12 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3720
4151
|
pointData[1]的数据在idsForGraphicId中不存在的,执行新增
|
|
3721
4152
|
pointData[0]数据中多余的id,执行删除
|
|
3722
4153
|
*/
|
|
4154
|
+
|
|
4155
|
+
|
|
3723
4156
|
if (mapPoints instanceof Array && props.mapPoints instanceof Array && !t.deepEqual(mapPoints, props.mapPoints)) {
|
|
3724
4157
|
var oldMapPoints = props.mapPoints;
|
|
3725
|
-
var newMapPoints = mapPoints;
|
|
3726
|
-
|
|
4158
|
+
var newMapPoints = mapPoints; //过滤编辑的图元
|
|
4159
|
+
|
|
3727
4160
|
if (!!t.state.editId) {
|
|
3728
4161
|
oldMapPoints = props.mapPoints.filter(function (item) {
|
|
3729
4162
|
return item.id !== editGraphicId;
|
|
@@ -3732,41 +4165,50 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3732
4165
|
return item.id !== editGraphicId;
|
|
3733
4166
|
});
|
|
3734
4167
|
}
|
|
4168
|
+
|
|
3735
4169
|
var _t$dataMatch2 = t.dataMatch(oldMapPoints, newMapPoints, 'id'),
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
4170
|
+
_deletedDataIDs = _t$dataMatch2.deletedDataIDs,
|
|
4171
|
+
_addedData = _t$dataMatch2.addedData,
|
|
4172
|
+
_updatedData = _t$dataMatch2.updatedData;
|
|
4173
|
+
|
|
3739
4174
|
var _t$dealAdd = t.dealAdd(_addedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
|
|
3740
|
-
|
|
3741
|
-
|
|
4175
|
+
ads = _t$dealAdd.ads,
|
|
4176
|
+
otherupds = _t$dealAdd.otherupds;
|
|
4177
|
+
|
|
3742
4178
|
var _t$dealUpdate = t.dealUpdate(_updatedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
4179
|
+
upds = _t$dealUpdate.upds,
|
|
4180
|
+
otherads = _t$dealUpdate.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
4181
|
+
|
|
4182
|
+
|
|
3746
4183
|
var _iterator = _createForOfIteratorHelper(_deletedDataIDs),
|
|
3747
|
-
|
|
4184
|
+
_step;
|
|
4185
|
+
|
|
3748
4186
|
try {
|
|
3749
4187
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
3750
4188
|
var id = _step.value;
|
|
3751
4189
|
t.removeGraphic(id, 'point');
|
|
3752
|
-
}
|
|
3753
|
-
|
|
4190
|
+
} //增加
|
|
4191
|
+
|
|
3754
4192
|
} catch (err) {
|
|
3755
4193
|
_iterator.e(err);
|
|
3756
4194
|
} finally {
|
|
3757
4195
|
_iterator.f();
|
|
3758
4196
|
}
|
|
3759
|
-
|
|
3760
|
-
//更新
|
|
4197
|
+
|
|
4198
|
+
t.addPoint([].concat(_toConsumableArray(ads), _toConsumableArray(otherads))); //更新
|
|
4199
|
+
|
|
3761
4200
|
t.updatePoint([].concat(_toConsumableArray(upds), _toConsumableArray(otherupds)));
|
|
3762
4201
|
}
|
|
3763
4202
|
/*
|
|
3764
4203
|
面数据处理
|
|
3765
4204
|
先全删除,再新增
|
|
3766
4205
|
*/
|
|
4206
|
+
|
|
4207
|
+
|
|
3767
4208
|
if (mapPolygons instanceof Array && props.mapPolygons instanceof Array && !t.deepEqual(mapPolygons, props.mapPolygons)) {
|
|
3768
4209
|
var oldMapPolygons = props.mapPolygons;
|
|
3769
4210
|
var newMapPolygons = mapPolygons;
|
|
4211
|
+
|
|
3770
4212
|
if (!!t.state.editId) {
|
|
3771
4213
|
oldMapPolygons = props.mapPolygons.filter(function (item) {
|
|
3772
4214
|
return item.id !== editGraphicId;
|
|
@@ -3775,41 +4217,50 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3775
4217
|
return item.id !== editGraphicId;
|
|
3776
4218
|
});
|
|
3777
4219
|
}
|
|
4220
|
+
|
|
3778
4221
|
var _t$dataMatch3 = t.dataMatch(oldMapPolygons, newMapPolygons, 'id'),
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
4222
|
+
_deletedDataIDs2 = _t$dataMatch3.deletedDataIDs,
|
|
4223
|
+
_addedData2 = _t$dataMatch3.addedData,
|
|
4224
|
+
_updatedData2 = _t$dataMatch3.updatedData;
|
|
4225
|
+
|
|
3782
4226
|
var _t$dealAdd2 = t.dealAdd(_addedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
|
|
3783
|
-
|
|
3784
|
-
|
|
4227
|
+
_ads = _t$dealAdd2.ads,
|
|
4228
|
+
_otherupds = _t$dealAdd2.otherupds;
|
|
4229
|
+
|
|
3785
4230
|
var _t$dealUpdate2 = t.dealUpdate(_updatedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
4231
|
+
_upds = _t$dealUpdate2.upds,
|
|
4232
|
+
_otherads = _t$dealUpdate2.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
4233
|
+
|
|
4234
|
+
|
|
3789
4235
|
var _iterator2 = _createForOfIteratorHelper(_deletedDataIDs2),
|
|
3790
|
-
|
|
4236
|
+
_step2;
|
|
4237
|
+
|
|
3791
4238
|
try {
|
|
3792
4239
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
3793
4240
|
var _id2 = _step2.value;
|
|
3794
4241
|
t.removeGraphic(_id2, 'polygon');
|
|
3795
|
-
}
|
|
3796
|
-
|
|
4242
|
+
} //增加
|
|
4243
|
+
|
|
3797
4244
|
} catch (err) {
|
|
3798
4245
|
_iterator2.e(err);
|
|
3799
4246
|
} finally {
|
|
3800
4247
|
_iterator2.f();
|
|
3801
4248
|
}
|
|
3802
|
-
|
|
3803
|
-
//更新
|
|
4249
|
+
|
|
4250
|
+
t.addPolygon([].concat(_toConsumableArray(_ads), _toConsumableArray(_otherads))); //更新
|
|
4251
|
+
|
|
3804
4252
|
t.updatePolygon([].concat(_toConsumableArray(_upds), _toConsumableArray(_otherupds)));
|
|
3805
4253
|
}
|
|
3806
4254
|
/*
|
|
3807
4255
|
圆数据处理
|
|
3808
4256
|
先全删除,再新增
|
|
3809
4257
|
*/
|
|
4258
|
+
|
|
4259
|
+
|
|
3810
4260
|
if (mapCircles instanceof Array && props.mapCircles instanceof Array && !t.deepEqual(mapCircles, props.mapCircles)) {
|
|
3811
4261
|
var oldMapCircles = props.mapCircles;
|
|
3812
4262
|
var newMapCircles = mapCircles;
|
|
4263
|
+
|
|
3813
4264
|
if (!!t.state.editId) {
|
|
3814
4265
|
oldMapCircles = props.mapCircles.filter(function (item) {
|
|
3815
4266
|
return item.id !== editGraphicId;
|
|
@@ -3818,41 +4269,50 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3818
4269
|
return item.id !== editGraphicId;
|
|
3819
4270
|
});
|
|
3820
4271
|
}
|
|
4272
|
+
|
|
3821
4273
|
var _t$dataMatch4 = t.dataMatch(oldMapCircles, newMapCircles, 'id'),
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
4274
|
+
_deletedDataIDs3 = _t$dataMatch4.deletedDataIDs,
|
|
4275
|
+
_addedData3 = _t$dataMatch4.addedData,
|
|
4276
|
+
_updatedData3 = _t$dataMatch4.updatedData;
|
|
4277
|
+
|
|
3825
4278
|
var _t$dealAdd3 = t.dealAdd(_addedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
|
|
3826
|
-
|
|
3827
|
-
|
|
4279
|
+
_ads2 = _t$dealAdd3.ads,
|
|
4280
|
+
_otherupds2 = _t$dealAdd3.otherupds;
|
|
4281
|
+
|
|
3828
4282
|
var _t$dealUpdate3 = t.dealUpdate(_updatedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
4283
|
+
_upds2 = _t$dealUpdate3.upds,
|
|
4284
|
+
_otherads2 = _t$dealUpdate3.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
4285
|
+
|
|
4286
|
+
|
|
3832
4287
|
var _iterator3 = _createForOfIteratorHelper(_deletedDataIDs3),
|
|
3833
|
-
|
|
4288
|
+
_step3;
|
|
4289
|
+
|
|
3834
4290
|
try {
|
|
3835
4291
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
3836
4292
|
var _id3 = _step3.value;
|
|
3837
4293
|
t.removeGraphic(_id3, 'circle');
|
|
3838
|
-
}
|
|
3839
|
-
|
|
4294
|
+
} //增加
|
|
4295
|
+
|
|
3840
4296
|
} catch (err) {
|
|
3841
4297
|
_iterator3.e(err);
|
|
3842
4298
|
} finally {
|
|
3843
4299
|
_iterator3.f();
|
|
3844
4300
|
}
|
|
3845
|
-
|
|
3846
|
-
//更新
|
|
4301
|
+
|
|
4302
|
+
t.addCircle([].concat(_toConsumableArray(_ads2), _toConsumableArray(_otherads2))); //更新
|
|
4303
|
+
|
|
3847
4304
|
t.updateCircle([].concat(_toConsumableArray(_upds2), _toConsumableArray(_otherupds2)));
|
|
3848
4305
|
}
|
|
3849
4306
|
/*
|
|
3850
4307
|
线数据处理
|
|
3851
4308
|
先全删除,再新增
|
|
3852
4309
|
*/
|
|
4310
|
+
|
|
4311
|
+
|
|
3853
4312
|
if (mapLines instanceof Array && props.mapLines instanceof Array && !t.deepEqual(mapLines, props.mapLines)) {
|
|
3854
4313
|
var oldMapLines = props.mapLines;
|
|
3855
4314
|
var newMapLines = mapLines;
|
|
4315
|
+
|
|
3856
4316
|
if (!!t.state.editId) {
|
|
3857
4317
|
oldMapLines = props.mapLines.filter(function (item) {
|
|
3858
4318
|
return item.id !== editGraphicId;
|
|
@@ -3861,43 +4321,52 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3861
4321
|
return item.id !== editGraphicId;
|
|
3862
4322
|
});
|
|
3863
4323
|
}
|
|
4324
|
+
|
|
3864
4325
|
var _t$dataMatch5 = t.dataMatch(oldMapLines, newMapLines, 'id'),
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
4326
|
+
_deletedDataIDs4 = _t$dataMatch5.deletedDataIDs,
|
|
4327
|
+
_addedData4 = _t$dataMatch5.addedData,
|
|
4328
|
+
_updatedData4 = _t$dataMatch5.updatedData;
|
|
4329
|
+
|
|
3868
4330
|
var _t$dealAdd4 = t.dealAdd(_addedData4, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
|
|
3869
|
-
|
|
3870
|
-
|
|
4331
|
+
_ads3 = _t$dealAdd4.ads,
|
|
4332
|
+
_otherupds3 = _t$dealAdd4.otherupds;
|
|
4333
|
+
|
|
3871
4334
|
var _t$dealUpdate4 = t.dealUpdate(_updatedData4, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
4335
|
+
_upds3 = _t$dealUpdate4.upds,
|
|
4336
|
+
_otherads3 = _t$dealUpdate4.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
4337
|
+
|
|
4338
|
+
|
|
3875
4339
|
var _iterator4 = _createForOfIteratorHelper(_deletedDataIDs4),
|
|
3876
|
-
|
|
4340
|
+
_step4;
|
|
4341
|
+
|
|
3877
4342
|
try {
|
|
3878
4343
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
3879
4344
|
var _id4 = _step4.value;
|
|
3880
4345
|
t.removeGraphic(_id4, 'line');
|
|
3881
|
-
}
|
|
3882
|
-
|
|
4346
|
+
} //增加
|
|
4347
|
+
|
|
3883
4348
|
} catch (err) {
|
|
3884
4349
|
_iterator4.e(err);
|
|
3885
4350
|
} finally {
|
|
3886
4351
|
_iterator4.f();
|
|
3887
4352
|
}
|
|
3888
|
-
|
|
3889
|
-
//更新
|
|
4353
|
+
|
|
4354
|
+
t.addLine([].concat(_toConsumableArray(_ads3), _toConsumableArray(_otherads3))); //更新
|
|
4355
|
+
|
|
3890
4356
|
t.updateLine([].concat(_toConsumableArray(_upds3), _toConsumableArray(_otherupds3)));
|
|
3891
|
-
}
|
|
3892
|
-
|
|
4357
|
+
} //画其他特例线专用
|
|
4358
|
+
|
|
4359
|
+
|
|
3893
4360
|
if (customizedBoundary instanceof Array && props.customizedBoundary instanceof Array && !t.deepEqual(customizedBoundary, props.customizedBoundary)) {
|
|
3894
4361
|
var _t$dataMatch6 = t.dataMatch(props.customizedBoundary, customizedBoundary, 'id'),
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
4362
|
+
_deletedDataIDs5 = _t$dataMatch6.deletedDataIDs,
|
|
4363
|
+
_addedData5 = _t$dataMatch6.addedData,
|
|
4364
|
+
_updatedData5 = _t$dataMatch6.updatedData; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
4365
|
+
|
|
4366
|
+
|
|
3899
4367
|
var _iterator5 = _createForOfIteratorHelper(_deletedDataIDs5),
|
|
3900
|
-
|
|
4368
|
+
_step5;
|
|
4369
|
+
|
|
3901
4370
|
try {
|
|
3902
4371
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
3903
4372
|
var _id5 = _step5.value;
|
|
@@ -3908,60 +4377,75 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3908
4377
|
} finally {
|
|
3909
4378
|
_iterator5.f();
|
|
3910
4379
|
}
|
|
4380
|
+
|
|
3911
4381
|
t.addLine(_addedData5);
|
|
3912
4382
|
t.updateLine(_updatedData5);
|
|
3913
|
-
}
|
|
3914
|
-
|
|
4383
|
+
} // 获取热力图
|
|
4384
|
+
|
|
4385
|
+
|
|
3915
4386
|
if (heatMapData && !t.deepEqual(heatMapData, props.heatMapData)) {
|
|
3916
4387
|
t.heatMapOverlay(heatMapData);
|
|
3917
|
-
}
|
|
3918
|
-
|
|
4388
|
+
} //图元编辑调用
|
|
4389
|
+
|
|
4390
|
+
|
|
3919
4391
|
if (typeof isDoEdit == 'boolean' && isDoEdit || isDoEdit && isDoEdit !== t.props.isDoEdit) {
|
|
3920
4392
|
t.doEdit(editGraphicId);
|
|
3921
|
-
}
|
|
3922
|
-
|
|
4393
|
+
} //关闭图元编辑
|
|
4394
|
+
|
|
4395
|
+
|
|
3923
4396
|
if (typeof isEndEdit == 'boolean' && isEndEdit || isEndEdit && isEndEdit !== t.props.isEndEdit) {
|
|
3924
4397
|
t.endEdit();
|
|
3925
|
-
}
|
|
3926
|
-
|
|
4398
|
+
} //开启图元绘制
|
|
4399
|
+
|
|
4400
|
+
|
|
3927
4401
|
if (typeof isDraw == 'boolean' && isDraw || isDraw && isDraw !== t.props.isDraw) {
|
|
3928
4402
|
t.draw(mapDraw);
|
|
3929
|
-
}
|
|
3930
|
-
|
|
4403
|
+
} //关闭图元绘制
|
|
4404
|
+
|
|
4405
|
+
|
|
3931
4406
|
if (typeof isCloseDraw == 'boolean' && isCloseDraw || isCloseDraw && isCloseDraw !== t.props.isCloseDraw) {
|
|
3932
4407
|
t.closeDraw();
|
|
3933
|
-
}
|
|
3934
|
-
|
|
4408
|
+
} //设置中心点
|
|
4409
|
+
|
|
4410
|
+
|
|
3935
4411
|
if (typeof setCenter == 'boolean' && setCenter || setCenter && setCenter !== t.props.setCenter) {
|
|
3936
4412
|
t.setCenter(mapCenter);
|
|
3937
|
-
}
|
|
3938
|
-
|
|
4413
|
+
} //设置点聚合
|
|
4414
|
+
|
|
4415
|
+
|
|
3939
4416
|
if (typeof setCluster == 'boolean' && setCluster || setCluster && setCluster !== t.props.setCluster) {
|
|
3940
4417
|
t.cluster(mapCluster);
|
|
3941
|
-
}
|
|
3942
|
-
|
|
4418
|
+
} //设置比例尺
|
|
4419
|
+
|
|
4420
|
+
|
|
3943
4421
|
if (typeof setZoomLevel == 'boolean' && setZoomLevel || setZoomLevel && setZoomLevel !== t.props.setZoomLevel) {
|
|
3944
4422
|
t.setZoomLevel(mapZoomLevel);
|
|
3945
4423
|
}
|
|
3946
4424
|
/*设置指定图元展示*/
|
|
4425
|
+
|
|
4426
|
+
|
|
3947
4427
|
if (typeof setVisiblePoints == 'boolean' && setVisiblePoints || setVisiblePoints && setVisiblePoints !== t.props.setVisiblePoints) {
|
|
3948
4428
|
t.setVisiblePoints(mapVisiblePoints);
|
|
3949
|
-
}
|
|
3950
|
-
|
|
4429
|
+
} //测距工具调用
|
|
4430
|
+
|
|
4431
|
+
|
|
3951
4432
|
if (typeof isRangingTool == 'boolean' && isRangingTool || isRangingTool && isRangingTool !== t.props.isRangingTool) {
|
|
3952
4433
|
t.vtxRangingTool(mapRangingTool);
|
|
3953
|
-
}
|
|
3954
|
-
|
|
4434
|
+
} //开关路况
|
|
4435
|
+
|
|
4436
|
+
|
|
3955
4437
|
if (isOpenTrafficInfo) {
|
|
3956
4438
|
t.openTrafficInfo();
|
|
3957
4439
|
} else {
|
|
3958
4440
|
t.hideTrafficInfo();
|
|
3959
|
-
}
|
|
3960
|
-
|
|
4441
|
+
} //清空地图
|
|
4442
|
+
|
|
4443
|
+
|
|
3961
4444
|
if (typeof isClearAll == 'boolean' && isClearAll || isClearAll && isClearAll !== t.props.isClearAll) {
|
|
3962
4445
|
t.clearAll();
|
|
3963
|
-
}
|
|
3964
|
-
|
|
4446
|
+
} //删除指定图元
|
|
4447
|
+
|
|
4448
|
+
|
|
3965
4449
|
if (typeof isRemove == 'boolean' && isRemove || isRemove && isRemove !== t.props.isRemove) {
|
|
3966
4450
|
mapRemove.map(function (item, index) {
|
|
3967
4451
|
t.removeGraphic(item.id, item.type);
|
|
@@ -3973,27 +4457,37 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
3973
4457
|
value: function componentWillUnmount() {
|
|
3974
4458
|
//关闭moveTo定时
|
|
3975
4459
|
var t = this;
|
|
4460
|
+
|
|
3976
4461
|
if (t.loadLabel) {
|
|
3977
4462
|
clearInterval(t.loadLabel);
|
|
3978
4463
|
}
|
|
4464
|
+
|
|
3979
4465
|
if (t.upPsTimer) {
|
|
3980
4466
|
clearTimeout(t.upPsTimer);
|
|
3981
4467
|
}
|
|
4468
|
+
|
|
3982
4469
|
if (t.addPsTimer) {
|
|
3983
4470
|
clearTimeout(t.addPsTimer);
|
|
3984
4471
|
}
|
|
4472
|
+
|
|
3985
4473
|
if (t.state.gis) {
|
|
3986
4474
|
t.state.gis.clearOverlays();
|
|
3987
4475
|
}
|
|
4476
|
+
|
|
3988
4477
|
t.state.gis = null;
|
|
4478
|
+
|
|
3989
4479
|
if (t.moveToTimer) {
|
|
3990
4480
|
clearInterval(t.moveToTimer);
|
|
3991
4481
|
}
|
|
4482
|
+
|
|
3992
4483
|
window.VtxMap[t.state.mapId] = null;
|
|
3993
4484
|
}
|
|
3994
4485
|
}]);
|
|
4486
|
+
|
|
3995
4487
|
return Map;
|
|
3996
4488
|
}(_react["default"].Component);
|
|
3997
|
-
|
|
4489
|
+
|
|
4490
|
+
var _default = Map;
|
|
4491
|
+
exports["default"] = _default;
|
|
3998
4492
|
module.exports = exports["default"];
|
|
3999
4493
|
//# sourceMappingURL=Map.js.map
|