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