@vtx/map 1.1.49 → 1.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/VtxMap/AMap/AMap.js +1003 -633
- package/lib/VtxMap/AMap/AMap.js.map +1 -1
- package/lib/VtxMap/BMap/Map.js +1198 -749
- package/lib/VtxMap/BMap/Map.js.map +1 -1
- package/lib/VtxMap/GMap/Map.js +1564 -1046
- package/lib/VtxMap/GMap/Map.js.map +1 -1
- package/lib/VtxMap/Map.js +42 -8
- package/lib/VtxMap/Map.js.map +1 -1
- package/lib/VtxMap/MapToolFunction.js +63 -26
- package/lib/VtxMap/MapToolFunction.js.map +1 -1
- package/lib/VtxMap/OMap/Map.js +1361 -867
- package/lib/VtxMap/OMap/Map.js.map +1 -1
- package/lib/VtxMap/OlMap/Map.js +1243 -722
- package/lib/VtxMap/OlMap/Map.js.map +1 -1
- package/lib/VtxMap/TMap/TMap.js +1059 -652
- package/lib/VtxMap/TMap/TMap.js.map +1 -1
- package/lib/VtxMap/index.js +8 -1
- package/lib/VtxMap/index.js.map +1 -1
- package/lib/VtxMap/mapPlayer.js +123 -67
- package/lib/VtxMap/mapPlayer.js.map +1 -1
- package/lib/VtxMap/optimizingPointMap.js +77 -21
- package/lib/VtxMap/optimizingPointMap.js.map +1 -1
- package/lib/VtxMap/style/css.js +6 -0
- package/lib/VtxMap/style/css.js.map +1 -1
- package/lib/VtxMap/style/index.js +6 -0
- package/lib/VtxMap/style/index.js.map +1 -1
- package/lib/VtxMap/zoomMap.js +41 -12
- package/lib/VtxMap/zoomMap.js.map +1 -1
- package/lib/VtxModal/VtxModal.js +63 -19
- package/lib/VtxModal/VtxModal.js.map +1 -1
- package/lib/VtxModal/draggableModal.js +48 -12
- package/lib/VtxModal/draggableModal.js.map +1 -1
- package/lib/VtxModal/index.js +6 -1
- package/lib/VtxModal/index.js.map +1 -1
- package/lib/VtxModal/style/css.js +6 -0
- package/lib/VtxModal/style/css.js.map +1 -1
- package/lib/VtxModal/style/index.js +6 -0
- package/lib/VtxModal/style/index.js.map +1 -1
- package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js +238 -105
- package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js.map +1 -1
- package/lib/VtxSearchCheckMap/index.js +2 -0
- package/lib/VtxSearchCheckMap/index.js.map +1 -1
- package/lib/VtxSearchCheckMap/mapping.js +2 -1
- package/lib/VtxSearchCheckMap/mapping.js.map +1 -1
- package/lib/VtxSearchCheckMap/style/css.js +19 -0
- package/lib/VtxSearchCheckMap/style/css.js.map +1 -1
- package/lib/VtxSearchCheckMap/style/index.js +19 -0
- package/lib/VtxSearchCheckMap/style/index.js.map +1 -1
- package/lib/VtxSearchMap/VtxSearchMap.js +229 -91
- package/lib/VtxSearchMap/VtxSearchMap.js.map +1 -1
- package/lib/VtxSearchMap/index.js +2 -0
- package/lib/VtxSearchMap/index.js.map +1 -1
- package/lib/VtxSearchMap/mapping.js +2 -1
- package/lib/VtxSearchMap/mapping.js.map +1 -1
- package/lib/VtxSearchMap/style/css.js +19 -0
- package/lib/VtxSearchMap/style/css.js.map +1 -1
- package/lib/VtxSearchMap/style/index.js +19 -0
- package/lib/VtxSearchMap/style/index.js.map +1 -1
- package/lib/default.js +19 -4
- package/lib/default.js.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/util.js +17 -5
- package/lib/utils/util.js.map +1 -1
- package/package.json +1 -1
package/lib/VtxMap/AMap/AMap.js
CHANGED
|
@@ -1,51 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
9
12
|
var _reactDom = require("react-dom");
|
|
13
|
+
|
|
10
14
|
var _MapToolFunction = require("../MapToolFunction");
|
|
15
|
+
|
|
11
16
|
var _immutable = _interopRequireDefault(require("immutable"));
|
|
17
|
+
|
|
12
18
|
var _default2 = _interopRequireDefault(require("../../default"));
|
|
19
|
+
|
|
13
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
|
|
14
22
|
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; } } }; }
|
|
23
|
+
|
|
15
24
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
25
|
+
|
|
16
26
|
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."); }
|
|
27
|
+
|
|
17
28
|
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); }
|
|
29
|
+
|
|
18
30
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
31
|
+
|
|
19
32
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
20
|
-
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
function
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
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; }
|
|
37
|
+
|
|
38
|
+
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; }
|
|
39
|
+
|
|
40
|
+
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; }
|
|
41
|
+
|
|
24
42
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
|
-
|
|
43
|
+
|
|
44
|
+
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); } }
|
|
45
|
+
|
|
26
46
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
|
-
|
|
28
|
-
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); }
|
|
47
|
+
|
|
29
48
|
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); }
|
|
49
|
+
|
|
30
50
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
51
|
+
|
|
31
52
|
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); }; }
|
|
53
|
+
|
|
32
54
|
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); }
|
|
55
|
+
|
|
33
56
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
57
|
+
|
|
34
58
|
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; } }
|
|
35
|
-
|
|
59
|
+
|
|
60
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
61
|
+
|
|
36
62
|
var Set = _immutable["default"].Set;
|
|
63
|
+
|
|
37
64
|
var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
38
65
|
_inherits(VortexAMap, _React$Component);
|
|
66
|
+
|
|
39
67
|
var _super = _createSuper(VortexAMap);
|
|
68
|
+
|
|
40
69
|
function VortexAMap(props) {
|
|
41
70
|
var _this;
|
|
71
|
+
|
|
42
72
|
_classCallCheck(this, VortexAMap);
|
|
43
|
-
|
|
44
|
-
//初始化 图元管理方法
|
|
73
|
+
|
|
74
|
+
_this = _super.call(this, props); //初始化 图元管理方法
|
|
75
|
+
|
|
45
76
|
_this.GM = new _MapToolFunction.graphicManage();
|
|
46
77
|
_this.getPolygonArea = _MapToolFunction.getPolygonArea;
|
|
47
78
|
_this.pointCollectionId = 'vtx_gmap_html_pointCollection'; //海量点canvas点位容器id class管理
|
|
79
|
+
|
|
48
80
|
_this.morepoints = []; //海量点集合
|
|
81
|
+
|
|
49
82
|
_this.htmlXY = {
|
|
50
83
|
x: 0,
|
|
51
84
|
y: 0,
|
|
@@ -54,23 +87,39 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
54
87
|
isCount: false
|
|
55
88
|
};
|
|
56
89
|
_this.stopMove = true; //防止zoom事件触发时,联动的触发move事件
|
|
90
|
+
|
|
57
91
|
_this.mapLeft = 0; //地图offset的Left值
|
|
92
|
+
|
|
58
93
|
_this.mapTop = 0; //地图offset的Top值
|
|
94
|
+
|
|
59
95
|
_this.clusterObj = null; //聚合点类对象
|
|
96
|
+
|
|
60
97
|
_this.trafficLayer = null; //路况类对象
|
|
98
|
+
|
|
61
99
|
_this.scale = null; //比例尺控件对象
|
|
100
|
+
|
|
62
101
|
_this.tool = null; //比例尺工具对象
|
|
102
|
+
|
|
63
103
|
_this.ruler = null; //测距对象
|
|
104
|
+
|
|
64
105
|
_this.mousetool = null; //绘制图元对象
|
|
106
|
+
|
|
65
107
|
_this.districeSearch = null; //行政区划搜索对象
|
|
108
|
+
|
|
66
109
|
_this.polyEdit = null; //折线和多边形编辑对象
|
|
110
|
+
|
|
67
111
|
_this.circleEdit = null; //圆编辑对象
|
|
112
|
+
|
|
68
113
|
_this.editTimeout = null; //圆编辑时的延迟回调,避免重复调用
|
|
114
|
+
|
|
69
115
|
_this.heatmap = null; //热力图对象
|
|
116
|
+
|
|
70
117
|
_this.satellite = null; //底图图层对象-卫星图
|
|
118
|
+
|
|
71
119
|
_this.roadNet = null; //路网图层对象
|
|
72
|
-
|
|
73
|
-
//为了样式相同,引用百度的鼠标样式
|
|
120
|
+
|
|
121
|
+
_this.mapCreated = false; //为了样式相同,引用百度的鼠标样式
|
|
122
|
+
|
|
74
123
|
_this.csr = /webkit/.test(navigator.userAgent.toLowerCase()) ? 'url("http://api.map.baidu.com/images/ruler.cur") 3 6, crosshair' : 'url("http://api.map.baidu.com/images/ruler.cur"), crosshair';
|
|
75
124
|
_this.state = {
|
|
76
125
|
gis: null,
|
|
@@ -108,9 +157,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
108
157
|
br: 'RB'
|
|
109
158
|
};
|
|
110
159
|
_this.frameSelectProps = {};
|
|
160
|
+
|
|
111
161
|
_this.loadMapJs();
|
|
162
|
+
|
|
112
163
|
return _this;
|
|
113
164
|
}
|
|
165
|
+
|
|
114
166
|
_createClass(VortexAMap, [{
|
|
115
167
|
key: "loadMapJs",
|
|
116
168
|
value: function loadMapJs() {
|
|
@@ -119,7 +171,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
119
171
|
resolve(window.AMap);
|
|
120
172
|
} else {
|
|
121
173
|
$.getScript("".concat(_default2["default"].mapServerURL, "/A_content.js"), function () {
|
|
122
|
-
$.getScript(
|
|
174
|
+
$.getScript(_default2["default"].amapScriptUrl, function () {
|
|
123
175
|
var PointCollection = new Promise(function (resolve, reject) {
|
|
124
176
|
$.getScript("".concat(_default2["default"].mapServerURL, "/GPointCollection.js"), function () {
|
|
125
177
|
resolve();
|
|
@@ -129,6 +181,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
129
181
|
(function setTime() {
|
|
130
182
|
var allEvents = [window.AMap, 'MarkerClusterer', 'MapType', 'Scale', 'ToolBar', 'DistrictSearch', 'RangingTool', 'MouseTool', 'PolyEditor', 'CircleEditor', 'PlaceSearch', 'Heatmap'];
|
|
131
183
|
var isLoading = true;
|
|
184
|
+
|
|
132
185
|
for (var i = 0; i <= allEvents.length - 1; i++) {
|
|
133
186
|
if (i === 0) {
|
|
134
187
|
if (!allEvents[i]) {
|
|
@@ -142,6 +195,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
142
195
|
}
|
|
143
196
|
}
|
|
144
197
|
}
|
|
198
|
+
|
|
145
199
|
if (isLoading) {
|
|
146
200
|
resolve(window.AMap);
|
|
147
201
|
} else {
|
|
@@ -155,143 +209,162 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
155
209
|
});
|
|
156
210
|
}
|
|
157
211
|
});
|
|
158
|
-
}
|
|
159
|
-
|
|
212
|
+
} //初始化地图
|
|
213
|
+
|
|
160
214
|
}, {
|
|
161
215
|
key: "init",
|
|
162
216
|
value: function init() {
|
|
163
217
|
var t = this;
|
|
164
218
|
var _t$props = t.props,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
219
|
+
mapPoints = _t$props.mapPoints,
|
|
220
|
+
mapLines = _t$props.mapLines,
|
|
221
|
+
mapPolygons = _t$props.mapPolygons,
|
|
222
|
+
mapCircles = _t$props.mapCircles,
|
|
223
|
+
imageOverlays = _t$props.imageOverlays,
|
|
224
|
+
setVisiblePoints = _t$props.setVisiblePoints,
|
|
225
|
+
mapVisiblePoints = _t$props.mapVisiblePoints,
|
|
226
|
+
mapCenter = _t$props.mapCenter,
|
|
227
|
+
mapZoomLevel = _t$props.mapZoomLevel,
|
|
228
|
+
mapCluster = _t$props.mapCluster,
|
|
229
|
+
mapPointCollection = _t$props.mapPointCollection,
|
|
230
|
+
showControl = _t$props.showControl,
|
|
231
|
+
boundaryName = _t$props.boundaryName,
|
|
232
|
+
heatMapData = _t$props.heatMapData,
|
|
233
|
+
areaRestriction = _t$props.areaRestriction,
|
|
234
|
+
coverageType = _t$props.coverageType,
|
|
235
|
+
infoWindowData = _t$props.infoWindowData; // 切换地图矢量图和卫星图背景
|
|
236
|
+
|
|
183
237
|
if (coverageType) {
|
|
184
238
|
t.setMapType(coverageType);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
//初始化中心点
|
|
189
|
-
|
|
190
|
-
//添加点
|
|
239
|
+
} //创建地图
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
t.createMap(); //初始化中心点
|
|
243
|
+
|
|
244
|
+
t.setCenter(mapCenter); //添加点
|
|
245
|
+
|
|
191
246
|
if (mapPoints instanceof Array) {
|
|
192
247
|
t.addPoint(mapPoints);
|
|
193
|
-
}
|
|
194
|
-
|
|
248
|
+
} //添加线
|
|
249
|
+
|
|
250
|
+
|
|
195
251
|
if (mapLines instanceof Array) {
|
|
196
252
|
t.addLine(mapLines);
|
|
197
|
-
}
|
|
198
|
-
|
|
253
|
+
} //添加面
|
|
254
|
+
|
|
255
|
+
|
|
199
256
|
if (mapPolygons instanceof Array) {
|
|
200
257
|
t.addPolygon(mapPolygons);
|
|
201
|
-
}
|
|
202
|
-
|
|
258
|
+
} //添加圆
|
|
259
|
+
|
|
260
|
+
|
|
203
261
|
if (mapCircles instanceof Array) {
|
|
204
262
|
t.addCircle(mapCircles);
|
|
205
|
-
}
|
|
206
|
-
|
|
263
|
+
} //添加图片图层
|
|
264
|
+
|
|
265
|
+
|
|
207
266
|
if (imageOverlays instanceof Array) {
|
|
208
267
|
t.imageUrlOverlay(imageOverlays);
|
|
209
268
|
}
|
|
210
269
|
/*设置指定图元展示*/
|
|
270
|
+
|
|
271
|
+
|
|
211
272
|
if (mapVisiblePoints) {
|
|
212
273
|
t.setVisiblePoints(mapVisiblePoints);
|
|
213
|
-
}
|
|
214
|
-
|
|
274
|
+
} //设置比例尺
|
|
275
|
+
|
|
276
|
+
|
|
215
277
|
if (mapZoomLevel) {
|
|
216
278
|
t.setZoomLevel(mapZoomLevel);
|
|
217
|
-
}
|
|
218
|
-
|
|
279
|
+
} //设置点聚合
|
|
280
|
+
|
|
281
|
+
|
|
219
282
|
if (mapCluster) {
|
|
220
283
|
t.cluster(mapCluster);
|
|
221
|
-
}
|
|
222
|
-
|
|
284
|
+
} //展示比例尺
|
|
285
|
+
|
|
286
|
+
|
|
223
287
|
if (showControl) {
|
|
224
288
|
t.showControl();
|
|
225
|
-
}
|
|
226
|
-
|
|
289
|
+
} //添加地图类型控件
|
|
290
|
+
|
|
291
|
+
|
|
227
292
|
if (t.props.satelliteSwitch) {
|
|
228
293
|
t.showMapTypeControl();
|
|
229
|
-
}
|
|
230
|
-
|
|
294
|
+
} //画边界线
|
|
295
|
+
|
|
296
|
+
|
|
231
297
|
if (boundaryName instanceof Array && boundaryName.length > 0) {
|
|
232
298
|
t.addBaiduBoundary(boundaryName);
|
|
233
|
-
}
|
|
299
|
+
} //回调显示方法
|
|
300
|
+
|
|
234
301
|
|
|
235
|
-
//回调显示方法
|
|
236
302
|
if (t.props.showGraphicById) {
|
|
237
303
|
t.props.showGraphicById(t.showGraphicById.bind(t));
|
|
238
|
-
}
|
|
239
|
-
|
|
304
|
+
} //回调隐藏方法
|
|
305
|
+
|
|
306
|
+
|
|
240
307
|
if (t.props.hideGraphicById) {
|
|
241
308
|
t.props.hideGraphicById(t.hideGraphicById.bind(t));
|
|
242
|
-
}
|
|
243
|
-
|
|
309
|
+
} //设置区域限制
|
|
310
|
+
|
|
311
|
+
|
|
244
312
|
if (areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
|
|
245
313
|
t.setAreaRestriction(areaRestriction);
|
|
246
|
-
}
|
|
247
|
-
|
|
314
|
+
} // 画热力图
|
|
315
|
+
|
|
316
|
+
|
|
248
317
|
if (heatMapData) {
|
|
249
318
|
t.heatMapOverlay(heatMapData);
|
|
250
|
-
}
|
|
251
|
-
|
|
319
|
+
} // 打开信息窗体
|
|
320
|
+
|
|
321
|
+
|
|
252
322
|
if (infoWindowData) {
|
|
253
323
|
t.infoWindow(infoWindowData);
|
|
254
|
-
}
|
|
255
|
-
|
|
324
|
+
} //添加海量点
|
|
325
|
+
|
|
326
|
+
|
|
256
327
|
if (mapPointCollection instanceof Array) {
|
|
257
328
|
t.addPointCollection(mapPointCollection);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
//初始化地图拖拽结束事件
|
|
262
|
-
|
|
263
|
-
//初始化地图移动开始事件
|
|
264
|
-
|
|
265
|
-
//初始化地图移动结束事件
|
|
266
|
-
|
|
267
|
-
//初始化地图zoom改变开始事件
|
|
268
|
-
|
|
269
|
-
//初始化地图zoom改变结束事件
|
|
270
|
-
|
|
271
|
-
//初始化地图点击事件
|
|
329
|
+
} //初始化地图拖拽开始事件
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
t.dragMapStart(); //初始化地图拖拽结束事件
|
|
333
|
+
|
|
334
|
+
t.dragMapEnd(); //初始化地图移动开始事件
|
|
335
|
+
|
|
336
|
+
t.moveStart(); //初始化地图移动结束事件
|
|
337
|
+
|
|
338
|
+
t.moveEnd(); //初始化地图zoom改变开始事件
|
|
339
|
+
|
|
340
|
+
t.zoomStart(); //初始化地图zoom改变结束事件
|
|
341
|
+
|
|
342
|
+
t.zoomEnd(); //初始化地图点击事件
|
|
343
|
+
|
|
272
344
|
t.clickMap();
|
|
273
345
|
this.mapCreated = true;
|
|
274
|
-
}
|
|
275
|
-
|
|
346
|
+
} //地图方法
|
|
347
|
+
|
|
276
348
|
}, {
|
|
277
349
|
key: "createMap",
|
|
278
350
|
value: function createMap(divId) {
|
|
279
351
|
var t = this;
|
|
280
352
|
var _t$props2 = t.props,
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
//缓存Map的对象,方便后期的功能操作
|
|
353
|
+
viewMode = _t$props2.viewMode,
|
|
354
|
+
mapStyle = _t$props2.mapStyle,
|
|
355
|
+
mapCenter = _t$props2.mapCenter,
|
|
356
|
+
mapId = _t$props2.mapId,
|
|
357
|
+
mapZoomLevel = _t$props2.mapZoomLevel,
|
|
358
|
+
minZoom = _t$props2.minZoom,
|
|
359
|
+
maxZoom = _t$props2.maxZoom; //缓存Map的对象,方便后期的功能操作
|
|
289
360
|
//后期不会操作gis数据,直接通过state缓存.
|
|
361
|
+
|
|
290
362
|
if (window.VtxMap) {
|
|
291
363
|
window.VtxMap[mapId] = null;
|
|
292
364
|
} else {
|
|
293
365
|
window.VtxMap = {};
|
|
294
366
|
}
|
|
367
|
+
|
|
295
368
|
window.VtxMap[mapId] = t.state.gis = new AMap.Map(mapId.toString(), {
|
|
296
369
|
viewMode: viewMode ? viewMode : '2D',
|
|
297
370
|
resizeEnable: true,
|
|
@@ -301,17 +374,21 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
301
374
|
center: mapCenter && mapCenter instanceof Array && mapCenter.length == 2 ? mapCenter : [116.400433, 39.906705],
|
|
302
375
|
zooms: [minZoom || 3, maxZoom || 18]
|
|
303
376
|
});
|
|
377
|
+
|
|
304
378
|
if (mapStyle) {
|
|
305
379
|
t.state.gis.setMapStyle(mapStyle);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
//比例尺控件对象
|
|
380
|
+
} //聚合点类对象
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
t.clusterObj = new AMap.MarkerClusterer(t.state.gis, []); //比例尺控件对象
|
|
384
|
+
|
|
310
385
|
/*算出比例尺位置偏移量*/
|
|
386
|
+
|
|
311
387
|
var offsetS = new AMap.Pixel(60, 17);
|
|
312
388
|
var offsetT = new AMap.Pixel(25, 10);
|
|
313
389
|
var zlt = 'RB';
|
|
314
390
|
var zls = 'RB';
|
|
391
|
+
|
|
315
392
|
if (t.props.showControl) {
|
|
316
393
|
switch (t.props.showControl.location) {
|
|
317
394
|
case 'tl':
|
|
@@ -320,30 +397,35 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
320
397
|
offsetS = new AMap.Pixel(10, 17);
|
|
321
398
|
offsetT = new AMap.Pixel(5, 10);
|
|
322
399
|
break;
|
|
400
|
+
|
|
323
401
|
case 'bl':
|
|
324
402
|
zlt = 'LB';
|
|
325
403
|
zls = 'LB';
|
|
326
404
|
offsetS = new AMap.Pixel(60, 19);
|
|
327
405
|
offsetT = new AMap.Pixel(5, 12);
|
|
328
406
|
break;
|
|
407
|
+
|
|
329
408
|
case 'tr':
|
|
330
409
|
zlt = 'RT';
|
|
331
410
|
zls = 'RB';
|
|
332
411
|
offsetS = new AMap.Pixel(25, 17);
|
|
333
412
|
offsetT = new AMap.Pixel(25, 10);
|
|
334
413
|
break;
|
|
414
|
+
|
|
335
415
|
case 'br':
|
|
336
416
|
zlt = 'RB';
|
|
337
417
|
zls = 'RB';
|
|
338
418
|
offsetS = new AMap.Pixel(70, 17);
|
|
339
419
|
offsetT = new AMap.Pixel(25, 10);
|
|
340
420
|
break;
|
|
341
|
-
}
|
|
342
|
-
|
|
421
|
+
} //默认是all
|
|
422
|
+
|
|
423
|
+
|
|
343
424
|
var tp = {
|
|
344
425
|
ruler: true,
|
|
345
426
|
direction: true
|
|
346
427
|
};
|
|
428
|
+
|
|
347
429
|
switch (t.props.showControl.type) {
|
|
348
430
|
case 'small':
|
|
349
431
|
tp = {
|
|
@@ -351,12 +433,14 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
351
433
|
direction: true
|
|
352
434
|
};
|
|
353
435
|
break;
|
|
436
|
+
|
|
354
437
|
case 'pan':
|
|
355
438
|
tp = {
|
|
356
439
|
ruler: false,
|
|
357
440
|
direction: true
|
|
358
441
|
};
|
|
359
442
|
break;
|
|
443
|
+
|
|
360
444
|
case 'zoom':
|
|
361
445
|
tp = {
|
|
362
446
|
ruler: false,
|
|
@@ -364,54 +448,59 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
364
448
|
};
|
|
365
449
|
break;
|
|
366
450
|
}
|
|
451
|
+
|
|
367
452
|
t.scale = new AMap.Scale({
|
|
368
453
|
position: zls,
|
|
369
454
|
offset: offsetS
|
|
370
|
-
});
|
|
371
|
-
|
|
455
|
+
}); //比例尺工具对象
|
|
456
|
+
|
|
372
457
|
t.tool = new AMap.ToolBar(_objectSpread({
|
|
373
458
|
position: zlt,
|
|
374
459
|
offset: offsetT,
|
|
375
460
|
locate: false
|
|
376
461
|
}, tp));
|
|
377
|
-
}
|
|
378
|
-
|
|
462
|
+
} //搜索服务
|
|
463
|
+
|
|
464
|
+
|
|
379
465
|
var opts = {
|
|
380
466
|
subdistrict: 1,
|
|
381
467
|
//返回下一级行政区
|
|
382
468
|
extensions: 'all',
|
|
383
469
|
//返回行政区边界坐标组等具体信息
|
|
384
470
|
level: 'district' //查询行政级别为 市
|
|
385
|
-
|
|
386
|
-
//实例化DistrictSearch
|
|
387
|
-
|
|
388
|
-
//实例化RangingTool
|
|
471
|
+
|
|
472
|
+
}; //实例化DistrictSearch
|
|
473
|
+
|
|
474
|
+
t.districeSearch = new AMap.DistrictSearch(opts); //实例化RangingTool
|
|
475
|
+
|
|
389
476
|
t.ruler = new AMap.RangingTool(t.state.gis);
|
|
390
477
|
t.ruler.on('end', function (_ref) {
|
|
391
478
|
var type = _ref.type,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
479
|
+
polyline = _ref.polyline,
|
|
480
|
+
points = _ref.points,
|
|
481
|
+
distance = _ref.distance;
|
|
395
482
|
var lnglats = points.map(function (item, index) {
|
|
396
483
|
return [item.lng, item.lat];
|
|
397
|
-
});
|
|
398
|
-
|
|
484
|
+
}); //恢复鼠标默认样式
|
|
485
|
+
|
|
399
486
|
t.state.gis.setDefaultCursor();
|
|
400
487
|
t.ruler.turnOff();
|
|
488
|
+
|
|
401
489
|
if (typeof t.props.mapRangingTool === "function") {
|
|
402
490
|
t.props.mapRangingTool({
|
|
403
491
|
distance: distance,
|
|
404
492
|
lnglats: lnglats
|
|
405
493
|
});
|
|
406
494
|
}
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
t.mousetool = new AMap.MouseTool(t.state.gis);
|
|
410
|
-
|
|
495
|
+
}); //绘制图元类
|
|
496
|
+
|
|
497
|
+
t.mousetool = new AMap.MouseTool(t.state.gis); //绘制完后的回调
|
|
498
|
+
|
|
411
499
|
t.mousetool.on('draw', function (_ref2) {
|
|
412
500
|
var _t$frameSelectProps$b;
|
|
501
|
+
|
|
413
502
|
var type = _ref2.type,
|
|
414
|
-
|
|
503
|
+
obj = _ref2.obj;
|
|
415
504
|
var drawExtData = obj.getExtData();
|
|
416
505
|
var backobj = {
|
|
417
506
|
id: drawExtData.id,
|
|
@@ -421,11 +510,11 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
421
510
|
geometry: {
|
|
422
511
|
type: drawExtData.type == 'rectangle' ? 'polygon' : drawExtData.type
|
|
423
512
|
}
|
|
424
|
-
};
|
|
425
|
-
|
|
513
|
+
}; //缓存绘制的图元信息
|
|
514
|
+
|
|
426
515
|
t.GM.setGraphic(drawExtData.id, obj);
|
|
427
|
-
t.GM.setGraphicParam(drawExtData.id, backobj);
|
|
428
|
-
|
|
516
|
+
t.GM.setGraphicParam(drawExtData.id, backobj); //添加点击事件
|
|
517
|
+
|
|
429
518
|
obj.on('click', function (e) {
|
|
430
519
|
t.clickGraphic(drawExtData.id, e);
|
|
431
520
|
});
|
|
@@ -434,50 +523,57 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
434
523
|
});
|
|
435
524
|
obj.on('mouseout', function (e) {
|
|
436
525
|
t.mouseOutGraphic(drawExtData.id, e);
|
|
437
|
-
});
|
|
526
|
+
}); //区别点和圆的经纬度数据处理
|
|
438
527
|
|
|
439
|
-
//区别点和圆的经纬度数据处理
|
|
440
528
|
var _t$dealData = t.dealData(obj),
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
529
|
+
lnglatAry = _t$dealData.lnglatAry,
|
|
530
|
+
_extent = _t$dealData._extent,
|
|
531
|
+
path = _t$dealData.path; //处理返回数据
|
|
532
|
+
|
|
533
|
+
|
|
445
534
|
switch (drawExtData.type) {
|
|
446
535
|
case 'point':
|
|
447
536
|
backobj.geometry.x = obj.getPosition().getLng();
|
|
448
537
|
backobj.geometry.y = obj.getPosition().getLat();
|
|
449
538
|
break;
|
|
539
|
+
|
|
450
540
|
case 'polyline':
|
|
451
541
|
backobj.lnglatAry = lnglatAry;
|
|
452
542
|
backobj.geometry.paths = path;
|
|
453
543
|
backobj.geometry._extent = _extent;
|
|
454
544
|
backobj.distance = obj.getLength();
|
|
455
545
|
break;
|
|
546
|
+
|
|
456
547
|
case 'polygon':
|
|
457
548
|
backobj.area = obj.getArea();
|
|
458
549
|
backobj.lnglatAry = lnglatAry;
|
|
459
550
|
backobj.geometry.rings = path;
|
|
460
551
|
backobj.geometry._extent = _extent;
|
|
461
552
|
break;
|
|
553
|
+
|
|
462
554
|
case 'rectangle':
|
|
463
555
|
backobj.area = obj.getArea();
|
|
464
556
|
backobj.lnglatAry = lnglatAry;
|
|
465
557
|
backobj.geometry.rings = path;
|
|
466
558
|
backobj.geometry._extent = _extent;
|
|
467
559
|
break;
|
|
560
|
+
|
|
468
561
|
case 'circle':
|
|
469
562
|
backobj.geometry.x = obj.getCenter().getLng();
|
|
470
563
|
backobj.geometry.y = obj.getCenter().getLat();
|
|
471
564
|
backobj.geometry.radius = obj.getRadius();
|
|
472
565
|
backobj.area = Math.PI * Math.pow(backobj.geometry.radius, 2);
|
|
473
566
|
break;
|
|
474
|
-
}
|
|
475
|
-
|
|
567
|
+
} //恢复鼠标默认样式
|
|
568
|
+
|
|
569
|
+
|
|
476
570
|
t.state.gis.setDefaultCursor();
|
|
477
571
|
t.mousetool.close();
|
|
572
|
+
|
|
478
573
|
if ('drawEnd' in t.props) {
|
|
479
574
|
t.props.drawEnd(backobj);
|
|
480
575
|
}
|
|
576
|
+
|
|
481
577
|
if (((_t$frameSelectProps$b = t.frameSelectProps[backobj.id]) === null || _t$frameSelectProps$b === void 0 ? void 0 : _t$frameSelectProps$b.callback) instanceof Function) {
|
|
482
578
|
t.frameSelectProps[backobj.id].callback(backobj);
|
|
483
579
|
}
|
|
@@ -494,41 +590,46 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
494
590
|
}
|
|
495
591
|
});
|
|
496
592
|
t.initPropsForUser();
|
|
497
|
-
}
|
|
498
|
-
|
|
593
|
+
} // 初始化对外方法
|
|
594
|
+
|
|
499
595
|
}, {
|
|
500
596
|
key: "initPropsForUser",
|
|
501
597
|
value: function initPropsForUser() {
|
|
502
598
|
var t = this;
|
|
599
|
+
|
|
503
600
|
t.state.gis["frameSelect"] = function () {
|
|
504
601
|
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
505
602
|
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
506
603
|
return t.frameSelect(obj, callback);
|
|
507
604
|
};
|
|
605
|
+
|
|
508
606
|
t.state.gis["clearFrameSelect"] = function () {
|
|
509
607
|
return t.clearFrameSelect();
|
|
510
608
|
};
|
|
609
|
+
|
|
511
610
|
t.state.gis["clearFrameSelectById"] = function (id) {
|
|
512
611
|
return t.clearFrameSelectById(id);
|
|
513
612
|
};
|
|
514
|
-
}
|
|
515
|
-
|
|
613
|
+
} // 框选
|
|
614
|
+
|
|
516
615
|
}, {
|
|
517
616
|
key: "frameSelect",
|
|
518
617
|
value: function frameSelect(_ref3, callback) {
|
|
519
618
|
var geometryType = _ref3.geometryType,
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
619
|
+
_ref3$parameter = _ref3.parameter,
|
|
620
|
+
parameter = _ref3$parameter === void 0 ? {} : _ref3$parameter,
|
|
621
|
+
_ref3$data = _ref3.data,
|
|
622
|
+
data = _ref3$data === void 0 ? {} : _ref3$data;
|
|
623
|
+
|
|
524
624
|
if (!['polygon', 'circle', 'rectangle'].includes(geometryType)) {
|
|
525
625
|
message.warn("传入的类型不支持框选!");
|
|
526
626
|
return false;
|
|
527
627
|
}
|
|
628
|
+
|
|
528
629
|
var t = this;
|
|
529
630
|
var params = {},
|
|
530
|
-
|
|
531
|
-
|
|
631
|
+
type = geometryType || 'polygon',
|
|
632
|
+
id = data.id || "frameSelectFeature_".concat(Math.random());
|
|
532
633
|
params.color = parameter.color || 'red';
|
|
533
634
|
params.lineColor = parameter.lineColor || 'red';
|
|
534
635
|
params.lineOpacity = parameter.lineOpacity || 1;
|
|
@@ -547,17 +648,18 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
547
648
|
id: id,
|
|
548
649
|
type: geometryType
|
|
549
650
|
};
|
|
550
|
-
}
|
|
551
|
-
|
|
651
|
+
} // 清除框选
|
|
652
|
+
|
|
552
653
|
}, {
|
|
553
654
|
key: "clearFrameSelect",
|
|
554
655
|
value: function clearFrameSelect() {
|
|
555
656
|
for (var key in this.frameSelectProps) {
|
|
556
657
|
this.removeGraphic(this.frameSelectProps[key].id, this.frameSelectProps[key].type);
|
|
557
658
|
}
|
|
659
|
+
|
|
558
660
|
this.frameSelectProps = {};
|
|
559
|
-
}
|
|
560
|
-
|
|
661
|
+
} // 清除框选ById
|
|
662
|
+
|
|
561
663
|
}, {
|
|
562
664
|
key: "clearFrameSelectById",
|
|
563
665
|
value: function clearFrameSelectById(id) {
|
|
@@ -568,6 +670,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
568
670
|
/*
|
|
569
671
|
切换地图矢量图和卫星图背景
|
|
570
672
|
*/
|
|
673
|
+
|
|
571
674
|
}, {
|
|
572
675
|
key: "setMapType",
|
|
573
676
|
value: function setMapType(type) {
|
|
@@ -579,60 +682,64 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
579
682
|
map: this.state.gis
|
|
580
683
|
});
|
|
581
684
|
}
|
|
685
|
+
|
|
582
686
|
if (this.satellite) {
|
|
583
687
|
switch (type) {
|
|
584
688
|
case 'sl':
|
|
585
689
|
this.satellite.hide();
|
|
586
690
|
this.roadNet.hide();
|
|
587
691
|
break;
|
|
692
|
+
|
|
588
693
|
case 'wx':
|
|
589
694
|
this.satellite.show();
|
|
590
695
|
this.roadNet.show();
|
|
591
696
|
break;
|
|
592
697
|
}
|
|
593
698
|
}
|
|
594
|
-
}
|
|
595
|
-
|
|
699
|
+
} //增加图片图层
|
|
700
|
+
|
|
596
701
|
}, {
|
|
597
702
|
key: "imageUrlOverlay",
|
|
598
703
|
value: function imageUrlOverlay(imageAry) {
|
|
599
704
|
var t = this;
|
|
600
705
|
imageAry.map(function (item, index) {
|
|
601
706
|
var sw = item.sw,
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
707
|
+
ne = item.ne,
|
|
708
|
+
url = item.url,
|
|
709
|
+
opacity = item.opacity,
|
|
710
|
+
displayOnMinLevel = item.displayOnMinLevel,
|
|
711
|
+
displayOnMaxLevel = item.displayOnMaxLevel;
|
|
712
|
+
|
|
607
713
|
if (!url) {
|
|
608
714
|
console.warn("\u56FE\u7247\u56FE\u5C42url\u6570\u636E\u9519\u8BEF");
|
|
609
715
|
return false;
|
|
610
716
|
}
|
|
717
|
+
|
|
611
718
|
if (sw && ne && Array.isArray(sw) && Array.isArray(ne) && sw[0] && sw[1] && ne[0] && ne[1]) {
|
|
612
719
|
var swnep = new AMap.Bounds(sw, ne),
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
720
|
+
imageUrlOverlay = new AMap.ImageLayer({
|
|
721
|
+
url: url,
|
|
722
|
+
zooms: [displayOnMinLevel || 3, displayOnMaxLevel || 18],
|
|
723
|
+
bounds: swnep
|
|
724
|
+
});
|
|
618
725
|
t.state.gis.setLayers([new AMap.TileLayer(), imageUrlOverlay]);
|
|
619
726
|
} else {
|
|
620
727
|
console.warn("\u533A\u57DF\u7ECF\u7EAC\u5EA6sw/ne\u6570\u636E\u9519\u8BEF");
|
|
621
728
|
return false;
|
|
622
729
|
}
|
|
623
730
|
});
|
|
624
|
-
}
|
|
625
|
-
|
|
731
|
+
} //清空地图所有图元
|
|
732
|
+
|
|
626
733
|
}, {
|
|
627
734
|
key: "clearAll",
|
|
628
735
|
value: function clearAll() {
|
|
629
|
-
var t = this;
|
|
630
|
-
|
|
736
|
+
var t = this; //先清除所有标记
|
|
737
|
+
|
|
631
738
|
t.clusterObj.clearMarkers();
|
|
632
|
-
t.state.gis.clearMap();
|
|
633
|
-
|
|
634
|
-
t.GM.clearAll();
|
|
635
|
-
|
|
739
|
+
t.state.gis.clearMap(); //清空所有缓存图元数据
|
|
740
|
+
|
|
741
|
+
t.GM.clearAll(); //清空历史数据记录
|
|
742
|
+
|
|
636
743
|
t.setState({
|
|
637
744
|
pointIds: [],
|
|
638
745
|
lineIds: [],
|
|
@@ -650,22 +757,24 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
650
757
|
}
|
|
651
758
|
/*set方法*/
|
|
652
759
|
//设置地图中心位置 lng/经度 lat/纬度
|
|
760
|
+
|
|
653
761
|
}, {
|
|
654
762
|
key: "setCenter",
|
|
655
763
|
value: function setCenter(gt) {
|
|
656
764
|
var t = this;
|
|
765
|
+
|
|
657
766
|
if (!t.state.gis) {
|
|
658
767
|
return;
|
|
659
768
|
}
|
|
769
|
+
|
|
660
770
|
if (gt && gt instanceof Array && gt.length == 2) {
|
|
661
|
-
t.state.gis.setCenter(gt);
|
|
662
|
-
// t.setState({center:gt});
|
|
771
|
+
t.state.gis.setCenter(gt); // t.setState({center:gt});
|
|
663
772
|
} else {
|
|
664
|
-
t.state.gis.setCenter([116.400433, 39.906705]);
|
|
665
|
-
// t.setState({center:[117.468021,39.890092]});
|
|
773
|
+
t.state.gis.setCenter([116.400433, 39.906705]); // t.setState({center:[117.468021,39.890092]});
|
|
666
774
|
}
|
|
667
775
|
}
|
|
668
776
|
/*地图区域限制*/
|
|
777
|
+
|
|
669
778
|
}, {
|
|
670
779
|
key: "setAreaRestriction",
|
|
671
780
|
value: function setAreaRestriction(sw_ne) {
|
|
@@ -676,13 +785,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
676
785
|
key: "clearAreaRestriction",
|
|
677
786
|
value: function clearAreaRestriction() {
|
|
678
787
|
this.state.gis.clearLimitBounds();
|
|
679
|
-
}
|
|
680
|
-
|
|
788
|
+
} //展示路况信息
|
|
789
|
+
|
|
681
790
|
}, {
|
|
682
791
|
key: "openTrafficInfo",
|
|
683
792
|
value: function openTrafficInfo() {
|
|
684
|
-
var t = this;
|
|
685
|
-
|
|
793
|
+
var t = this; //判断是否已经创建路况对象
|
|
794
|
+
|
|
686
795
|
if (this.trafficLayer) {
|
|
687
796
|
this.trafficLayer.show();
|
|
688
797
|
} else {
|
|
@@ -693,44 +802,51 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
693
802
|
t.state.gis.add(trafficLayer);
|
|
694
803
|
this.trafficLayer = trafficLayer;
|
|
695
804
|
}
|
|
696
|
-
}
|
|
697
|
-
|
|
805
|
+
} //隐藏路况信息
|
|
806
|
+
|
|
698
807
|
}, {
|
|
699
808
|
key: "hideTrafficInfo",
|
|
700
809
|
value: function hideTrafficInfo() {
|
|
701
810
|
if (this.trafficLayer) {
|
|
702
811
|
this.trafficLayer.hide();
|
|
703
812
|
}
|
|
704
|
-
}
|
|
705
|
-
|
|
813
|
+
} //设置指定图元展示 高德只有zoom和center全适应,单适应暂时无法实现
|
|
814
|
+
|
|
706
815
|
}, {
|
|
707
816
|
key: "setVisiblePoints",
|
|
708
817
|
value: function setVisiblePoints(obj) {
|
|
709
818
|
var t = this;
|
|
710
819
|
var ids = [];
|
|
820
|
+
|
|
711
821
|
switch (obj.fitView) {
|
|
712
822
|
case 'point':
|
|
713
823
|
t.state.gis.setFitView(t.state.gis.getAllOverlays('marker'));
|
|
714
824
|
break;
|
|
825
|
+
|
|
715
826
|
case 'line':
|
|
716
827
|
t.state.gis.setFitView(t.state.gis.getAllOverlays('polyline'));
|
|
717
828
|
break;
|
|
829
|
+
|
|
718
830
|
case 'polygon':
|
|
719
831
|
t.state.gis.setFitView(t.state.gis.getAllOverlays('polygon'));
|
|
720
832
|
break;
|
|
833
|
+
|
|
721
834
|
case 'circle':
|
|
722
835
|
t.state.gis.setFitView(t.state.gis.getAllOverlays('circle'));
|
|
723
836
|
break;
|
|
837
|
+
|
|
724
838
|
case 'all':
|
|
725
839
|
var pts = [].concat(_toConsumableArray(t.state.gis.getAllOverlays('marker')), _toConsumableArray(t.state.gis.getAllOverlays('polyline')), _toConsumableArray(t.state.gis.getAllOverlays('polygon')), _toConsumableArray(t.state.gis.getAllOverlays('circle')));
|
|
726
840
|
t.state.gis.setFitView(pts);
|
|
727
841
|
break;
|
|
842
|
+
|
|
728
843
|
default:
|
|
729
844
|
if (obj.fitView instanceof Array) {
|
|
730
845
|
ids = obj.fitView;
|
|
731
846
|
} else if (typeof obj.fitView === 'string') {
|
|
732
847
|
ids = obj.fitView.split(',');
|
|
733
848
|
}
|
|
849
|
+
|
|
734
850
|
if (ids[0] instanceof Array) {
|
|
735
851
|
// let l = new AMap.LngLat(ids[0][0],ids[0][1]),
|
|
736
852
|
// r = new AMap.LngLat(ids[1][0],ids[1][1]);
|
|
@@ -745,17 +861,18 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
745
861
|
} else {
|
|
746
862
|
t.state.gis.setFitView(this.GM.getMoreGraphic(ids));
|
|
747
863
|
}
|
|
864
|
+
|
|
748
865
|
break;
|
|
749
866
|
}
|
|
750
|
-
}
|
|
751
|
-
|
|
867
|
+
} //设置地图比例尺
|
|
868
|
+
|
|
752
869
|
}, {
|
|
753
870
|
key: "setZoomLevel",
|
|
754
871
|
value: function setZoomLevel(zoom) {
|
|
755
872
|
var t = this;
|
|
756
873
|
t.state.gis.setZoom(zoom);
|
|
757
|
-
}
|
|
758
|
-
|
|
874
|
+
} //获取当前地图的中心位置
|
|
875
|
+
|
|
759
876
|
}, {
|
|
760
877
|
key: "getCurrentCenter",
|
|
761
878
|
value: function getCurrentCenter() {
|
|
@@ -764,22 +881,22 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
764
881
|
lat: t.state.gis.getCenter().lat,
|
|
765
882
|
lng: t.state.gis.getCenter().lng
|
|
766
883
|
};
|
|
767
|
-
}
|
|
768
|
-
|
|
884
|
+
} //获取当前比例尺
|
|
885
|
+
|
|
769
886
|
}, {
|
|
770
887
|
key: "getZoomLevel",
|
|
771
888
|
value: function getZoomLevel() {
|
|
772
889
|
var t = this;
|
|
773
890
|
return t.state.gis.getZoom();
|
|
774
|
-
}
|
|
775
|
-
|
|
891
|
+
} //获取当前地图边框左右边角经纬度,中心点位置,和比例尺,半径距离
|
|
892
|
+
|
|
776
893
|
}, {
|
|
777
894
|
key: "getMapExtent",
|
|
778
895
|
value: function getMapExtent() {
|
|
779
896
|
var t = this;
|
|
780
897
|
var gis = t.state.gis;
|
|
781
898
|
var northEast = (this.props.viewMode == '3D' ? gis.getBounds().toBounds() : gis.getBounds()).getNorthEast(),
|
|
782
|
-
|
|
899
|
+
southWest = (this.props.viewMode == '3D' ? gis.getBounds().toBounds() : gis.getBounds()).getSouthWest();
|
|
783
900
|
var obj = {
|
|
784
901
|
mapSize: gis.getSize(),
|
|
785
902
|
nowCenter: t.getCurrentCenter(),
|
|
@@ -795,13 +912,14 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
795
912
|
};
|
|
796
913
|
obj.radius = t.calculatePointsDistance([obj.nowCenter.lng, obj.nowCenter.lat], [northEast.getLng(), northEast.getLat()]);
|
|
797
914
|
return obj;
|
|
798
|
-
}
|
|
799
|
-
|
|
915
|
+
} //聚合地图图元(arg为空时聚合全部点)
|
|
916
|
+
|
|
800
917
|
}, {
|
|
801
918
|
key: "cluster",
|
|
802
919
|
value: function cluster(arg) {
|
|
803
920
|
var t = this;
|
|
804
921
|
var ary = [];
|
|
922
|
+
|
|
805
923
|
if (!arg) {
|
|
806
924
|
var pointIds = t.state.pointIds;
|
|
807
925
|
ary = pointIds;
|
|
@@ -812,6 +930,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
812
930
|
ary = arg.split(',');
|
|
813
931
|
}
|
|
814
932
|
}
|
|
933
|
+
|
|
815
934
|
ary = ary.filter(function (item, index) {
|
|
816
935
|
return !(t.GM.getGraphicParam(item).attributes.config || {}).isAnimation;
|
|
817
936
|
});
|
|
@@ -819,8 +938,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
819
938
|
return !item && item != 0 ? false : true;
|
|
820
939
|
});
|
|
821
940
|
t.clusterObj.setMarkers(ms);
|
|
822
|
-
}
|
|
823
|
-
|
|
941
|
+
} // 清除聚合
|
|
942
|
+
|
|
824
943
|
}, {
|
|
825
944
|
key: "removeCluster",
|
|
826
945
|
value: function removeCluster(arg) {
|
|
@@ -829,85 +948,93 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
829
948
|
t.clusterObj.removeMarkers(t.clusterObj.getMarkers());
|
|
830
949
|
ids.map(function (id) {
|
|
831
950
|
t.GM.removeGraphic(id);
|
|
832
|
-
});
|
|
833
|
-
|
|
951
|
+
}); // 重新加点
|
|
952
|
+
|
|
834
953
|
t.addPoint(t.props.mapPoints);
|
|
835
|
-
}
|
|
836
|
-
|
|
954
|
+
} //展示比例尺
|
|
955
|
+
|
|
837
956
|
}, {
|
|
838
957
|
key: "showControl",
|
|
839
958
|
value: function showControl(props) {
|
|
840
959
|
var t = this,
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
960
|
+
location = 'RT',
|
|
961
|
+
offset = null,
|
|
962
|
+
scaleOffset = null;
|
|
844
963
|
var config = props || t.props;
|
|
964
|
+
|
|
845
965
|
if (t.scaleControl) {
|
|
846
966
|
t.state.gis.removeControl(t.scaleControl);
|
|
847
967
|
}
|
|
968
|
+
|
|
848
969
|
if (t.navigationControl) {
|
|
849
970
|
t.state.gis.removeControl(t.navigationControl);
|
|
850
971
|
}
|
|
972
|
+
|
|
851
973
|
if (config.showControl.location) {
|
|
852
974
|
location = t.AnchorConstant[config.showControl.location];
|
|
853
975
|
}
|
|
976
|
+
|
|
854
977
|
if (config.showControl.offset && config.showControl.offset.length > 0) {
|
|
855
978
|
offset = new AMap.Pixel(config.showControl.offset[0], config.showControl.offset[1]);
|
|
856
979
|
scaleOffset = new AMap.Pixel(config.showControl.offset[0] + 70, config.showControl.offset[1]);
|
|
857
|
-
}
|
|
858
|
-
|
|
980
|
+
} // 添加比例尺
|
|
981
|
+
|
|
982
|
+
|
|
859
983
|
var control = new AMap.Scale({
|
|
860
984
|
position: location,
|
|
861
985
|
offset: scaleOffset
|
|
862
986
|
});
|
|
863
987
|
t.state.gis.addControl(control);
|
|
864
|
-
t.scaleControl = control;
|
|
865
|
-
|
|
988
|
+
t.scaleControl = control; // 包含平移和缩放按钮
|
|
989
|
+
|
|
866
990
|
var navigation = new AMap.ToolBar({
|
|
867
991
|
position: location,
|
|
868
992
|
offset: offset
|
|
869
993
|
});
|
|
870
994
|
t.state.gis.addControl(navigation);
|
|
871
995
|
t.navigationControl = navigation;
|
|
872
|
-
}
|
|
873
|
-
|
|
996
|
+
} // 移除比例尺
|
|
997
|
+
|
|
874
998
|
}, {
|
|
875
999
|
key: "removeControl",
|
|
876
1000
|
value: function removeControl() {
|
|
877
1001
|
var t = this;
|
|
1002
|
+
|
|
878
1003
|
if (t.scaleControl) {
|
|
879
1004
|
t.state.gis.removeControl(t.scaleControl);
|
|
880
1005
|
t.scaleControl = null;
|
|
881
1006
|
}
|
|
1007
|
+
|
|
882
1008
|
if (t.navigationControl) {
|
|
883
1009
|
t.state.gis.removeControl(t.navigationControl);
|
|
884
1010
|
t.navigationControl = null;
|
|
885
1011
|
}
|
|
886
|
-
}
|
|
887
|
-
|
|
1012
|
+
} //展示地图切换控件
|
|
1013
|
+
|
|
888
1014
|
}, {
|
|
889
1015
|
key: "showMapTypeControl",
|
|
890
1016
|
value: function showMapTypeControl(props) {
|
|
891
1017
|
var t = this,
|
|
892
|
-
|
|
893
|
-
|
|
1018
|
+
location = 'RT',
|
|
1019
|
+
offset = null;
|
|
894
1020
|
var config = props || t.props;
|
|
1021
|
+
|
|
895
1022
|
if (t.mapTypeControl) {
|
|
896
1023
|
t.state.gis.removeControl(t.mapTypeControl);
|
|
897
1024
|
}
|
|
1025
|
+
|
|
898
1026
|
if (config.satelliteSwitch.location) {
|
|
899
1027
|
location = t.AnchorConstant[config.satelliteSwitch.location];
|
|
900
|
-
}
|
|
1028
|
+
} // 地图切换控件
|
|
1029
|
+
|
|
901
1030
|
|
|
902
|
-
// 地图切换控件
|
|
903
1031
|
var control = new AMap.MapType({
|
|
904
1032
|
position: location,
|
|
905
1033
|
offset: offset
|
|
906
1034
|
});
|
|
907
1035
|
t.state.gis.addControl(control);
|
|
908
|
-
t.mapTypeControl = control;
|
|
1036
|
+
t.mapTypeControl = control; // TODO,MapType没有这些属性,所以下面定位和偏移不生效,手动修改
|
|
909
1037
|
|
|
910
|
-
// TODO,MapType没有这些属性,所以下面定位和偏移不生效,手动修改
|
|
911
1038
|
function reloaction() {
|
|
912
1039
|
if (location == 'RT') {
|
|
913
1040
|
$('div.amap-maptypecontrol').css({
|
|
@@ -938,6 +1065,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
938
1065
|
top: 'inherit'
|
|
939
1066
|
});
|
|
940
1067
|
}
|
|
1068
|
+
|
|
941
1069
|
if (config.satelliteSwitch.offset && config.satelliteSwitch.offset.length > 0) {
|
|
942
1070
|
if (location == 'RT') {
|
|
943
1071
|
$('div.amap-maptypecontrol').css({
|
|
@@ -970,39 +1098,47 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
970
1098
|
}
|
|
971
1099
|
}
|
|
972
1100
|
}
|
|
1101
|
+
|
|
973
1102
|
if ($('div.amap-maptypecontrol').length > 0) {
|
|
974
1103
|
reloaction();
|
|
975
1104
|
} else {
|
|
976
1105
|
var timer = setInterval(function () {
|
|
977
1106
|
console.log(123);
|
|
1107
|
+
|
|
978
1108
|
if ($('div.amap-maptypecontrol').length > 0) {
|
|
979
1109
|
clearInterval(timer);
|
|
980
1110
|
reloaction();
|
|
981
1111
|
}
|
|
982
1112
|
}, 500);
|
|
983
1113
|
}
|
|
984
|
-
}
|
|
985
|
-
|
|
1114
|
+
} //获取图元数据
|
|
1115
|
+
|
|
986
1116
|
}, {
|
|
987
1117
|
key: "getGraphic",
|
|
988
1118
|
value: function getGraphic(id) {
|
|
989
1119
|
var t = this;
|
|
1120
|
+
|
|
990
1121
|
if (!id) {
|
|
991
1122
|
return false;
|
|
992
1123
|
}
|
|
1124
|
+
|
|
993
1125
|
var gp = t.GM.getGraphicParam(id);
|
|
994
1126
|
var gg = t.GM.getGraphic(id);
|
|
1127
|
+
|
|
995
1128
|
if (!gg) {
|
|
996
1129
|
return false;
|
|
997
1130
|
}
|
|
1131
|
+
|
|
998
1132
|
var p = {},
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1133
|
+
pts = [],
|
|
1134
|
+
lng = 0,
|
|
1135
|
+
lat = 0;
|
|
1136
|
+
|
|
1002
1137
|
var _t$dealData2 = t.dealData(gg),
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1138
|
+
lnglatAry = _t$dealData2.lnglatAry,
|
|
1139
|
+
_extent = _t$dealData2._extent,
|
|
1140
|
+
path = _t$dealData2.path;
|
|
1141
|
+
|
|
1006
1142
|
switch (gp.geometryType) {
|
|
1007
1143
|
case 'point':
|
|
1008
1144
|
lng = gg.getPosition().getLng();
|
|
@@ -1023,6 +1159,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1023
1159
|
})
|
|
1024
1160
|
});
|
|
1025
1161
|
break;
|
|
1162
|
+
|
|
1026
1163
|
case 'polyline':
|
|
1027
1164
|
pts = gg.getPath().map(function (item, index) {
|
|
1028
1165
|
return [item.lng, item.lat];
|
|
@@ -1042,6 +1179,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1042
1179
|
})
|
|
1043
1180
|
});
|
|
1044
1181
|
break;
|
|
1182
|
+
|
|
1045
1183
|
case 'polygon':
|
|
1046
1184
|
pts = gg.getPath().map(function (item, index) {
|
|
1047
1185
|
return [item.lng, item.lat];
|
|
@@ -1061,6 +1199,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1061
1199
|
})
|
|
1062
1200
|
});
|
|
1063
1201
|
break;
|
|
1202
|
+
|
|
1064
1203
|
case 'circle':
|
|
1065
1204
|
lng = gg.getCenter().getLng();
|
|
1066
1205
|
lat = gg.getCenter().getLat();
|
|
@@ -1085,23 +1224,24 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1085
1224
|
});
|
|
1086
1225
|
break;
|
|
1087
1226
|
}
|
|
1227
|
+
|
|
1088
1228
|
return p;
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1229
|
+
} //显示隐藏的图元
|
|
1230
|
+
|
|
1091
1231
|
}, {
|
|
1092
1232
|
key: "showGraphicById",
|
|
1093
1233
|
value: function showGraphicById(id) {
|
|
1094
1234
|
var t = this;
|
|
1095
1235
|
t.GM.getGraphic(id).show();
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1236
|
+
} //隐藏图元
|
|
1237
|
+
|
|
1098
1238
|
}, {
|
|
1099
1239
|
key: "hideGraphicById",
|
|
1100
1240
|
value: function hideGraphicById(id) {
|
|
1101
1241
|
var t = this;
|
|
1102
1242
|
t.GM.getGraphic(id).hide();
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1243
|
+
} //画出对应边界线 name区域名
|
|
1244
|
+
|
|
1105
1245
|
}, {
|
|
1106
1246
|
key: "addBaiduBoundary",
|
|
1107
1247
|
value: function addBaiduBoundary(bdNames) {
|
|
@@ -1129,6 +1269,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1129
1269
|
key: "removeBaiduBoundary",
|
|
1130
1270
|
value: function removeBaiduBoundary(removedBDNames) {
|
|
1131
1271
|
var _this2 = this;
|
|
1272
|
+
|
|
1132
1273
|
var removedBDIds = this.state.boundaryInfo.filter(function (item) {
|
|
1133
1274
|
return removedBDNames.indexOf(item.name) > -1;
|
|
1134
1275
|
}).map(function (item) {
|
|
@@ -1154,28 +1295,33 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1154
1295
|
visible: true,
|
|
1155
1296
|
opacity: 0.7
|
|
1156
1297
|
};
|
|
1298
|
+
|
|
1157
1299
|
if (d.config) {
|
|
1158
1300
|
cg = _objectSpread(_objectSpread({}, cg), d.config);
|
|
1159
1301
|
}
|
|
1302
|
+
|
|
1160
1303
|
var option = {
|
|
1161
1304
|
radius: cg.radius,
|
|
1162
1305
|
opacity: [0, cg.opacity]
|
|
1163
1306
|
};
|
|
1307
|
+
|
|
1164
1308
|
if (cg.gradient) {
|
|
1165
1309
|
option.gradient = cg.gradient;
|
|
1166
1310
|
}
|
|
1311
|
+
|
|
1167
1312
|
t.heatmap.setOptions(option);
|
|
1168
1313
|
t.heatmap.setDataSet({
|
|
1169
1314
|
max: cg.max,
|
|
1170
1315
|
data: d.data || []
|
|
1171
1316
|
});
|
|
1317
|
+
|
|
1172
1318
|
if (cg.visible) {
|
|
1173
1319
|
t.heatmap.show();
|
|
1174
1320
|
} else {
|
|
1175
1321
|
t.heatmap.hide();
|
|
1176
1322
|
}
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1323
|
+
} // 信息窗体
|
|
1324
|
+
|
|
1179
1325
|
}, {
|
|
1180
1326
|
key: "infoWindow",
|
|
1181
1327
|
value: function infoWindow() {
|
|
@@ -1185,37 +1331,43 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1185
1331
|
width: 300,
|
|
1186
1332
|
height: 172
|
|
1187
1333
|
};
|
|
1334
|
+
|
|
1188
1335
|
if (d.config) {
|
|
1189
1336
|
cg = _objectSpread(_objectSpread({}, cg), d.config);
|
|
1190
1337
|
}
|
|
1338
|
+
|
|
1191
1339
|
var sContent = document.createElement('div');
|
|
1192
1340
|
var infowindow = new AMap.InfoWindow({
|
|
1193
1341
|
// isCustom: true,
|
|
1194
1342
|
content: sContent
|
|
1195
1343
|
});
|
|
1196
1344
|
infowindow.setSize(new AMap.Size(cg.width, cg.height + 20));
|
|
1345
|
+
|
|
1197
1346
|
if (d.onClose instanceof Function) {
|
|
1198
1347
|
infowindow.on("close", function (e) {
|
|
1199
1348
|
d.onClose(e);
|
|
1200
1349
|
});
|
|
1201
1350
|
}
|
|
1351
|
+
|
|
1202
1352
|
if (d.lat && d.lng && d.content) {
|
|
1203
1353
|
(0, _reactDom.render)(d.content, sContent);
|
|
1204
1354
|
infowindow.open(t.state.gis, [d.lng, d.lat]);
|
|
1205
1355
|
} else {
|
|
1206
1356
|
infowindow.close();
|
|
1207
1357
|
}
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1358
|
+
} //添加海量点
|
|
1359
|
+
|
|
1210
1360
|
}, {
|
|
1211
1361
|
key: "addPointCollection",
|
|
1212
1362
|
value: function addPointCollection() {
|
|
1213
1363
|
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1214
1364
|
var t = this;
|
|
1365
|
+
|
|
1215
1366
|
if (!$("#".concat(t.state.mapId, " .amap-layers")).length) {
|
|
1216
1367
|
if (t.pointCollectTimer) {
|
|
1217
1368
|
clearTimeout(t.pointCollectTimer);
|
|
1218
1369
|
}
|
|
1370
|
+
|
|
1219
1371
|
t.pointCollectTimer = setTimeout(function () {
|
|
1220
1372
|
t.addPointCollection(data);
|
|
1221
1373
|
}, 50);
|
|
@@ -1230,6 +1382,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1230
1382
|
pointCollectionHtml.className = 'vtx_gmap_html_pointCollection_a';
|
|
1231
1383
|
$($("#".concat(t.state.mapId, " .amap-layers"))[0]).append(pointCollectionHtml);
|
|
1232
1384
|
} else {}
|
|
1385
|
+
|
|
1233
1386
|
data.map(function (item, index) {
|
|
1234
1387
|
var d = item || {};
|
|
1235
1388
|
var points = (d.points || []).map(function (d, i) {
|
|
@@ -1253,8 +1406,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1253
1406
|
VotexpointCollection.draw();
|
|
1254
1407
|
});
|
|
1255
1408
|
}
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1409
|
+
} //更新海量点
|
|
1410
|
+
|
|
1258
1411
|
}, {
|
|
1259
1412
|
key: "updatePointCollection",
|
|
1260
1413
|
value: function updatePointCollection() {
|
|
@@ -1279,8 +1432,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1279
1432
|
}
|
|
1280
1433
|
});
|
|
1281
1434
|
});
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1435
|
+
} //删除海量点
|
|
1436
|
+
|
|
1284
1437
|
}, {
|
|
1285
1438
|
key: "clearPointCollection",
|
|
1286
1439
|
value: function clearPointCollection() {
|
|
@@ -1293,8 +1446,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1293
1446
|
}
|
|
1294
1447
|
});
|
|
1295
1448
|
});
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1449
|
+
} //删除全部海量点
|
|
1450
|
+
|
|
1298
1451
|
}, {
|
|
1299
1452
|
key: "clearAllPointCollection",
|
|
1300
1453
|
value: function clearAllPointCollection() {
|
|
@@ -1302,26 +1455,31 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1302
1455
|
t.morepoints.map(function (item, index) {
|
|
1303
1456
|
item.value.clear();
|
|
1304
1457
|
});
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1458
|
+
} //添加点
|
|
1459
|
+
|
|
1307
1460
|
}, {
|
|
1308
1461
|
key: "addPoint",
|
|
1309
1462
|
value: function addPoint(mapPoints, type) {
|
|
1310
1463
|
var _this3 = this;
|
|
1464
|
+
|
|
1311
1465
|
var t = this;
|
|
1312
1466
|
var ps = [];
|
|
1467
|
+
|
|
1313
1468
|
var psids = _toConsumableArray(t.state.pointIds);
|
|
1469
|
+
|
|
1314
1470
|
mapPoints.map(function (item, index) {
|
|
1315
1471
|
//如果id重复,直接跳过不执行.
|
|
1316
1472
|
if (_this3.GM.isRepetition(item.id)) {
|
|
1317
1473
|
console.warn("\u52A0\u70B9id: ".concat(item.id, " \u91CD\u590D"));
|
|
1318
1474
|
return false;
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1475
|
+
} //点位数据不符合,直接跳过
|
|
1476
|
+
|
|
1477
|
+
|
|
1321
1478
|
if (!item.longitude || !item.latitude) {
|
|
1322
1479
|
console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
|
|
1323
1480
|
return false;
|
|
1324
1481
|
}
|
|
1482
|
+
|
|
1325
1483
|
var cg = {
|
|
1326
1484
|
width: 30,
|
|
1327
1485
|
height: 30,
|
|
@@ -1332,12 +1490,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1332
1490
|
markerContentY: -42,
|
|
1333
1491
|
zIndex: 100,
|
|
1334
1492
|
deg: 0
|
|
1335
|
-
};
|
|
1336
|
-
|
|
1493
|
+
}; //初始化默认数据
|
|
1494
|
+
|
|
1337
1495
|
if (item.config) {
|
|
1338
1496
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1497
|
+
} //覆盖物参数
|
|
1498
|
+
|
|
1499
|
+
|
|
1341
1500
|
var markerOption = {
|
|
1342
1501
|
position: new AMap.LngLat(item.longitude, item.latitude),
|
|
1343
1502
|
offset: new AMap.Pixel(cg.markerContentX, cg.markerContentY),
|
|
@@ -1350,14 +1509,16 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1350
1509
|
id: item.id
|
|
1351
1510
|
}
|
|
1352
1511
|
};
|
|
1512
|
+
|
|
1353
1513
|
if (cg.BAnimationType == 0) {
|
|
1354
1514
|
markerOption.animation = 'AMAP_ANIMATION_BOUNCE';
|
|
1355
1515
|
} else if (cg.BAnimationType == 1) {
|
|
1356
1516
|
markerOption.animation = 'AMAP_ANIMATION_DROP';
|
|
1357
1517
|
} else {
|
|
1358
1518
|
markerOption.animation = 'AMAP_ANIMATION_NONE';
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1519
|
+
} //判断html还是图片
|
|
1520
|
+
|
|
1521
|
+
|
|
1361
1522
|
if (!!item.markerContent) {
|
|
1362
1523
|
markerOption.content = item.markerContent;
|
|
1363
1524
|
} else {
|
|
@@ -1368,23 +1529,24 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1368
1529
|
size: new AMap.Size(cg.width, cg.height),
|
|
1369
1530
|
image: item.url,
|
|
1370
1531
|
imageSize: new AMap.Size(cg.width, cg.height)
|
|
1371
|
-
});
|
|
1372
|
-
// }else{
|
|
1532
|
+
}); // }else{
|
|
1373
1533
|
// markerOption.icon = item.url;
|
|
1374
1534
|
// }
|
|
1375
1535
|
}
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1536
|
+
} //是否展示label
|
|
1537
|
+
|
|
1538
|
+
|
|
1378
1539
|
if (item.canShowLabel) {
|
|
1379
1540
|
var labelClass = item.labelClass || 'label-content';
|
|
1380
1541
|
markerOption.label = {
|
|
1381
1542
|
content: "<div class='".concat(labelClass, "'>").concat(cg.labelContent, "</div>"),
|
|
1382
1543
|
offset: new AMap.Pixel(cg.labelPixelX, cg.labelPixelY)
|
|
1383
1544
|
};
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
//添加点击事件
|
|
1545
|
+
} //获得覆盖物对象
|
|
1546
|
+
|
|
1547
|
+
|
|
1548
|
+
var marker = new AMap.Marker(markerOption); //添加点击事件
|
|
1549
|
+
|
|
1388
1550
|
marker.on('click', function (e) {
|
|
1389
1551
|
t.clickGraphic(item.id, e);
|
|
1390
1552
|
});
|
|
@@ -1395,8 +1557,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1395
1557
|
t.mouseOutGraphic(item.id, e);
|
|
1396
1558
|
});
|
|
1397
1559
|
ps.push(marker);
|
|
1398
|
-
psids.push(item.id);
|
|
1399
|
-
|
|
1560
|
+
psids.push(item.id); //缓存图元的数据,偏于后期操作
|
|
1561
|
+
|
|
1400
1562
|
_this3.GM.setGraphic(item.id, marker).setGraphicParam(item.id, {
|
|
1401
1563
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1402
1564
|
other: item
|
|
@@ -1408,21 +1570,22 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1408
1570
|
y: item.latitude
|
|
1409
1571
|
}
|
|
1410
1572
|
});
|
|
1411
|
-
});
|
|
1412
|
-
|
|
1573
|
+
}); //统一加点
|
|
1574
|
+
|
|
1413
1575
|
t.state.gis.add(ps);
|
|
1576
|
+
|
|
1414
1577
|
if (type !== 'defined') {
|
|
1415
|
-
t.state.pointIds = psids;
|
|
1416
|
-
// t.setState({
|
|
1578
|
+
t.state.pointIds = psids; // t.setState({
|
|
1417
1579
|
// pointIds: psids
|
|
1418
1580
|
// })
|
|
1419
1581
|
}
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1582
|
+
} //更新点
|
|
1583
|
+
|
|
1422
1584
|
}, {
|
|
1423
1585
|
key: "updatePoint",
|
|
1424
1586
|
value: function updatePoint(mapPoints) {
|
|
1425
1587
|
var _this4 = this;
|
|
1588
|
+
|
|
1426
1589
|
var t = this;
|
|
1427
1590
|
mapPoints.map(function (item, index) {
|
|
1428
1591
|
//判断图元是否存在.
|
|
@@ -1431,10 +1594,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1431
1594
|
if (!item.longitude || !item.latitude) {
|
|
1432
1595
|
console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
|
|
1433
1596
|
return false;
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1597
|
+
} //获取原有的图元
|
|
1598
|
+
|
|
1599
|
+
|
|
1436
1600
|
var gc = _this4.GM.getGraphic(item.id),
|
|
1437
|
-
|
|
1601
|
+
isuserUrlLeft = false;
|
|
1602
|
+
|
|
1438
1603
|
var cg = {
|
|
1439
1604
|
width: 30,
|
|
1440
1605
|
height: 30,
|
|
@@ -1445,56 +1610,66 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1445
1610
|
zIndex: gc.getzIndex(),
|
|
1446
1611
|
labelClass: 'label-content'
|
|
1447
1612
|
};
|
|
1613
|
+
|
|
1448
1614
|
if (item.config) {
|
|
1449
1615
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1616
|
+
} //是否展示label
|
|
1617
|
+
|
|
1618
|
+
|
|
1452
1619
|
if (item.canShowLabel) {
|
|
1453
1620
|
cg.labelPixelX = cg.labelPixelX || gc.getLabel() ? gc.getLabel().offset.getX() : 0;
|
|
1454
1621
|
cg.labelPixelY = cg.labelPixelY || gc.getLabel() ? gc.getLabel().offset.getY() : 34;
|
|
1455
1622
|
cg.labelContent = cg.labelContent || gc.getLabel().offset.content;
|
|
1456
|
-
var labelClass = item.labelClass || 'label-content';
|
|
1457
|
-
|
|
1623
|
+
var labelClass = item.labelClass || 'label-content'; //更新label
|
|
1624
|
+
|
|
1458
1625
|
gc.setLabel({
|
|
1459
1626
|
content: "<div class='".concat(labelClass, "'>").concat(cg.labelContent, "</div>"),
|
|
1460
1627
|
offset: new AMap.Pixel(cg.labelPixelX, cg.labelPixelY)
|
|
1461
1628
|
});
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
//设置偏转角度
|
|
1466
|
-
|
|
1467
|
-
//设置点的标记添加顺序
|
|
1468
|
-
|
|
1469
|
-
//更新经纬度
|
|
1629
|
+
} //更新偏移量
|
|
1630
|
+
|
|
1631
|
+
|
|
1632
|
+
gc.setOffset(new AMap.Pixel(cg.markerContentX, cg.markerContentY)); //设置偏转角度
|
|
1633
|
+
|
|
1634
|
+
gc.setAngle(cg.deg); //设置点的标记添加顺序
|
|
1635
|
+
|
|
1636
|
+
gc.setzIndex(cg.zIndex); //更新经纬度
|
|
1637
|
+
|
|
1470
1638
|
if (!item.config.isAnimation) {
|
|
1471
1639
|
gc.setPosition(new AMap.LngLat(item.longitude, item.latitude));
|
|
1472
1640
|
} else {
|
|
1473
1641
|
var distance = t.calculatePointsDistance([item.longitude, item.latitude], [gc.getPosition().getLng(), gc.getPosition().getLat()]);
|
|
1642
|
+
|
|
1474
1643
|
if (distance > 0) {
|
|
1475
1644
|
var delay = item.config.animationDelay || 3;
|
|
1476
1645
|
var speed = distance / delay * 3600 / 1000;
|
|
1646
|
+
|
|
1477
1647
|
if (cg.autoRotation) {
|
|
1478
1648
|
var ddeg = t.rotateDeg(gc.getPosition(), [item.longitude, item.latitude]);
|
|
1649
|
+
|
|
1479
1650
|
if (item.urlleft && ddeg < -90 && ddeg > -270) {
|
|
1480
1651
|
ddeg += 180;
|
|
1481
1652
|
isuserUrlLeft = true;
|
|
1482
1653
|
}
|
|
1654
|
+
|
|
1483
1655
|
gc.setAngle(ddeg);
|
|
1484
1656
|
}
|
|
1657
|
+
|
|
1485
1658
|
gc.moveTo(new AMap.LngLat(item.longitude, item.latitude), speed, function (k) {
|
|
1486
1659
|
return k;
|
|
1487
1660
|
});
|
|
1488
1661
|
}
|
|
1489
1662
|
}
|
|
1663
|
+
|
|
1490
1664
|
if (item.config.BAnimationType == 0) {
|
|
1491
1665
|
gc.setAnimation('AMAP_ANIMATION_BOUNCE');
|
|
1492
1666
|
} else if (item.config.BAnimationType == 1) {
|
|
1493
1667
|
gc.setAnimation('AMAP_ANIMATION_DROP');
|
|
1494
1668
|
} else {
|
|
1495
1669
|
gc.setAnimation('AMAP_ANIMATION_NONE');
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1670
|
+
} //判断html还是图片
|
|
1671
|
+
|
|
1672
|
+
|
|
1498
1673
|
if (!!item.markerContent) {
|
|
1499
1674
|
gc.setContent(item.markerContent);
|
|
1500
1675
|
} else {
|
|
@@ -1507,13 +1682,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1507
1682
|
size: new AMap.Size(cg.width, cg.height),
|
|
1508
1683
|
image: item.url,
|
|
1509
1684
|
imageSize: new AMap.Size(cg.width, cg.height)
|
|
1510
|
-
}));
|
|
1511
|
-
// }else{
|
|
1685
|
+
})); // }else{
|
|
1512
1686
|
// gc.setIcon(item.url);
|
|
1513
1687
|
// }
|
|
1514
1688
|
}
|
|
1515
1689
|
}
|
|
1516
1690
|
}
|
|
1691
|
+
|
|
1517
1692
|
_this4.GM.setGraphicParam(item.id, {
|
|
1518
1693
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1519
1694
|
other: item
|
|
@@ -1530,27 +1705,32 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1530
1705
|
return false;
|
|
1531
1706
|
}
|
|
1532
1707
|
});
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1708
|
+
} //添加线
|
|
1709
|
+
|
|
1535
1710
|
}, {
|
|
1536
1711
|
key: "addLine",
|
|
1537
1712
|
value: function addLine(mapLines, type) {
|
|
1538
1713
|
var _this5 = this;
|
|
1714
|
+
|
|
1539
1715
|
var t = this;
|
|
1540
1716
|
var ls = [];
|
|
1541
|
-
|
|
1542
|
-
//遍历添加线(图元)
|
|
1717
|
+
|
|
1718
|
+
var lsids = _toConsumableArray(t.state.lineIds); //遍历添加线(图元)
|
|
1719
|
+
|
|
1720
|
+
|
|
1543
1721
|
mapLines.map(function (item, index) {
|
|
1544
1722
|
//如果id重复,直接跳过不执行.
|
|
1545
1723
|
if (_this5.GM.isRepetition(item.id)) {
|
|
1546
1724
|
console.warn("\u591A\u6298\u7EBFid: ".concat(item.id, " \u91CD\u590D"));
|
|
1547
1725
|
return false;
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1726
|
+
} //多折线点位数据不符合,直接跳过
|
|
1727
|
+
|
|
1728
|
+
|
|
1550
1729
|
if (!(item.paths && item.paths.length >= 2)) {
|
|
1551
1730
|
console.warn("\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF");
|
|
1552
1731
|
return false;
|
|
1553
1732
|
}
|
|
1733
|
+
|
|
1554
1734
|
var cg = {
|
|
1555
1735
|
color: '#277ffa',
|
|
1556
1736
|
pellucidity: 0.9,
|
|
@@ -1558,9 +1738,11 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1558
1738
|
lineType: 'solid',
|
|
1559
1739
|
isHidden: false
|
|
1560
1740
|
};
|
|
1741
|
+
|
|
1561
1742
|
if (item.config) {
|
|
1562
1743
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1563
1744
|
}
|
|
1745
|
+
|
|
1564
1746
|
var lineOption = {
|
|
1565
1747
|
strokeColor: cg.color,
|
|
1566
1748
|
strokeOpacity: cg.pellucidity,
|
|
@@ -1572,8 +1754,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1572
1754
|
cursor: 'pointer',
|
|
1573
1755
|
bubble: true
|
|
1574
1756
|
};
|
|
1575
|
-
var polyline = new AMap.Polyline(lineOption);
|
|
1576
|
-
|
|
1757
|
+
var polyline = new AMap.Polyline(lineOption); //添加点击事件
|
|
1758
|
+
|
|
1577
1759
|
polyline.on('click', function (e) {
|
|
1578
1760
|
t.clickGraphic(item.id, e);
|
|
1579
1761
|
});
|
|
@@ -1582,11 +1764,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1582
1764
|
});
|
|
1583
1765
|
polyline.on('mouseout', function (e) {
|
|
1584
1766
|
t.mouseOutGraphic(item.id, e);
|
|
1585
|
-
});
|
|
1586
|
-
|
|
1767
|
+
}); //缓存图元的数据,便于后期操作
|
|
1768
|
+
|
|
1587
1769
|
var pts = item.paths.map(function (itt, ind) {
|
|
1588
1770
|
return _toConsumableArray(itt);
|
|
1589
1771
|
});
|
|
1772
|
+
|
|
1590
1773
|
_this5.GM.setGraphic(item.id, polyline).setGraphicParam(item.id, {
|
|
1591
1774
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1592
1775
|
paths: pts,
|
|
@@ -1598,19 +1781,20 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1598
1781
|
paths: pts
|
|
1599
1782
|
}
|
|
1600
1783
|
});
|
|
1784
|
+
|
|
1601
1785
|
ls.push(polyline);
|
|
1602
|
-
lsids.push(item.id);
|
|
1603
|
-
//添加线
|
|
1786
|
+
lsids.push(item.id); //添加线
|
|
1604
1787
|
// polyline.setMap(t.state.gis);
|
|
1605
1788
|
//根据参数判断是否显示多折线
|
|
1789
|
+
|
|
1606
1790
|
if (cg.isHidden) {
|
|
1607
1791
|
polyline.hide();
|
|
1608
1792
|
} else {
|
|
1609
1793
|
polyline.show();
|
|
1610
|
-
}
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
// polyline.on('click', function(e) {
|
|
1794
|
+
} //state中缓存 line的id...用于数据判断
|
|
1795
|
+
|
|
1796
|
+
|
|
1797
|
+
t.state.lineIds.push(item.id); // polyline.on('click', function(e) {
|
|
1614
1798
|
// let obj = {
|
|
1615
1799
|
// type: 'polyline',
|
|
1616
1800
|
// attributes: {...item.other,...{config:item.config}},
|
|
@@ -1622,20 +1806,21 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1622
1806
|
// });
|
|
1623
1807
|
});
|
|
1624
1808
|
t.state.gis.add(ls);
|
|
1809
|
+
|
|
1625
1810
|
if (type !== 'defined') {
|
|
1626
|
-
t.state.lineIds = lsids;
|
|
1627
|
-
// t.setState({
|
|
1811
|
+
t.state.lineIds = lsids; // t.setState({
|
|
1628
1812
|
// lineIds: lsids
|
|
1629
1813
|
// });
|
|
1630
1814
|
}
|
|
1631
|
-
}
|
|
1632
|
-
|
|
1815
|
+
} //更新线
|
|
1816
|
+
|
|
1633
1817
|
}, {
|
|
1634
1818
|
key: "updateLine",
|
|
1635
1819
|
value: function updateLine(mapLines) {
|
|
1636
1820
|
var _this6 = this;
|
|
1637
|
-
|
|
1638
|
-
//遍历添加线(图元)
|
|
1821
|
+
|
|
1822
|
+
var t = this; //遍历添加线(图元)
|
|
1823
|
+
|
|
1639
1824
|
mapLines.map(function (item, index) {
|
|
1640
1825
|
//判断图元是否存在.
|
|
1641
1826
|
if (_this6.GM.isRepetition(item.id)) {
|
|
@@ -1643,28 +1828,32 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1643
1828
|
if (!(item.paths && item.paths.length >= 2)) {
|
|
1644
1829
|
console.warn("\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF");
|
|
1645
1830
|
return false;
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1831
|
+
} //获取原有的图元
|
|
1832
|
+
|
|
1833
|
+
|
|
1648
1834
|
var gc = _this6.GM.getGraphic(item.id);
|
|
1649
|
-
|
|
1650
|
-
//根据参数判断是否显示多折线
|
|
1835
|
+
|
|
1836
|
+
var op = gc.getOptions(); //根据参数判断是否显示多折线
|
|
1837
|
+
|
|
1651
1838
|
if (item.config && item.config.isHidden) {
|
|
1652
1839
|
gc.hide();
|
|
1653
1840
|
} else {
|
|
1654
1841
|
gc.show();
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1842
|
+
} //获取原有的线属性,转换key值
|
|
1843
|
+
|
|
1844
|
+
|
|
1657
1845
|
var cg = {
|
|
1658
1846
|
color: op.strokeColor,
|
|
1659
1847
|
pellucidity: op.strokeOpacity,
|
|
1660
1848
|
lineWidth: op.strokeWeight,
|
|
1661
1849
|
lineType: op.strokeStyle
|
|
1662
|
-
};
|
|
1663
|
-
|
|
1850
|
+
}; //重新初始化值
|
|
1851
|
+
|
|
1664
1852
|
if (item.config) {
|
|
1665
1853
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1854
|
+
} //重新赋值
|
|
1855
|
+
|
|
1856
|
+
|
|
1668
1857
|
var lineOption = {
|
|
1669
1858
|
strokeColor: cg.color,
|
|
1670
1859
|
strokeOpacity: cg.pellucidity,
|
|
@@ -1678,6 +1867,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1678
1867
|
var pts = item.paths.map(function (itt, ind) {
|
|
1679
1868
|
return _toConsumableArray(itt);
|
|
1680
1869
|
});
|
|
1870
|
+
|
|
1681
1871
|
_this6.GM.setGraphicParam(item.id, {
|
|
1682
1872
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1683
1873
|
paths: pts,
|
|
@@ -1688,47 +1878,55 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1688
1878
|
type: 'polyline',
|
|
1689
1879
|
paths: pts
|
|
1690
1880
|
}
|
|
1691
|
-
});
|
|
1692
|
-
|
|
1881
|
+
}); //更新线
|
|
1882
|
+
|
|
1883
|
+
|
|
1693
1884
|
gc.setOptions(lineOption);
|
|
1694
1885
|
} else {
|
|
1695
1886
|
console.warn("\u66F4\u65B0\u7684\u591A\u6298\u7EBFid\u4E0D\u5B58\u5728!");
|
|
1696
1887
|
return false;
|
|
1697
1888
|
}
|
|
1698
1889
|
});
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1890
|
+
} //添加面
|
|
1891
|
+
|
|
1701
1892
|
}, {
|
|
1702
1893
|
key: "addPolygon",
|
|
1703
1894
|
value: function addPolygon(mapPolygons) {
|
|
1704
1895
|
var _this7 = this;
|
|
1896
|
+
|
|
1705
1897
|
var t = this;
|
|
1706
1898
|
var pgs = [];
|
|
1707
|
-
|
|
1708
|
-
//遍历添加面(图元)
|
|
1899
|
+
|
|
1900
|
+
var pgsids = _toConsumableArray(t.state.polygonIds); //遍历添加面(图元)
|
|
1901
|
+
|
|
1902
|
+
|
|
1709
1903
|
mapPolygons.map(function (item, index) {
|
|
1710
1904
|
//如果id重复,直接跳过不执行.
|
|
1711
1905
|
if (_this7.GM.isRepetition(item.id)) {
|
|
1712
1906
|
console.warn("\u591A\u8FB9\u5F62id: ".concat(item.id, " \u91CD\u590D"));
|
|
1713
1907
|
return false;
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1908
|
+
} //多边形点位数据不符合,直接跳过
|
|
1909
|
+
|
|
1910
|
+
|
|
1716
1911
|
if (!(item.rings && item.rings.length >= 3)) {
|
|
1717
1912
|
console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
|
|
1718
1913
|
return false;
|
|
1719
1914
|
}
|
|
1915
|
+
|
|
1720
1916
|
var cg = {
|
|
1721
1917
|
lineType: 'solid',
|
|
1722
1918
|
lineWidth: 5,
|
|
1723
1919
|
lineColor: '#277ffa',
|
|
1724
1920
|
lineOpacity: 1,
|
|
1725
1921
|
color: '#fff',
|
|
1726
|
-
pellucidity: 0.5
|
|
1727
|
-
|
|
1922
|
+
pellucidity: 0.5 // isHidden: false //后期跟百度一起加
|
|
1923
|
+
|
|
1728
1924
|
};
|
|
1925
|
+
|
|
1729
1926
|
if (item.config) {
|
|
1730
1927
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1731
1928
|
}
|
|
1929
|
+
|
|
1732
1930
|
var polygonOption = {
|
|
1733
1931
|
strokeColor: cg.lineColor,
|
|
1734
1932
|
strokeOpacity: cg.lineOpacity,
|
|
@@ -1742,8 +1940,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1742
1940
|
cursor: 'pointer',
|
|
1743
1941
|
bubble: true
|
|
1744
1942
|
};
|
|
1745
|
-
var polygon = new AMap.Polygon(polygonOption);
|
|
1746
|
-
|
|
1943
|
+
var polygon = new AMap.Polygon(polygonOption); //添加点击事件
|
|
1944
|
+
|
|
1747
1945
|
polygon.on('click', function (e) {
|
|
1748
1946
|
t.clickGraphic(item.id, e);
|
|
1749
1947
|
});
|
|
@@ -1752,11 +1950,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1752
1950
|
});
|
|
1753
1951
|
polygon.on('mouseout', function (e) {
|
|
1754
1952
|
t.mouseOutGraphic(item.id, e);
|
|
1755
|
-
});
|
|
1756
|
-
|
|
1953
|
+
}); //缓存图元的数据,便于后期操作
|
|
1954
|
+
|
|
1757
1955
|
var pts = item.rings.map(function (itt, ind) {
|
|
1758
1956
|
return _toConsumableArray(itt);
|
|
1759
1957
|
});
|
|
1958
|
+
|
|
1760
1959
|
_this7.GM.setGraphic(item.id, polygon).setGraphicParam(item.id, {
|
|
1761
1960
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1762
1961
|
rings: pts,
|
|
@@ -1768,20 +1967,21 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1768
1967
|
rings: pts
|
|
1769
1968
|
}
|
|
1770
1969
|
});
|
|
1970
|
+
|
|
1771
1971
|
pgs.push(polygon);
|
|
1772
1972
|
pgsids.push(item.id);
|
|
1773
1973
|
});
|
|
1774
1974
|
t.state.gis.add(pgs);
|
|
1775
|
-
t.state.polygonIds = pgsids;
|
|
1776
|
-
// t.setState({
|
|
1975
|
+
t.state.polygonIds = pgsids; // t.setState({
|
|
1777
1976
|
// polygonIds: pgsids
|
|
1778
1977
|
// })
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1978
|
+
} //更新面
|
|
1979
|
+
|
|
1781
1980
|
}, {
|
|
1782
1981
|
key: "updatePolygon",
|
|
1783
1982
|
value: function updatePolygon(mapPolygons) {
|
|
1784
1983
|
var _this8 = this;
|
|
1984
|
+
|
|
1785
1985
|
var t = this;
|
|
1786
1986
|
mapPolygons.map(function (item, index) {
|
|
1787
1987
|
//判断图元是否存在.
|
|
@@ -1790,17 +1990,19 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1790
1990
|
if (!(item.rings && item.rings.length >= 3)) {
|
|
1791
1991
|
console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
|
|
1792
1992
|
return false;
|
|
1793
|
-
}
|
|
1794
|
-
|
|
1993
|
+
} //获取原有的图元
|
|
1994
|
+
|
|
1995
|
+
|
|
1795
1996
|
var gc = _this8.GM.getGraphic(item.id);
|
|
1796
|
-
|
|
1797
|
-
//根据参数判断是否显示面
|
|
1997
|
+
|
|
1998
|
+
var op = gc.getOptions(); //根据参数判断是否显示面
|
|
1798
1999
|
// if(item.config && item.config.isHidden){
|
|
1799
2000
|
// gc.hide();
|
|
1800
2001
|
// }else{
|
|
1801
2002
|
// gc.show();
|
|
1802
2003
|
// }
|
|
1803
2004
|
//获取原有的面属性,转换key值
|
|
2005
|
+
|
|
1804
2006
|
var cg = {
|
|
1805
2007
|
lineType: op.strokeStyle,
|
|
1806
2008
|
lineWidth: op.strokeWeight,
|
|
@@ -1808,12 +2010,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1808
2010
|
lineOpacity: op.strokeOpacity,
|
|
1809
2011
|
color: op.fillColor,
|
|
1810
2012
|
pellucidity: op.fillOpacity
|
|
1811
|
-
};
|
|
1812
|
-
|
|
2013
|
+
}; //重新初始化值
|
|
2014
|
+
|
|
1813
2015
|
if (item.config) {
|
|
1814
2016
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1815
|
-
}
|
|
1816
|
-
|
|
2017
|
+
} //重新赋值
|
|
2018
|
+
|
|
2019
|
+
|
|
1817
2020
|
var polygonOption = {
|
|
1818
2021
|
strokeColor: cg.lineColor,
|
|
1819
2022
|
strokeOpacity: cg.lineOpacity,
|
|
@@ -1829,6 +2032,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1829
2032
|
var pts = item.rings.map(function (itt, ind) {
|
|
1830
2033
|
return _toConsumableArray(itt);
|
|
1831
2034
|
});
|
|
2035
|
+
|
|
1832
2036
|
_this8.GM.setGraphicParam(item.id, {
|
|
1833
2037
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1834
2038
|
rings: pts,
|
|
@@ -1839,47 +2043,55 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1839
2043
|
type: 'polygon',
|
|
1840
2044
|
rings: pts
|
|
1841
2045
|
}
|
|
1842
|
-
});
|
|
1843
|
-
|
|
2046
|
+
}); //更新线
|
|
2047
|
+
|
|
2048
|
+
|
|
1844
2049
|
gc.setOptions(polygonOption);
|
|
1845
2050
|
} else {
|
|
1846
2051
|
console.warn("\u66F4\u65B0\u7684\u591A\u8FB9\u5F62id\u4E0D\u5B58\u5728!");
|
|
1847
2052
|
return false;
|
|
1848
2053
|
}
|
|
1849
2054
|
});
|
|
1850
|
-
}
|
|
1851
|
-
|
|
2055
|
+
} //添加圆 circle
|
|
2056
|
+
|
|
1852
2057
|
}, {
|
|
1853
2058
|
key: "addCircle",
|
|
1854
2059
|
value: function addCircle(mapCircles) {
|
|
1855
2060
|
var _this9 = this;
|
|
2061
|
+
|
|
1856
2062
|
var t = this;
|
|
1857
2063
|
var ccs = [];
|
|
2064
|
+
|
|
1858
2065
|
var ccsids = _toConsumableArray(t.state.circleIds);
|
|
2066
|
+
|
|
1859
2067
|
mapCircles.map(function (item, index) {
|
|
1860
2068
|
//如果id重复,直接跳过不执行.
|
|
1861
2069
|
if (_this9.GM.isRepetition(item.id)) {
|
|
1862
2070
|
console.warn("\u5706id: ".concat(item.id, " \u91CD\u590D"));
|
|
1863
2071
|
return false;
|
|
1864
|
-
}
|
|
1865
|
-
|
|
2072
|
+
} //圆 点位数据不符合,直接跳过
|
|
2073
|
+
|
|
2074
|
+
|
|
1866
2075
|
if (!item.longitude || !item.latitude) {
|
|
1867
2076
|
console.warn("\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
|
|
1868
2077
|
return false;
|
|
1869
2078
|
}
|
|
2079
|
+
|
|
1870
2080
|
var cg = {
|
|
1871
2081
|
lineType: 'solid',
|
|
1872
2082
|
lineWidth: 5,
|
|
1873
2083
|
lineColor: '#277ffa',
|
|
1874
2084
|
lineOpacity: 1,
|
|
1875
2085
|
color: '#fff',
|
|
1876
|
-
pellucidity: 0.5
|
|
1877
|
-
|
|
2086
|
+
pellucidity: 0.5 // isHidden: false //后期跟百度一起加
|
|
2087
|
+
|
|
1878
2088
|
};
|
|
2089
|
+
|
|
1879
2090
|
if (item.config) {
|
|
1880
2091
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1881
|
-
}
|
|
1882
|
-
|
|
2092
|
+
} //初始化配置数据
|
|
2093
|
+
|
|
2094
|
+
|
|
1883
2095
|
var circleOption = {
|
|
1884
2096
|
strokeColor: cg.lineColor,
|
|
1885
2097
|
strokeOpacity: cg.lineOpacity,
|
|
@@ -1891,10 +2103,10 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1891
2103
|
radius: item.radius,
|
|
1892
2104
|
cursor: 'pointer',
|
|
1893
2105
|
bubble: true
|
|
1894
|
-
};
|
|
1895
|
-
|
|
1896
|
-
var circle = new AMap.Circle(circleOption);
|
|
1897
|
-
|
|
2106
|
+
}; //创建圆对象
|
|
2107
|
+
|
|
2108
|
+
var circle = new AMap.Circle(circleOption); //添加点击事件
|
|
2109
|
+
|
|
1898
2110
|
circle.on('click', function (e) {
|
|
1899
2111
|
t.clickGraphic(item.id, e);
|
|
1900
2112
|
});
|
|
@@ -1903,8 +2115,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1903
2115
|
});
|
|
1904
2116
|
circle.on('mouseout', function (e) {
|
|
1905
2117
|
t.mouseOutGraphic(item.id, e);
|
|
1906
|
-
});
|
|
1907
|
-
|
|
2118
|
+
}); //缓存图元的数据,便于后期操作
|
|
2119
|
+
|
|
1908
2120
|
_this9.GM.setGraphic(item.id, circle).setGraphicParam(item.id, {
|
|
1909
2121
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1910
2122
|
other: item
|
|
@@ -1917,20 +2129,21 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1917
2129
|
radius: item.radius
|
|
1918
2130
|
}
|
|
1919
2131
|
});
|
|
2132
|
+
|
|
1920
2133
|
ccs.push(circle);
|
|
1921
2134
|
ccsids.push(item.id);
|
|
1922
2135
|
});
|
|
1923
2136
|
t.state.gis.add(ccs);
|
|
1924
|
-
t.state.circleIds = ccsids;
|
|
1925
|
-
// t.setState({
|
|
2137
|
+
t.state.circleIds = ccsids; // t.setState({
|
|
1926
2138
|
// circleIds: ccsids
|
|
1927
2139
|
// })
|
|
1928
|
-
}
|
|
1929
|
-
|
|
2140
|
+
} //更新圆
|
|
2141
|
+
|
|
1930
2142
|
}, {
|
|
1931
2143
|
key: "updateCircle",
|
|
1932
2144
|
value: function updateCircle(mapCircles) {
|
|
1933
2145
|
var _this10 = this;
|
|
2146
|
+
|
|
1934
2147
|
var t = this;
|
|
1935
2148
|
mapCircles.map(function (item, index) {
|
|
1936
2149
|
//判断图元是否存在.
|
|
@@ -1939,11 +2152,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1939
2152
|
if (!item.longitude || !item.latitude) {
|
|
1940
2153
|
console.warn("\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
|
|
1941
2154
|
return false;
|
|
1942
|
-
}
|
|
1943
|
-
|
|
2155
|
+
} //获取原有的图元
|
|
2156
|
+
|
|
2157
|
+
|
|
1944
2158
|
var gc = _this10.GM.getGraphic(item.id);
|
|
1945
|
-
|
|
1946
|
-
//获取原有的面属性,转换key值
|
|
2159
|
+
|
|
2160
|
+
var op = gc.getOptions(); //获取原有的面属性,转换key值
|
|
2161
|
+
|
|
1947
2162
|
var cg = {
|
|
1948
2163
|
lineType: op.strokeStyle,
|
|
1949
2164
|
lineWidth: op.strokeWeight,
|
|
@@ -1951,12 +2166,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1951
2166
|
lineOpacity: op.strokeOpacity,
|
|
1952
2167
|
color: op.fillColor,
|
|
1953
2168
|
pellucidity: op.fillOpacity
|
|
1954
|
-
};
|
|
1955
|
-
|
|
2169
|
+
}; //重新初始化值
|
|
2170
|
+
|
|
1956
2171
|
if (item.config) {
|
|
1957
2172
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1958
|
-
}
|
|
1959
|
-
|
|
2173
|
+
} //重新赋值
|
|
2174
|
+
|
|
2175
|
+
|
|
1960
2176
|
var circleOption = {
|
|
1961
2177
|
strokeColor: cg.lineColor,
|
|
1962
2178
|
strokeOpacity: cg.lineOpacity,
|
|
@@ -1967,8 +2183,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1967
2183
|
center: new AMap.LngLat(item.longitude, item.latitude) || op.center,
|
|
1968
2184
|
radius: !item.radius && item != 0 ? op.radius : item.radius,
|
|
1969
2185
|
cursor: 'pointer'
|
|
1970
|
-
};
|
|
1971
|
-
|
|
2186
|
+
}; //缓存图元的数据,便于后期操作
|
|
2187
|
+
|
|
1972
2188
|
_this10.GM.setGraphicParam(item.id, {
|
|
1973
2189
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
1974
2190
|
other: item
|
|
@@ -1980,8 +2196,9 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1980
2196
|
y: item.latitude,
|
|
1981
2197
|
radius: item.radius
|
|
1982
2198
|
}
|
|
1983
|
-
});
|
|
1984
|
-
|
|
2199
|
+
}); //更新线
|
|
2200
|
+
|
|
2201
|
+
|
|
1985
2202
|
gc.setOptions(circleOption);
|
|
1986
2203
|
} else {
|
|
1987
2204
|
console.warn("\u66F4\u65B0\u7684\u5706id\u4E0D\u5B58\u5728!");
|
|
@@ -1990,30 +2207,36 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1990
2207
|
});
|
|
1991
2208
|
}
|
|
1992
2209
|
/*根据图元id,使图元变成可编辑状态*/
|
|
2210
|
+
|
|
1993
2211
|
}, {
|
|
1994
2212
|
key: "doEdit",
|
|
1995
2213
|
value: function doEdit(id) {
|
|
1996
2214
|
var t = this;
|
|
1997
2215
|
var ms = t.getGraphic(id);
|
|
2216
|
+
|
|
1998
2217
|
if (!ms) {
|
|
1999
2218
|
return false;
|
|
2000
2219
|
}
|
|
2220
|
+
|
|
2001
2221
|
if (!!t.state.editId) {
|
|
2002
2222
|
t.endEdit();
|
|
2003
2223
|
}
|
|
2224
|
+
|
|
2004
2225
|
switch (ms.geometryType) {
|
|
2005
2226
|
case 'point':
|
|
2006
2227
|
ms.mapLayer.setDraggable(true);
|
|
2007
2228
|
ms.mapLayer.on('dragend', t.editGraphicChange, t);
|
|
2008
2229
|
break;
|
|
2009
|
-
|
|
2010
|
-
// break;
|
|
2230
|
+
|
|
2231
|
+
case 'polyline': // break;
|
|
2232
|
+
|
|
2011
2233
|
case 'polygon':
|
|
2012
2234
|
case 'rectangle':
|
|
2013
2235
|
t.polyEdit = new AMap.PolyEditor(t.state.gis, ms.mapLayer);
|
|
2014
2236
|
t.polyEdit.open();
|
|
2015
2237
|
t.polyEdit.on('adjust', t.editGraphicChange, t);
|
|
2016
2238
|
break;
|
|
2239
|
+
|
|
2017
2240
|
case 'circle':
|
|
2018
2241
|
t.circleEdit = new AMap.CircleEditor(t.state.gis, ms.mapLayer);
|
|
2019
2242
|
t.circleEdit.open();
|
|
@@ -2021,34 +2244,40 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2021
2244
|
t.circleEdit.on('adjust', t.editGraphicChange, t);
|
|
2022
2245
|
break;
|
|
2023
2246
|
}
|
|
2247
|
+
|
|
2024
2248
|
t.setState({
|
|
2025
2249
|
editId: id
|
|
2026
2250
|
});
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2251
|
+
} //关闭编辑
|
|
2252
|
+
|
|
2029
2253
|
}, {
|
|
2030
2254
|
key: "endEdit",
|
|
2031
2255
|
value: function endEdit() {
|
|
2032
2256
|
var t = this;
|
|
2033
2257
|
var ms = t.getGraphic(t.state.editId);
|
|
2258
|
+
|
|
2034
2259
|
switch (ms.geometryType) {
|
|
2035
2260
|
case 'point':
|
|
2036
2261
|
ms.mapLayer.setDraggable(false);
|
|
2037
2262
|
ms.mapLayer.off('dragend', t.editGraphicChange, t);
|
|
2038
2263
|
break;
|
|
2264
|
+
|
|
2039
2265
|
case 'polyline':
|
|
2040
2266
|
case 'polygon':
|
|
2041
2267
|
case 'rectangle':
|
|
2042
2268
|
t.polyEdit.close();
|
|
2043
2269
|
t.polyEdit.off('adjust', t.editGraphicChange, t);
|
|
2044
2270
|
break;
|
|
2271
|
+
|
|
2045
2272
|
case 'circle':
|
|
2046
2273
|
t.circleEdit.close();
|
|
2047
2274
|
t.circleEdit.off('move', t.editGraphicChange, t);
|
|
2048
2275
|
t.circleEdit.off('adjust', t.editGraphicChange, t);
|
|
2049
2276
|
break;
|
|
2050
2277
|
}
|
|
2278
|
+
|
|
2051
2279
|
var editGraphic = t.state.editGraphic;
|
|
2280
|
+
|
|
2052
2281
|
if (editGraphic) {
|
|
2053
2282
|
t.setState({
|
|
2054
2283
|
editId: '',
|
|
@@ -2057,8 +2286,8 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2057
2286
|
t.props.editGraphicChange(editGraphic);
|
|
2058
2287
|
});
|
|
2059
2288
|
}
|
|
2060
|
-
}
|
|
2061
|
-
|
|
2289
|
+
} //编辑变动后
|
|
2290
|
+
|
|
2062
2291
|
}, {
|
|
2063
2292
|
key: "editGraphicChange",
|
|
2064
2293
|
value: function editGraphicChange(e) {
|
|
@@ -2068,38 +2297,46 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2068
2297
|
id: t.state.editId,
|
|
2069
2298
|
e: e
|
|
2070
2299
|
};
|
|
2300
|
+
|
|
2071
2301
|
switch (ms.geometryType) {
|
|
2072
2302
|
case 'point':
|
|
2073
2303
|
obj.geometry = ms.geometry;
|
|
2074
2304
|
obj.param = ms;
|
|
2075
2305
|
break;
|
|
2306
|
+
|
|
2076
2307
|
case 'polyline':
|
|
2077
2308
|
obj.geometry = ms.geometry;
|
|
2078
2309
|
obj.param = ms;
|
|
2079
2310
|
obj.distance = ms.mapLayer.getLength();
|
|
2080
2311
|
break;
|
|
2312
|
+
|
|
2081
2313
|
case 'polygon':
|
|
2082
2314
|
case 'rectangle':
|
|
2083
2315
|
obj.geometry = ms.geometry;
|
|
2084
2316
|
obj.param = ms;
|
|
2085
2317
|
obj.area = e.target.getArea();
|
|
2086
2318
|
break;
|
|
2319
|
+
|
|
2087
2320
|
case 'circle':
|
|
2088
2321
|
if (!('lnglat' in e)) {
|
|
2089
2322
|
obj.e.lnglat = new AMap.LngLat(ms.geometry.x, ms.geometry.y);
|
|
2090
2323
|
}
|
|
2324
|
+
|
|
2091
2325
|
if (!('radius' in e)) {
|
|
2092
2326
|
obj.e.radius = ms.geometry.radius;
|
|
2093
2327
|
}
|
|
2328
|
+
|
|
2094
2329
|
obj.geometry = ms.geometry;
|
|
2095
2330
|
obj.param = ms;
|
|
2096
2331
|
obj.area = Math.pow(ms.geometry.radius, 2) * Math.PI;
|
|
2097
2332
|
break;
|
|
2098
2333
|
}
|
|
2334
|
+
|
|
2099
2335
|
if (ms.geometryType == 'circle') {
|
|
2100
2336
|
if (t.editTimeout) {
|
|
2101
2337
|
clearTimeout(t.editTimeout);
|
|
2102
2338
|
}
|
|
2339
|
+
|
|
2103
2340
|
t.editTimeout = setTimeout(function () {
|
|
2104
2341
|
t.setState({
|
|
2105
2342
|
editGraphic: obj
|
|
@@ -2114,12 +2351,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2114
2351
|
t.props.editGraphicChange(obj);
|
|
2115
2352
|
});
|
|
2116
2353
|
}
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2354
|
+
} //点击图元事件
|
|
2355
|
+
|
|
2119
2356
|
}, {
|
|
2120
2357
|
key: "clickGraphic",
|
|
2121
2358
|
value: function clickGraphic(id, e) {
|
|
2122
2359
|
var t = this;
|
|
2360
|
+
|
|
2123
2361
|
if (typeof t.props.clickGraphic === "function") {
|
|
2124
2362
|
var param = t.getGraphic(id);
|
|
2125
2363
|
var obj = {
|
|
@@ -2137,40 +2375,43 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2137
2375
|
};
|
|
2138
2376
|
t.props.clickGraphic(obj);
|
|
2139
2377
|
}
|
|
2140
|
-
}
|
|
2141
|
-
|
|
2378
|
+
} //拖拽地图开始
|
|
2379
|
+
|
|
2142
2380
|
}, {
|
|
2143
2381
|
key: "dragMapStart",
|
|
2144
2382
|
value: function dragMapStart() {
|
|
2145
2383
|
var t = this;
|
|
2384
|
+
|
|
2146
2385
|
if (typeof t.props.dragMapStart === "function") {
|
|
2147
2386
|
t.state.gis.on('dragstart', function (e) {
|
|
2148
2387
|
var obj = t.getMapExtent();
|
|
2149
|
-
obj.e = e;
|
|
2150
|
-
|
|
2388
|
+
obj.e = e; //处理下数据,符合拖拽事件
|
|
2389
|
+
|
|
2151
2390
|
t.props.dragMapStart(obj);
|
|
2152
2391
|
});
|
|
2153
2392
|
}
|
|
2154
|
-
}
|
|
2155
|
-
|
|
2393
|
+
} //拖拽地图结束事件
|
|
2394
|
+
|
|
2156
2395
|
}, {
|
|
2157
2396
|
key: "dragMapEnd",
|
|
2158
2397
|
value: function dragMapEnd() {
|
|
2159
2398
|
var t = this;
|
|
2399
|
+
|
|
2160
2400
|
if (typeof t.props.dragMapEnd === "function") {
|
|
2161
2401
|
t.state.gis.on('dragend', function (e) {
|
|
2162
2402
|
var obj = t.getMapExtent();
|
|
2163
|
-
obj.e = e;
|
|
2164
|
-
|
|
2403
|
+
obj.e = e; //处理下数据,符合拖拽事件
|
|
2404
|
+
|
|
2165
2405
|
t.props.dragMapEnd(obj);
|
|
2166
2406
|
});
|
|
2167
2407
|
}
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2408
|
+
} //地图移动开始事件
|
|
2409
|
+
|
|
2170
2410
|
}, {
|
|
2171
2411
|
key: "moveStart",
|
|
2172
2412
|
value: function moveStart() {
|
|
2173
2413
|
var t = this;
|
|
2414
|
+
|
|
2174
2415
|
if (typeof t.props.moveStart === "function") {
|
|
2175
2416
|
t.state.gis.on('movestart', function (e) {
|
|
2176
2417
|
t.htmlXY = _objectSpread({
|
|
@@ -2184,20 +2425,22 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2184
2425
|
display: 'none'
|
|
2185
2426
|
});
|
|
2186
2427
|
t.updatePointCollection(t.props.mapPointCollection);
|
|
2428
|
+
|
|
2187
2429
|
if (t.stopMove) {
|
|
2188
2430
|
var obj = t.getMapExtent();
|
|
2189
|
-
obj.e = e;
|
|
2190
|
-
|
|
2431
|
+
obj.e = e; //处理下数据,符合拖拽事件
|
|
2432
|
+
|
|
2191
2433
|
t.props.moveStart(obj);
|
|
2192
2434
|
}
|
|
2193
2435
|
});
|
|
2194
2436
|
}
|
|
2195
|
-
}
|
|
2196
|
-
|
|
2437
|
+
} //地图移动结束事件
|
|
2438
|
+
|
|
2197
2439
|
}, {
|
|
2198
2440
|
key: "moveEnd",
|
|
2199
2441
|
value: function moveEnd() {
|
|
2200
2442
|
var t = this;
|
|
2443
|
+
|
|
2201
2444
|
if (typeof t.props.moveEnd === "function") {
|
|
2202
2445
|
t.state.gis.on('moveend', function (e) {
|
|
2203
2446
|
t.htmlXY.isCount = false;
|
|
@@ -2207,22 +2450,24 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2207
2450
|
display: 'block'
|
|
2208
2451
|
});
|
|
2209
2452
|
t.updatePointCollection(t.props.mapPointCollection);
|
|
2453
|
+
|
|
2210
2454
|
if (t.stopMove) {
|
|
2211
2455
|
var obj = t.getMapExtent();
|
|
2212
|
-
obj.e = e;
|
|
2213
|
-
|
|
2456
|
+
obj.e = e; //处理下数据,符合拖拽事件
|
|
2457
|
+
|
|
2214
2458
|
t.props.moveEnd(obj);
|
|
2215
2459
|
} else {
|
|
2216
2460
|
t.stopMove = true;
|
|
2217
2461
|
}
|
|
2218
2462
|
});
|
|
2219
2463
|
}
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2464
|
+
} //地图更改缩放级别开始时触发触发此事件
|
|
2465
|
+
|
|
2222
2466
|
}, {
|
|
2223
2467
|
key: "zoomStart",
|
|
2224
2468
|
value: function zoomStart() {
|
|
2225
2469
|
var t = this;
|
|
2470
|
+
|
|
2226
2471
|
if (typeof t.props.zoomStart === "function") {
|
|
2227
2472
|
t.state.gis.on('zoomstart', function (e) {
|
|
2228
2473
|
$("#".concat(t.pointCollectionId)).css({
|
|
@@ -2234,12 +2479,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2234
2479
|
t.props.zoomStart(obj);
|
|
2235
2480
|
});
|
|
2236
2481
|
}
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2482
|
+
} //地图更改缩放级别结束时触发触发此事件
|
|
2483
|
+
|
|
2239
2484
|
}, {
|
|
2240
2485
|
key: "zoomEnd",
|
|
2241
2486
|
value: function zoomEnd() {
|
|
2242
2487
|
var t = this;
|
|
2488
|
+
|
|
2243
2489
|
if (typeof t.props.zoomEnd === "function") {
|
|
2244
2490
|
t.state.gis.on('zoomend', function (e) {
|
|
2245
2491
|
$("#".concat(t.pointCollectionId)).css({
|
|
@@ -2250,12 +2496,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2250
2496
|
t.props.zoomEnd(obj);
|
|
2251
2497
|
});
|
|
2252
2498
|
}
|
|
2253
|
-
}
|
|
2254
|
-
|
|
2499
|
+
} //图元鼠标悬浮事件
|
|
2500
|
+
|
|
2255
2501
|
}, {
|
|
2256
2502
|
key: "mouseOverGraphic",
|
|
2257
2503
|
value: function mouseOverGraphic(id, e) {
|
|
2258
2504
|
var t = this;
|
|
2505
|
+
|
|
2259
2506
|
if (typeof t.props.mouseOverGraphic === 'function') {
|
|
2260
2507
|
var obj = {
|
|
2261
2508
|
e: e,
|
|
@@ -2267,12 +2514,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2267
2514
|
};
|
|
2268
2515
|
t.props.mouseOverGraphic(obj);
|
|
2269
2516
|
}
|
|
2270
|
-
}
|
|
2271
|
-
|
|
2517
|
+
} //图元鼠标移开事件
|
|
2518
|
+
|
|
2272
2519
|
}, {
|
|
2273
2520
|
key: "mouseOutGraphic",
|
|
2274
2521
|
value: function mouseOutGraphic(id, e) {
|
|
2275
2522
|
var t = this;
|
|
2523
|
+
|
|
2276
2524
|
if (typeof t.props.mouseOutGraphic === "function") {
|
|
2277
2525
|
var obj = {
|
|
2278
2526
|
e: e,
|
|
@@ -2284,12 +2532,13 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2284
2532
|
};
|
|
2285
2533
|
t.props.mouseOutGraphic(obj);
|
|
2286
2534
|
}
|
|
2287
|
-
}
|
|
2288
|
-
|
|
2535
|
+
} //地图点击事件
|
|
2536
|
+
|
|
2289
2537
|
}, {
|
|
2290
2538
|
key: "clickMap",
|
|
2291
2539
|
value: function clickMap() {
|
|
2292
2540
|
var t = this;
|
|
2541
|
+
|
|
2293
2542
|
if (typeof t.props.clickMap === "function") {
|
|
2294
2543
|
t.state.gis.on('click', function (e) {
|
|
2295
2544
|
var obj = t.getMapExtent();
|
|
@@ -2302,14 +2551,14 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2302
2551
|
t.props.clickMap(obj);
|
|
2303
2552
|
});
|
|
2304
2553
|
}
|
|
2305
|
-
}
|
|
2306
|
-
|
|
2554
|
+
} //测距
|
|
2555
|
+
|
|
2307
2556
|
}, {
|
|
2308
2557
|
key: "vtxRangingTool",
|
|
2309
2558
|
value: function vtxRangingTool() {
|
|
2310
2559
|
var t = this;
|
|
2311
|
-
t.ruler.turnOn();
|
|
2312
|
-
|
|
2560
|
+
t.ruler.turnOn(); //引用百度测距样式
|
|
2561
|
+
|
|
2313
2562
|
t.state.gis.setDefaultCursor(this.csr);
|
|
2314
2563
|
}
|
|
2315
2564
|
/*
|
|
@@ -2318,27 +2567,31 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2318
2567
|
parameter 样式 默认null 对象{}写入方式跟add方法一样(对应点线圆面)
|
|
2319
2568
|
data //初始化数据 默认{id:'add'}
|
|
2320
2569
|
*/
|
|
2570
|
+
|
|
2321
2571
|
}, {
|
|
2322
2572
|
key: "draw",
|
|
2323
2573
|
value: function draw(obj) {
|
|
2324
2574
|
var t = this,
|
|
2325
|
-
|
|
2326
|
-
|
|
2575
|
+
drawParam = {}; //初始化参数
|
|
2576
|
+
|
|
2327
2577
|
drawParam.geometryType = obj.geometryType || 'point';
|
|
2328
2578
|
drawParam.parameter = obj.parameter ? _objectSpread({}, obj.parameter) : {};
|
|
2329
2579
|
drawParam.data = obj.data ? _objectSpread({}, obj.data) : {};
|
|
2330
|
-
drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime());
|
|
2331
|
-
|
|
2580
|
+
drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime()); //判断id是否存在
|
|
2581
|
+
|
|
2332
2582
|
var len = t.state.drawIds[drawParam.geometryType].indexOf(drawParam.data.id);
|
|
2583
|
+
|
|
2333
2584
|
if (len > -1) {
|
|
2334
2585
|
//如果id存在 删除存在的图元,清除drawId中的id数据
|
|
2335
2586
|
t.removeGraphic(drawParam.data.id);
|
|
2336
2587
|
t.state.drawIds[drawParam.geometryType].splice(len, 1);
|
|
2337
|
-
}
|
|
2338
|
-
|
|
2588
|
+
} //引用百度测距样式
|
|
2589
|
+
|
|
2590
|
+
|
|
2339
2591
|
t.state.gis.setDefaultCursor('crosshair');
|
|
2340
2592
|
var param = {};
|
|
2341
2593
|
var paramgcr = {};
|
|
2594
|
+
|
|
2342
2595
|
if (drawParam.geometryType == 'polygon' || drawParam.geometryType == 'circle' || drawParam.geometryType == 'rectangle') {
|
|
2343
2596
|
paramgcr.fillColor = drawParam.parameter.color;
|
|
2344
2597
|
paramgcr.strokeColor = drawParam.parameter.lineColor;
|
|
@@ -2361,6 +2614,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2361
2614
|
type: drawParam.geometryType
|
|
2362
2615
|
};
|
|
2363
2616
|
}
|
|
2617
|
+
|
|
2364
2618
|
switch (drawParam.geometryType) {
|
|
2365
2619
|
case 'point':
|
|
2366
2620
|
param.icon = new AMap.Icon({
|
|
@@ -2382,6 +2636,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2382
2636
|
};
|
|
2383
2637
|
t.mousetool.marker(param);
|
|
2384
2638
|
break;
|
|
2639
|
+
|
|
2385
2640
|
case 'polyline':
|
|
2386
2641
|
param.strokeColor = drawParam.parameter.color;
|
|
2387
2642
|
param.strokeOpacity = drawParam.parameter.pellucidity;
|
|
@@ -2401,58 +2656,68 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2401
2656
|
};
|
|
2402
2657
|
t.mousetool.polyline(param);
|
|
2403
2658
|
break;
|
|
2659
|
+
|
|
2404
2660
|
case 'polygon':
|
|
2405
2661
|
t.mousetool.polygon(paramgcr);
|
|
2406
2662
|
break;
|
|
2663
|
+
|
|
2407
2664
|
case 'circle':
|
|
2408
2665
|
t.mousetool.circle(paramgcr);
|
|
2409
2666
|
break;
|
|
2667
|
+
|
|
2410
2668
|
case 'rectangle':
|
|
2411
2669
|
t.mousetool.rectangle(paramgcr);
|
|
2412
2670
|
break;
|
|
2413
|
-
}
|
|
2414
|
-
|
|
2671
|
+
} //保存绘制图元的id便于后期比对
|
|
2672
|
+
|
|
2673
|
+
|
|
2415
2674
|
t.state.drawIds[drawParam.geometryType].push(drawParam.data.id);
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2675
|
+
} //关闭绘制图元
|
|
2676
|
+
|
|
2418
2677
|
}, {
|
|
2419
2678
|
key: "closeDraw",
|
|
2420
2679
|
value: function closeDraw() {
|
|
2421
|
-
var t = this;
|
|
2422
|
-
|
|
2680
|
+
var t = this; //恢复鼠标默认样式
|
|
2681
|
+
|
|
2423
2682
|
t.state.gis.setDefaultCursor();
|
|
2424
2683
|
t.mousetool.close();
|
|
2425
|
-
}
|
|
2426
|
-
|
|
2684
|
+
} //处理线和面的 经纬度数据
|
|
2685
|
+
|
|
2427
2686
|
}, {
|
|
2428
2687
|
key: "dealData",
|
|
2429
2688
|
value: function dealData(ms) {
|
|
2430
2689
|
//区别点和圆的经纬度数据处理
|
|
2431
2690
|
var lnglatAry = [],
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2691
|
+
_extent = {
|
|
2692
|
+
xmax: 0,
|
|
2693
|
+
xmin: 0,
|
|
2694
|
+
ymax: 0,
|
|
2695
|
+
ymin: 0
|
|
2696
|
+
},
|
|
2697
|
+
path = [];
|
|
2698
|
+
|
|
2439
2699
|
if ('getPath' in ms) {
|
|
2440
2700
|
path = ms.getPath();
|
|
2441
2701
|
path = path.map(function (item, index) {
|
|
2442
2702
|
var lng = item.lng,
|
|
2443
|
-
|
|
2703
|
+
lat = item.lat;
|
|
2704
|
+
|
|
2444
2705
|
if (lng > _extent.xmax) {
|
|
2445
2706
|
_extent.xmax = lng;
|
|
2446
2707
|
}
|
|
2708
|
+
|
|
2447
2709
|
if (lng < _extent.xmin || _extent.xmin == 0) {
|
|
2448
2710
|
_extent.xmin = lng;
|
|
2449
2711
|
}
|
|
2712
|
+
|
|
2450
2713
|
if (lat > _extent.ymax) {
|
|
2451
2714
|
_extent.ymax = lat;
|
|
2452
2715
|
}
|
|
2716
|
+
|
|
2453
2717
|
if (lat < _extent.ymin || _extent.ymin == 0) {
|
|
2454
2718
|
_extent.ymin = lat;
|
|
2455
2719
|
}
|
|
2720
|
+
|
|
2456
2721
|
lnglatAry.push({
|
|
2457
2722
|
lngX: lng,
|
|
2458
2723
|
latX: lat
|
|
@@ -2460,107 +2725,132 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2460
2725
|
return [lng, lat];
|
|
2461
2726
|
});
|
|
2462
2727
|
}
|
|
2728
|
+
|
|
2463
2729
|
return {
|
|
2464
2730
|
lnglatAry: lnglatAry,
|
|
2465
2731
|
_extent: _extent,
|
|
2466
2732
|
path: path
|
|
2467
2733
|
};
|
|
2468
|
-
}
|
|
2469
|
-
|
|
2734
|
+
} //删除图元
|
|
2735
|
+
|
|
2470
2736
|
}, {
|
|
2471
2737
|
key: "removeGraphic",
|
|
2472
2738
|
value: function removeGraphic(id, type) {
|
|
2473
2739
|
var t = this;
|
|
2740
|
+
|
|
2474
2741
|
if (!!this.GM.getGraphic(id)) {
|
|
2475
2742
|
if ((t.GM.getGraphicParam(id).attributes.config || {}).isAnimation) {
|
|
2476
2743
|
this.GM.getGraphic(id).stopMove();
|
|
2477
|
-
}
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
//清除地图中图元
|
|
2481
|
-
|
|
2482
|
-
//清除对应id的图元数据缓存
|
|
2744
|
+
} //清除聚合点 避免异常
|
|
2745
|
+
|
|
2746
|
+
|
|
2747
|
+
t.clusterObj.removeMarker(this.GM.getGraphic(id)); //清除地图中图元
|
|
2748
|
+
|
|
2749
|
+
this.GM.getGraphic(id).setMap(); //清除对应id的图元数据缓存
|
|
2750
|
+
|
|
2483
2751
|
this.GM.removeGraphic(id);
|
|
2484
2752
|
} else {
|
|
2485
2753
|
return false;
|
|
2486
|
-
}
|
|
2487
|
-
|
|
2754
|
+
} //清除 state中id的缓存
|
|
2755
|
+
|
|
2756
|
+
|
|
2488
2757
|
var ids = [];
|
|
2758
|
+
|
|
2489
2759
|
switch (type) {
|
|
2490
2760
|
case 'point':
|
|
2491
2761
|
ids = t.state.pointIds;
|
|
2492
2762
|
break;
|
|
2763
|
+
|
|
2493
2764
|
case 'line':
|
|
2494
2765
|
ids = t.state.lineIds;
|
|
2495
2766
|
break;
|
|
2767
|
+
|
|
2496
2768
|
case 'polygon':
|
|
2497
2769
|
ids = t.state.polygonIds;
|
|
2498
2770
|
break;
|
|
2771
|
+
|
|
2499
2772
|
case 'circle':
|
|
2500
2773
|
ids = t.state.circleIds;
|
|
2501
2774
|
break;
|
|
2775
|
+
|
|
2502
2776
|
case 'draw':
|
|
2503
2777
|
if (t.state.drawIds.point.indexOf(id) > -1) {
|
|
2504
2778
|
t.state.drawIds.point.splice(t.state.drawIds.point.indexOf(id), 1);
|
|
2505
2779
|
}
|
|
2780
|
+
|
|
2506
2781
|
if (t.state.drawIds.polyline.indexOf(id) > -1) {
|
|
2507
2782
|
t.state.drawIds.polyline.splice(t.state.drawIds.polyline.indexOf(id), 1);
|
|
2508
2783
|
}
|
|
2784
|
+
|
|
2509
2785
|
if (t.state.drawIds.polygon.indexOf(id) > -1) {
|
|
2510
2786
|
t.state.drawIds.polygon.splice(t.state.drawIds.polygon.indexOf(id), 1);
|
|
2511
2787
|
}
|
|
2788
|
+
|
|
2512
2789
|
if (t.state.drawIds.circle.indexOf(id) > -1) {
|
|
2513
2790
|
t.state.drawIds.circle.splice(t.state.drawIds.circle.indexOf(id), 1);
|
|
2514
2791
|
}
|
|
2792
|
+
|
|
2515
2793
|
if (t.state.drawIds.rectangle.indexOf(id) > -1) {
|
|
2516
2794
|
t.state.drawIds.rectangle.splice(t.state.drawIds.rectangle.indexOf(id), 1);
|
|
2517
2795
|
}
|
|
2796
|
+
|
|
2518
2797
|
break;
|
|
2798
|
+
|
|
2519
2799
|
default:
|
|
2520
2800
|
if (t.state.pointIds.indexOf(id) > -1) {
|
|
2521
2801
|
t.state.pointIds.splice(t.state.pointIds.indexOf(id), 1);
|
|
2522
2802
|
}
|
|
2803
|
+
|
|
2523
2804
|
if (t.state.lineIds.indexOf(id) > -1) {
|
|
2524
2805
|
t.state.lineIds.splice(t.state.lineIds.indexOf(id), 1);
|
|
2525
2806
|
}
|
|
2807
|
+
|
|
2526
2808
|
if (t.state.polygonIds.indexOf(id) > -1) {
|
|
2527
2809
|
t.state.polygonIds.splice(t.state.polygonIds.indexOf(id), 1);
|
|
2528
2810
|
}
|
|
2811
|
+
|
|
2529
2812
|
if (t.state.circleIds.indexOf(id) > -1) {
|
|
2530
2813
|
t.state.circleIds.splice(t.state.circleIds.indexOf(id), 1);
|
|
2531
2814
|
}
|
|
2815
|
+
|
|
2532
2816
|
break;
|
|
2533
2817
|
}
|
|
2818
|
+
|
|
2534
2819
|
if (id == t.state.editId) {
|
|
2535
2820
|
t.state.editId = '';
|
|
2536
2821
|
}
|
|
2822
|
+
|
|
2537
2823
|
if (ids.indexOf(id) != -1) {
|
|
2538
2824
|
ids.splice(ids.indexOf(id), 1);
|
|
2539
2825
|
}
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2826
|
+
} //点位角度旋转(以指向东(右)为0°)
|
|
2827
|
+
|
|
2542
2828
|
}, {
|
|
2543
2829
|
key: "rotateDeg",
|
|
2544
2830
|
value: function rotateDeg(sp, ep) {
|
|
2545
2831
|
var t = this;
|
|
2546
2832
|
var spLngLat = sp;
|
|
2833
|
+
|
|
2547
2834
|
if (Array.isArray(sp)) {
|
|
2548
2835
|
spLngLat = new AMap.LngLat(sp[0], sp[1]);
|
|
2549
2836
|
}
|
|
2837
|
+
|
|
2550
2838
|
var s = t.state.gis.lngLatToContainer(spLngLat),
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2839
|
+
//获取当前点位的经纬度
|
|
2840
|
+
e = t.state.gis.lngLatToContainer(new AMap.LngLat(ep[0], ep[1])),
|
|
2841
|
+
deg = 0;
|
|
2842
|
+
|
|
2554
2843
|
if (e.x != s.x) {
|
|
2555
2844
|
var tan = (e.y - s.y) / (e.x - s.x),
|
|
2556
|
-
|
|
2557
|
-
deg = atan * 360 / (2 * Math.PI);
|
|
2558
|
-
|
|
2845
|
+
atan = Math.atan(tan);
|
|
2846
|
+
deg = atan * 360 / (2 * Math.PI); //degree correction;
|
|
2847
|
+
|
|
2559
2848
|
if (e.x < s.x) {
|
|
2560
2849
|
deg = -deg + 90 + 90;
|
|
2561
2850
|
} else {
|
|
2562
2851
|
deg = -deg;
|
|
2563
2852
|
}
|
|
2853
|
+
|
|
2564
2854
|
deg = -deg;
|
|
2565
2855
|
} else {
|
|
2566
2856
|
var disy = e.y - s.y;
|
|
@@ -2569,39 +2859,43 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2569
2859
|
if (disy == 0) bias = 0;
|
|
2570
2860
|
deg = -bias * 90;
|
|
2571
2861
|
}
|
|
2862
|
+
|
|
2572
2863
|
return deg;
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2864
|
+
} //对比对象数据是否相等
|
|
2865
|
+
|
|
2575
2866
|
}, {
|
|
2576
2867
|
key: "deepEqual",
|
|
2577
2868
|
value: function deepEqual(a, b) {
|
|
2578
2869
|
return _immutable["default"].is(_immutable["default"].fromJS(a), _immutable["default"].fromJS(b));
|
|
2579
|
-
}
|
|
2580
|
-
|
|
2870
|
+
} //计算2点间距离 单位m 精确到个位
|
|
2871
|
+
|
|
2581
2872
|
}, {
|
|
2582
2873
|
key: "calculatePointsDistance",
|
|
2583
2874
|
value: function calculatePointsDistance(f, s) {
|
|
2584
2875
|
var lnglat1 = new AMap.LngLat(f[0], f[1]);
|
|
2585
2876
|
var lnglat2 = new AMap.LngLat(s[0], s[1]);
|
|
2586
2877
|
return Math.round(lnglat1.distance(lnglat2));
|
|
2587
|
-
}
|
|
2588
|
-
|
|
2878
|
+
} //计算多个点的距离(常用于线计算)
|
|
2879
|
+
|
|
2589
2880
|
}, {
|
|
2590
2881
|
key: "calculateDistance",
|
|
2591
2882
|
value: function calculateDistance(ps) {
|
|
2592
2883
|
var t = this,
|
|
2593
|
-
|
|
2884
|
+
totalDistance = 0;
|
|
2885
|
+
|
|
2594
2886
|
if (ps.length < 0) {
|
|
2595
2887
|
return false;
|
|
2596
2888
|
}
|
|
2889
|
+
|
|
2597
2890
|
for (var i = 0; i < ps.length; i++) {
|
|
2598
2891
|
if (i < ps.length - 1) {
|
|
2599
2892
|
totalDistance += t.calculatePointsDistance(ps[i], ps[i + 1]);
|
|
2600
2893
|
}
|
|
2601
2894
|
}
|
|
2895
|
+
|
|
2602
2896
|
return Math.round(totalDistance * 100) / 100;
|
|
2603
|
-
}
|
|
2604
|
-
|
|
2897
|
+
} //数据解析(分析,新增,更新,删除对应的数据)
|
|
2898
|
+
|
|
2605
2899
|
}, {
|
|
2606
2900
|
key: "dataMatch",
|
|
2607
2901
|
value: function dataMatch(oldData, newData, type) {
|
|
@@ -2632,13 +2926,14 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2632
2926
|
updatedData: updatedData,
|
|
2633
2927
|
replacedData: replacedData
|
|
2634
2928
|
};
|
|
2635
|
-
}
|
|
2636
|
-
|
|
2929
|
+
} //处理需要增加图元的数据(避免意外问题)
|
|
2930
|
+
|
|
2637
2931
|
}, {
|
|
2638
2932
|
key: "dealAdd",
|
|
2639
2933
|
value: function dealAdd(ary, ids) {
|
|
2640
2934
|
var ads = [],
|
|
2641
|
-
|
|
2935
|
+
otherupds = [];
|
|
2936
|
+
|
|
2642
2937
|
for (var i = 0; i < ary.length; i++) {
|
|
2643
2938
|
if (ids.indexOf(ary[i].id) > -1) {
|
|
2644
2939
|
otherupds.push(ary[i]);
|
|
@@ -2646,17 +2941,19 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2646
2941
|
ads.push(ary[i]);
|
|
2647
2942
|
}
|
|
2648
2943
|
}
|
|
2944
|
+
|
|
2649
2945
|
return {
|
|
2650
2946
|
ads: ads,
|
|
2651
2947
|
otherupds: otherupds
|
|
2652
2948
|
};
|
|
2653
|
-
}
|
|
2654
|
-
|
|
2949
|
+
} //处理需要更新图元的数据(避免意外问题)
|
|
2950
|
+
|
|
2655
2951
|
}, {
|
|
2656
2952
|
key: "dealUpdate",
|
|
2657
2953
|
value: function dealUpdate(ary, ids) {
|
|
2658
2954
|
var upds = [],
|
|
2659
|
-
|
|
2955
|
+
otherads = [];
|
|
2956
|
+
|
|
2660
2957
|
for (var i = 0; i < ary.length; i++) {
|
|
2661
2958
|
if (ids.indexOf(ary[i].id) > -1) {
|
|
2662
2959
|
upds.push(ary[i]);
|
|
@@ -2664,6 +2961,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2664
2961
|
otherads.push(ary[i]);
|
|
2665
2962
|
}
|
|
2666
2963
|
}
|
|
2964
|
+
|
|
2667
2965
|
return {
|
|
2668
2966
|
upds: upds,
|
|
2669
2967
|
otherads: otherads
|
|
@@ -2726,6 +3024,7 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2726
3024
|
value: function componentWillUnmount() {
|
|
2727
3025
|
//关闭moveTo定时
|
|
2728
3026
|
var t = this;
|
|
3027
|
+
|
|
2729
3028
|
for (var i in t.GM.allParam) {
|
|
2730
3029
|
if (t.GM.allParam[i].geometryType == 'point') {
|
|
2731
3030
|
if (t.GM.getGraphic[i]) {
|
|
@@ -2733,9 +3032,11 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2733
3032
|
}
|
|
2734
3033
|
}
|
|
2735
3034
|
}
|
|
3035
|
+
|
|
2736
3036
|
if (t.pointCollectTimer) {
|
|
2737
3037
|
clearTimeout(t.pointCollectTimer);
|
|
2738
3038
|
}
|
|
3039
|
+
|
|
2739
3040
|
window.VtxMap[t.state.mapId] = null;
|
|
2740
3041
|
}
|
|
2741
3042
|
}, {
|
|
@@ -2743,15 +3044,15 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2743
3044
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
2744
3045
|
//重新渲染结束
|
|
2745
3046
|
var t = this;
|
|
2746
|
-
var props = t.props;
|
|
2747
|
-
|
|
2748
|
-
if (!t.mapCreated) return;
|
|
3047
|
+
var props = t.props; // 等待地图加载
|
|
3048
|
+
|
|
3049
|
+
if (!t.mapCreated) return; //回调显示方法
|
|
2749
3050
|
|
|
2750
|
-
//回调显示方法
|
|
2751
3051
|
if (props.showGraphicById) {
|
|
2752
3052
|
props.showGraphicById(t.showGraphicById.bind(t));
|
|
2753
|
-
}
|
|
2754
|
-
|
|
3053
|
+
} //回调隐藏方法
|
|
3054
|
+
|
|
3055
|
+
|
|
2755
3056
|
if (props.hideGraphicById) {
|
|
2756
3057
|
props.hideGraphicById(t.hideGraphicById.bind(t));
|
|
2757
3058
|
}
|
|
@@ -2760,81 +3061,86 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2760
3061
|
key: "UNSAFE_componentWillReceiveProps",
|
|
2761
3062
|
value: function UNSAFE_componentWillReceiveProps(nextProps, prevProps) {
|
|
2762
3063
|
//已加载组件,收到新的参数时调用
|
|
2763
|
-
var t = this;
|
|
2764
|
-
|
|
3064
|
+
var t = this; //点/线旧数据
|
|
3065
|
+
|
|
2765
3066
|
var _t$state = t.state,
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
3067
|
+
pointIds = _t$state.pointIds,
|
|
3068
|
+
lineIds = _t$state.lineIds,
|
|
3069
|
+
polygonIds = _t$state.polygonIds,
|
|
3070
|
+
circleIds = _t$state.circleIds,
|
|
3071
|
+
drawIds = _t$state.drawIds;
|
|
2771
3072
|
var point = drawIds.point,
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
3073
|
+
polyline = drawIds.polyline,
|
|
3074
|
+
polygon = drawIds.polygon,
|
|
3075
|
+
circle = drawIds.circle,
|
|
3076
|
+
rectangle = drawIds.rectangle; //点/线新数据
|
|
3077
|
+
|
|
2777
3078
|
var _nextProps$mapPoints = nextProps.mapPoints,
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
var props = t.props;
|
|
2819
|
-
|
|
3079
|
+
mapPoints = _nextProps$mapPoints === void 0 ? [] : _nextProps$mapPoints,
|
|
3080
|
+
_nextProps$mapLines = nextProps.mapLines,
|
|
3081
|
+
mapLines = _nextProps$mapLines === void 0 ? [] : _nextProps$mapLines,
|
|
3082
|
+
_nextProps$mapPolygon = nextProps.mapPolygons,
|
|
3083
|
+
mapPolygons = _nextProps$mapPolygon === void 0 ? [] : _nextProps$mapPolygon,
|
|
3084
|
+
_nextProps$mapCircles = nextProps.mapCircles,
|
|
3085
|
+
mapCircles = _nextProps$mapCircles === void 0 ? [] : _nextProps$mapCircles,
|
|
3086
|
+
_nextProps$customized = nextProps.customizedBoundary,
|
|
3087
|
+
customizedBoundary = _nextProps$customized === void 0 ? [] : _nextProps$customized,
|
|
3088
|
+
isOpenTrafficInfo = nextProps.isOpenTrafficInfo,
|
|
3089
|
+
boundaryName = nextProps.boundaryName,
|
|
3090
|
+
heatMapData = nextProps.heatMapData,
|
|
3091
|
+
imageOverlays = nextProps.imageOverlays,
|
|
3092
|
+
mapVisiblePoints = nextProps.mapVisiblePoints,
|
|
3093
|
+
setVisiblePoints = nextProps.setVisiblePoints,
|
|
3094
|
+
setCenter = nextProps.setCenter,
|
|
3095
|
+
mapCenter = nextProps.mapCenter,
|
|
3096
|
+
setZoomLevel = nextProps.setZoomLevel,
|
|
3097
|
+
mapZoomLevel = nextProps.mapZoomLevel,
|
|
3098
|
+
setCluster = nextProps.setCluster,
|
|
3099
|
+
mapCluster = nextProps.mapCluster,
|
|
3100
|
+
isRangingTool = nextProps.isRangingTool,
|
|
3101
|
+
mapRangingTool = nextProps.mapRangingTool,
|
|
3102
|
+
isRemove = nextProps.isRemove,
|
|
3103
|
+
mapRemove = nextProps.mapRemove,
|
|
3104
|
+
mapDraw = nextProps.mapDraw,
|
|
3105
|
+
isDraw = nextProps.isDraw,
|
|
3106
|
+
isCloseDraw = nextProps.isCloseDraw,
|
|
3107
|
+
editGraphicId = nextProps.editGraphicId,
|
|
3108
|
+
isDoEdit = nextProps.isDoEdit,
|
|
3109
|
+
isEndEdit = nextProps.isEndEdit,
|
|
3110
|
+
isClearAll = nextProps.isClearAll,
|
|
3111
|
+
mapPointCollection = nextProps.mapPointCollection,
|
|
3112
|
+
isclearAllPointCollection = nextProps.isclearAllPointCollection,
|
|
3113
|
+
isSetAreaRestriction = nextProps.isSetAreaRestriction,
|
|
3114
|
+
areaRestriction = nextProps.areaRestriction,
|
|
3115
|
+
isClearAreaRestriction = nextProps.isClearAreaRestriction,
|
|
3116
|
+
mapStyle = nextProps.mapStyle,
|
|
3117
|
+
coverageType = nextProps.coverageType,
|
|
3118
|
+
infoWindowData = nextProps.infoWindowData;
|
|
3119
|
+
var props = t.props; // 设置地图样式
|
|
3120
|
+
|
|
2820
3121
|
if (mapStyle && !t.deepEqual(mapStyle, t.props.mapStyle)) {
|
|
2821
3122
|
t.state.gis.setMapStyle(mapStyle);
|
|
2822
|
-
}
|
|
2823
|
-
|
|
3123
|
+
} // 切换地图矢量图和卫星图背景
|
|
3124
|
+
|
|
3125
|
+
|
|
2824
3126
|
if (coverageType && !t.deepEqual(coverageType, t.props.coverageType)) {
|
|
2825
3127
|
t.setMapType(coverageType);
|
|
2826
|
-
}
|
|
2827
|
-
|
|
3128
|
+
} // 等待地图加载
|
|
3129
|
+
|
|
3130
|
+
|
|
2828
3131
|
if (!t.mapCreated) return;
|
|
3132
|
+
|
|
2829
3133
|
if (mapPointCollection instanceof Array && props.mapPointCollection instanceof Array && !t.deepEqual(mapPointCollection, t.props.mapPointCollection)) {
|
|
2830
3134
|
var _t$dataMatch = t.dataMatch(t.props.mapPointCollection, mapPointCollection, 'id'),
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
3135
|
+
deletedDataIDs = _t$dataMatch.deletedDataIDs,
|
|
3136
|
+
addedData = _t$dataMatch.addedData,
|
|
3137
|
+
updatedData = _t$dataMatch.updatedData;
|
|
3138
|
+
|
|
2834
3139
|
t.clearPointCollection(deletedDataIDs);
|
|
2835
3140
|
t.addPointCollection(addedData);
|
|
2836
3141
|
t.updatePointCollection(updatedData);
|
|
2837
3142
|
}
|
|
3143
|
+
|
|
2838
3144
|
if (typeof isclearAllPointCollection == 'boolean' && isclearAllPointCollection || isclearAllPointCollection && isclearAllPointCollection !== t.props.isclearAllPointCollection) {
|
|
2839
3145
|
t.clearAllPointCollection();
|
|
2840
3146
|
}
|
|
@@ -2843,10 +3149,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2843
3149
|
pointData[1]的数据在idsForGraphicId中不存在的,执行新增
|
|
2844
3150
|
pointData[0]数据中多余的id,执行删除
|
|
2845
3151
|
*/
|
|
3152
|
+
|
|
3153
|
+
|
|
2846
3154
|
if (mapPoints instanceof Array && props.mapPoints instanceof Array && !t.deepEqual(mapPoints, props.mapPoints)) {
|
|
2847
3155
|
var oldMapPoints = props.mapPoints;
|
|
2848
|
-
var newMapPoints = mapPoints;
|
|
2849
|
-
|
|
3156
|
+
var newMapPoints = mapPoints; //过滤编辑的图元
|
|
3157
|
+
|
|
2850
3158
|
if (!!t.state.editId) {
|
|
2851
3159
|
oldMapPoints = props.mapPoints.filter(function (item) {
|
|
2852
3160
|
return item.id !== editGraphicId;
|
|
@@ -2855,41 +3163,50 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2855
3163
|
return item.id !== editGraphicId;
|
|
2856
3164
|
});
|
|
2857
3165
|
}
|
|
3166
|
+
|
|
2858
3167
|
var _t$dataMatch2 = t.dataMatch(oldMapPoints, newMapPoints, 'id'),
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
3168
|
+
_deletedDataIDs = _t$dataMatch2.deletedDataIDs,
|
|
3169
|
+
_addedData = _t$dataMatch2.addedData,
|
|
3170
|
+
_updatedData = _t$dataMatch2.updatedData;
|
|
3171
|
+
|
|
2862
3172
|
var _t$dealAdd = t.dealAdd(_addedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
|
|
2863
|
-
|
|
2864
|
-
|
|
3173
|
+
ads = _t$dealAdd.ads,
|
|
3174
|
+
otherupds = _t$dealAdd.otherupds;
|
|
3175
|
+
|
|
2865
3176
|
var _t$dealUpdate = t.dealUpdate(_updatedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
3177
|
+
upds = _t$dealUpdate.upds,
|
|
3178
|
+
otherads = _t$dealUpdate.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
3179
|
+
|
|
3180
|
+
|
|
2869
3181
|
var _iterator = _createForOfIteratorHelper(_deletedDataIDs),
|
|
2870
|
-
|
|
3182
|
+
_step;
|
|
3183
|
+
|
|
2871
3184
|
try {
|
|
2872
3185
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2873
3186
|
var id = _step.value;
|
|
2874
3187
|
t.removeGraphic(id, 'point');
|
|
2875
|
-
}
|
|
2876
|
-
|
|
3188
|
+
} //增加
|
|
3189
|
+
|
|
2877
3190
|
} catch (err) {
|
|
2878
3191
|
_iterator.e(err);
|
|
2879
3192
|
} finally {
|
|
2880
3193
|
_iterator.f();
|
|
2881
3194
|
}
|
|
2882
|
-
|
|
2883
|
-
//更新
|
|
3195
|
+
|
|
3196
|
+
t.addPoint([].concat(_toConsumableArray(ads), _toConsumableArray(otherads))); //更新
|
|
3197
|
+
|
|
2884
3198
|
t.updatePoint([].concat(_toConsumableArray(upds), _toConsumableArray(otherupds)));
|
|
2885
3199
|
}
|
|
2886
3200
|
/*
|
|
2887
3201
|
面数据处理
|
|
2888
3202
|
先全删除,再新增
|
|
2889
3203
|
*/
|
|
3204
|
+
|
|
3205
|
+
|
|
2890
3206
|
if (mapPolygons instanceof Array && props.mapPolygons instanceof Array && !t.deepEqual(mapPolygons, props.mapPolygons)) {
|
|
2891
3207
|
var oldMapPolygons = props.mapPolygons;
|
|
2892
3208
|
var newMapPolygons = mapPolygons;
|
|
3209
|
+
|
|
2893
3210
|
if (!!t.state.editId) {
|
|
2894
3211
|
oldMapPolygons = props.mapPolygons.filter(function (item) {
|
|
2895
3212
|
return item.id !== editGraphicId;
|
|
@@ -2898,41 +3215,50 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2898
3215
|
return item.id !== editGraphicId;
|
|
2899
3216
|
});
|
|
2900
3217
|
}
|
|
3218
|
+
|
|
2901
3219
|
var _t$dataMatch3 = t.dataMatch(oldMapPolygons, newMapPolygons, 'id'),
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
3220
|
+
_deletedDataIDs2 = _t$dataMatch3.deletedDataIDs,
|
|
3221
|
+
_addedData2 = _t$dataMatch3.addedData,
|
|
3222
|
+
_updatedData2 = _t$dataMatch3.updatedData;
|
|
3223
|
+
|
|
2905
3224
|
var _t$dealAdd2 = t.dealAdd(_addedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
|
|
2906
|
-
|
|
2907
|
-
|
|
3225
|
+
_ads = _t$dealAdd2.ads,
|
|
3226
|
+
_otherupds = _t$dealAdd2.otherupds;
|
|
3227
|
+
|
|
2908
3228
|
var _t$dealUpdate2 = t.dealUpdate(_updatedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
3229
|
+
_upds = _t$dealUpdate2.upds,
|
|
3230
|
+
_otherads = _t$dealUpdate2.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
3231
|
+
|
|
3232
|
+
|
|
2912
3233
|
var _iterator2 = _createForOfIteratorHelper(_deletedDataIDs2),
|
|
2913
|
-
|
|
3234
|
+
_step2;
|
|
3235
|
+
|
|
2914
3236
|
try {
|
|
2915
3237
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2916
3238
|
var _id = _step2.value;
|
|
2917
3239
|
t.removeGraphic(_id, 'polygon');
|
|
2918
|
-
}
|
|
2919
|
-
|
|
3240
|
+
} //增加
|
|
3241
|
+
|
|
2920
3242
|
} catch (err) {
|
|
2921
3243
|
_iterator2.e(err);
|
|
2922
3244
|
} finally {
|
|
2923
3245
|
_iterator2.f();
|
|
2924
3246
|
}
|
|
2925
|
-
|
|
2926
|
-
//更新
|
|
3247
|
+
|
|
3248
|
+
t.addPolygon([].concat(_toConsumableArray(_ads), _toConsumableArray(_otherads))); //更新
|
|
3249
|
+
|
|
2927
3250
|
t.updatePolygon([].concat(_toConsumableArray(_upds), _toConsumableArray(_otherupds)));
|
|
2928
3251
|
}
|
|
2929
3252
|
/*
|
|
2930
3253
|
面数据处理
|
|
2931
3254
|
先全删除,再新增
|
|
2932
3255
|
*/
|
|
3256
|
+
|
|
3257
|
+
|
|
2933
3258
|
if (mapCircles instanceof Array && props.mapCircles instanceof Array && !t.deepEqual(mapCircles, props.mapCircles)) {
|
|
2934
3259
|
var oldMapCircles = props.mapCircles;
|
|
2935
3260
|
var newMapCircles = mapCircles;
|
|
3261
|
+
|
|
2936
3262
|
if (!!t.state.editId) {
|
|
2937
3263
|
oldMapCircles = props.mapCircles.filter(function (item) {
|
|
2938
3264
|
return item.id !== editGraphicId;
|
|
@@ -2941,41 +3267,50 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2941
3267
|
return item.id !== editGraphicId;
|
|
2942
3268
|
});
|
|
2943
3269
|
}
|
|
3270
|
+
|
|
2944
3271
|
var _t$dataMatch4 = t.dataMatch(oldMapCircles, newMapCircles, 'id'),
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
3272
|
+
_deletedDataIDs3 = _t$dataMatch4.deletedDataIDs,
|
|
3273
|
+
_addedData3 = _t$dataMatch4.addedData,
|
|
3274
|
+
_updatedData3 = _t$dataMatch4.updatedData;
|
|
3275
|
+
|
|
2948
3276
|
var _t$dealAdd3 = t.dealAdd(_addedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
|
|
2949
|
-
|
|
2950
|
-
|
|
3277
|
+
_ads2 = _t$dealAdd3.ads,
|
|
3278
|
+
_otherupds2 = _t$dealAdd3.otherupds;
|
|
3279
|
+
|
|
2951
3280
|
var _t$dealUpdate3 = t.dealUpdate(_updatedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
3281
|
+
_upds2 = _t$dealUpdate3.upds,
|
|
3282
|
+
_otherads2 = _t$dealUpdate3.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
3283
|
+
|
|
3284
|
+
|
|
2955
3285
|
var _iterator3 = _createForOfIteratorHelper(_deletedDataIDs3),
|
|
2956
|
-
|
|
3286
|
+
_step3;
|
|
3287
|
+
|
|
2957
3288
|
try {
|
|
2958
3289
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2959
3290
|
var _id2 = _step3.value;
|
|
2960
3291
|
t.removeGraphic(_id2, 'circle');
|
|
2961
|
-
}
|
|
2962
|
-
|
|
3292
|
+
} //增加
|
|
3293
|
+
|
|
2963
3294
|
} catch (err) {
|
|
2964
3295
|
_iterator3.e(err);
|
|
2965
3296
|
} finally {
|
|
2966
3297
|
_iterator3.f();
|
|
2967
3298
|
}
|
|
2968
|
-
|
|
2969
|
-
//更新
|
|
3299
|
+
|
|
3300
|
+
t.addCircle([].concat(_toConsumableArray(_ads2), _toConsumableArray(_otherads2))); //更新
|
|
3301
|
+
|
|
2970
3302
|
t.updateCircle([].concat(_toConsumableArray(_upds2), _toConsumableArray(_otherupds2)));
|
|
2971
3303
|
}
|
|
2972
3304
|
/*
|
|
2973
3305
|
线数据处理
|
|
2974
3306
|
先全删除,再新增
|
|
2975
3307
|
*/
|
|
3308
|
+
|
|
3309
|
+
|
|
2976
3310
|
if (mapLines instanceof Array && props.mapLines instanceof Array && !t.deepEqual(mapLines, props.mapLines)) {
|
|
2977
3311
|
var oldMapLines = props.mapLines;
|
|
2978
3312
|
var newMapLines = mapLines;
|
|
3313
|
+
|
|
2979
3314
|
if (!!t.state.editId) {
|
|
2980
3315
|
oldMapLines = props.mapLines.filter(function (item) {
|
|
2981
3316
|
return item.id !== editGraphicId;
|
|
@@ -2984,43 +3319,52 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2984
3319
|
return item.id !== editGraphicId;
|
|
2985
3320
|
});
|
|
2986
3321
|
}
|
|
3322
|
+
|
|
2987
3323
|
var _t$dataMatch5 = t.dataMatch(oldMapLines, newMapLines, 'id'),
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
3324
|
+
_deletedDataIDs4 = _t$dataMatch5.deletedDataIDs,
|
|
3325
|
+
_addedData4 = _t$dataMatch5.addedData,
|
|
3326
|
+
_updatedData4 = _t$dataMatch5.updatedData;
|
|
3327
|
+
|
|
2991
3328
|
var _t$dealAdd4 = t.dealAdd(_addedData4, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
|
|
2992
|
-
|
|
2993
|
-
|
|
3329
|
+
_ads3 = _t$dealAdd4.ads,
|
|
3330
|
+
_otherupds3 = _t$dealAdd4.otherupds;
|
|
3331
|
+
|
|
2994
3332
|
var _t$dealUpdate4 = t.dealUpdate(_updatedData4, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
3333
|
+
_upds3 = _t$dealUpdate4.upds,
|
|
3334
|
+
_otherads3 = _t$dealUpdate4.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
3335
|
+
|
|
3336
|
+
|
|
2998
3337
|
var _iterator4 = _createForOfIteratorHelper(_deletedDataIDs4),
|
|
2999
|
-
|
|
3338
|
+
_step4;
|
|
3339
|
+
|
|
3000
3340
|
try {
|
|
3001
3341
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
3002
3342
|
var _id3 = _step4.value;
|
|
3003
3343
|
t.removeGraphic(_id3, 'line');
|
|
3004
|
-
}
|
|
3005
|
-
|
|
3344
|
+
} //增加
|
|
3345
|
+
|
|
3006
3346
|
} catch (err) {
|
|
3007
3347
|
_iterator4.e(err);
|
|
3008
3348
|
} finally {
|
|
3009
3349
|
_iterator4.f();
|
|
3010
3350
|
}
|
|
3011
|
-
|
|
3012
|
-
//更新
|
|
3351
|
+
|
|
3352
|
+
t.addLine([].concat(_toConsumableArray(_ads3), _toConsumableArray(_otherads3))); //更新
|
|
3353
|
+
|
|
3013
3354
|
t.updateLine([].concat(_toConsumableArray(_upds3), _toConsumableArray(_otherupds3)));
|
|
3014
|
-
}
|
|
3015
|
-
|
|
3355
|
+
} //画其他特例线专用
|
|
3356
|
+
|
|
3357
|
+
|
|
3016
3358
|
if (customizedBoundary instanceof Array && props.customizedBoundary instanceof Array && !t.deepEqual(customizedBoundary, props.customizedBoundary)) {
|
|
3017
3359
|
var _t$dataMatch6 = t.dataMatch(props.customizedBoundary, customizedBoundary, 'id'),
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3360
|
+
_deletedDataIDs5 = _t$dataMatch6.deletedDataIDs,
|
|
3361
|
+
_addedData5 = _t$dataMatch6.addedData,
|
|
3362
|
+
_updatedData5 = _t$dataMatch6.updatedData; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
3363
|
+
|
|
3364
|
+
|
|
3022
3365
|
var _iterator5 = _createForOfIteratorHelper(_deletedDataIDs5),
|
|
3023
|
-
|
|
3366
|
+
_step5;
|
|
3367
|
+
|
|
3024
3368
|
try {
|
|
3025
3369
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
3026
3370
|
var _id4 = _step5.value;
|
|
@@ -3031,10 +3375,12 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3031
3375
|
} finally {
|
|
3032
3376
|
_iterator5.f();
|
|
3033
3377
|
}
|
|
3378
|
+
|
|
3034
3379
|
t.updateLine(_updatedData5);
|
|
3035
3380
|
t.addLine(_addedData5);
|
|
3036
|
-
}
|
|
3037
|
-
|
|
3381
|
+
} //绘制边界线
|
|
3382
|
+
|
|
3383
|
+
|
|
3038
3384
|
if (boundaryName instanceof Array && props.boundaryName instanceof Array && !t.deepEqual(boundaryName, props.boundaryName)) {
|
|
3039
3385
|
var newBDName = Set(boundaryName);
|
|
3040
3386
|
var oldBDName = Set(props.boundaryName);
|
|
@@ -3042,104 +3388,128 @@ var VortexAMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3042
3388
|
var addedBoundaryName = newBDName.subtract(oldBDName).toJS();
|
|
3043
3389
|
t.removeBaiduBoundary(removedBoundaryName);
|
|
3044
3390
|
t.addBaiduBoundary(addedBoundaryName);
|
|
3045
|
-
}
|
|
3046
|
-
|
|
3391
|
+
} // 获取热力图
|
|
3392
|
+
|
|
3393
|
+
|
|
3047
3394
|
if (heatMapData && !t.deepEqual(heatMapData, props.heatMapData)) {
|
|
3048
3395
|
t.heatMapOverlay(heatMapData);
|
|
3049
|
-
}
|
|
3050
|
-
|
|
3396
|
+
} // 打开信息窗体
|
|
3397
|
+
|
|
3398
|
+
|
|
3051
3399
|
if (infoWindowData && !t.deepEqual(infoWindowData, t.props.infoWindowData)) {
|
|
3052
3400
|
t.infoWindow(infoWindowData);
|
|
3053
|
-
}
|
|
3054
|
-
|
|
3401
|
+
} //添加图片图层
|
|
3402
|
+
|
|
3403
|
+
|
|
3055
3404
|
if (imageOverlays instanceof Array && props.imageOverlays instanceof Array && !t.deepEqual(imageOverlays, props.imageOverlays)) {
|
|
3056
3405
|
t.imageUrlOverlay(imageOverlays);
|
|
3057
|
-
}
|
|
3058
|
-
|
|
3406
|
+
} //图元编辑调用
|
|
3407
|
+
|
|
3408
|
+
|
|
3059
3409
|
if (typeof isDoEdit == 'boolean' && isDoEdit || isDoEdit && isDoEdit !== t.props.isDoEdit) {
|
|
3060
3410
|
t.doEdit(editGraphicId);
|
|
3061
|
-
}
|
|
3062
|
-
|
|
3411
|
+
} //是否关闭图元编辑
|
|
3412
|
+
|
|
3413
|
+
|
|
3063
3414
|
if (typeof isEndEdit == 'boolean' && isEndEdit || isEndEdit && isEndEdit !== t.props.isEndEdit) {
|
|
3064
3415
|
t.endEdit();
|
|
3065
3416
|
}
|
|
3066
3417
|
/*设置指定图元展示*/
|
|
3418
|
+
|
|
3419
|
+
|
|
3067
3420
|
if (typeof setVisiblePoints == 'boolean' && setVisiblePoints || setVisiblePoints && setVisiblePoints !== t.props.setVisiblePoints) {
|
|
3068
3421
|
t.setVisiblePoints(mapVisiblePoints);
|
|
3069
|
-
}
|
|
3070
|
-
|
|
3422
|
+
} //绘制图元
|
|
3423
|
+
|
|
3424
|
+
|
|
3071
3425
|
if (typeof isDraw == 'boolean' && isDraw || isDraw && isDraw !== t.props.isDraw) {
|
|
3072
3426
|
t.draw(mapDraw);
|
|
3073
|
-
}
|
|
3074
|
-
|
|
3427
|
+
} //关闭绘制
|
|
3428
|
+
|
|
3429
|
+
|
|
3075
3430
|
if (typeof isCloseDraw == 'boolean' && isCloseDraw || isCloseDraw && isCloseDraw !== t.props.isCloseDraw) {
|
|
3076
3431
|
t.closeDraw();
|
|
3077
|
-
}
|
|
3078
|
-
|
|
3432
|
+
} //清空地图
|
|
3433
|
+
|
|
3434
|
+
|
|
3079
3435
|
if (typeof isClearAll == 'boolean' && isClearAll || isClearAll && isClearAll !== t.props.isClearAll) {
|
|
3080
3436
|
t.clearAll();
|
|
3081
|
-
}
|
|
3082
|
-
|
|
3437
|
+
} //设置中心点
|
|
3438
|
+
|
|
3439
|
+
|
|
3083
3440
|
if (typeof setCenter == 'boolean' && setCenter || setCenter && setCenter !== t.props.setCenter) {
|
|
3084
3441
|
if (!(t.getCurrentCenter().lng == mapCenter[0] && t.getCurrentCenter().lat == mapCenter[1])) {
|
|
3085
3442
|
t.setCenter(mapCenter);
|
|
3086
3443
|
}
|
|
3087
|
-
}
|
|
3088
|
-
|
|
3444
|
+
} //设置比例尺
|
|
3445
|
+
|
|
3446
|
+
|
|
3089
3447
|
if (typeof setZoomLevel == 'boolean' && setZoomLevel || setZoomLevel && setZoomLevel !== t.props.setZoomLevel) {
|
|
3090
3448
|
if (!(t.getZoomLevel() == mapZoomLevel)) {
|
|
3091
3449
|
t.setZoomLevel(mapZoomLevel);
|
|
3092
3450
|
}
|
|
3093
|
-
}
|
|
3094
|
-
|
|
3451
|
+
} //是否打开路况
|
|
3452
|
+
|
|
3453
|
+
|
|
3095
3454
|
if (isOpenTrafficInfo) {
|
|
3096
3455
|
t.openTrafficInfo();
|
|
3097
3456
|
} else {
|
|
3098
3457
|
t.hideTrafficInfo();
|
|
3099
|
-
}
|
|
3100
|
-
|
|
3458
|
+
} //设置点聚合
|
|
3459
|
+
|
|
3460
|
+
|
|
3101
3461
|
if (typeof setCluster == 'boolean' && setCluster || setCluster && setCluster !== t.props.setCluster) {
|
|
3102
3462
|
t.cluster(mapCluster);
|
|
3103
|
-
}
|
|
3104
|
-
|
|
3463
|
+
} // 清除聚合
|
|
3464
|
+
|
|
3465
|
+
|
|
3105
3466
|
if (!setCluster && setCluster !== t.props.setCluster) {
|
|
3106
3467
|
t.removeCluster(mapCluster);
|
|
3107
|
-
}
|
|
3108
|
-
|
|
3468
|
+
} //测距工具调用
|
|
3469
|
+
|
|
3470
|
+
|
|
3109
3471
|
if (typeof isRangingTool == 'boolean' && isRangingTool || isRangingTool && isRangingTool !== t.props.isRangingTool) {
|
|
3110
3472
|
t.vtxRangingTool();
|
|
3111
|
-
}
|
|
3112
|
-
|
|
3473
|
+
} //单独删除操作
|
|
3474
|
+
|
|
3475
|
+
|
|
3113
3476
|
if (typeof isRemove == 'boolean' && isRemove || isRemove && isRemove !== t.props.isRemove) {
|
|
3114
3477
|
mapRemove.map(function (item, index) {
|
|
3115
3478
|
t.removeGraphic(item.id, item.type);
|
|
3116
3479
|
});
|
|
3117
|
-
}
|
|
3118
|
-
|
|
3480
|
+
} //设置区域限制
|
|
3481
|
+
|
|
3482
|
+
|
|
3119
3483
|
if (typeof isSetAreaRestriction == 'boolean' && isSetAreaRestriction || isSetAreaRestriction && isSetAreaRestriction !== t.props.isSetAreaRestriction && areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
|
|
3120
3484
|
t.setAreaRestriction(areaRestriction);
|
|
3121
|
-
}
|
|
3122
|
-
|
|
3485
|
+
} //关闭区域限制
|
|
3486
|
+
|
|
3487
|
+
|
|
3123
3488
|
if (typeof isClearAreaRestriction == 'boolean' && isClearAreaRestriction || isClearAreaRestriction && isClearAreaRestriction !== t.props.isClearAreaRestriction) {
|
|
3124
3489
|
t.clearAreaRestriction();
|
|
3125
|
-
}
|
|
3490
|
+
} // 比例尺控件位置改变
|
|
3491
|
+
|
|
3126
3492
|
|
|
3127
|
-
// 比例尺控件位置改变
|
|
3128
3493
|
if (nextProps.showControl && JSON.stringify(nextProps.showControl) != JSON.stringify(t.props.showControl)) {
|
|
3129
3494
|
t.showControl(nextProps);
|
|
3130
|
-
}
|
|
3131
|
-
|
|
3495
|
+
} // 比例尺移除
|
|
3496
|
+
|
|
3497
|
+
|
|
3132
3498
|
if (!nextProps.showControl) {
|
|
3133
3499
|
t.removeControl();
|
|
3134
|
-
}
|
|
3135
|
-
|
|
3500
|
+
} // 地图类型控件位置改变
|
|
3501
|
+
|
|
3502
|
+
|
|
3136
3503
|
if (nextProps.satelliteSwitch && JSON.stringify(nextProps.satelliteSwitch) != JSON.stringify(t.props.satelliteSwitch)) {
|
|
3137
3504
|
t.showMapTypeControl(nextProps);
|
|
3138
3505
|
}
|
|
3139
3506
|
}
|
|
3140
3507
|
}]);
|
|
3508
|
+
|
|
3141
3509
|
return VortexAMap;
|
|
3142
3510
|
}(_react["default"].Component);
|
|
3143
|
-
|
|
3511
|
+
|
|
3512
|
+
var _default = VortexAMap;
|
|
3513
|
+
exports["default"] = _default;
|
|
3144
3514
|
module.exports = exports["default"];
|
|
3145
3515
|
//# sourceMappingURL=AMap.js.map
|