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