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