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