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