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