@vtx/map 1.1.43 → 1.1.45
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 +1012 -640
- package/lib/VtxMap/AMap/AMap.js.map +1 -1
- package/lib/VtxMap/BMap/Map.js +1197 -749
- package/lib/VtxMap/BMap/Map.js.map +1 -1
- package/lib/VtxMap/GMap/Map.js +1564 -1046
- package/lib/VtxMap/GMap/Map.js.map +1 -1
- package/lib/VtxMap/Map.js +42 -8
- package/lib/VtxMap/Map.js.map +1 -1
- package/lib/VtxMap/MapToolFunction.js +63 -26
- package/lib/VtxMap/MapToolFunction.js.map +1 -1
- package/lib/VtxMap/OMap/Map.js +1361 -867
- package/lib/VtxMap/OMap/Map.js.map +1 -1
- package/lib/VtxMap/OlMap/Map.js +1289 -699
- package/lib/VtxMap/OlMap/Map.js.map +1 -1
- package/lib/VtxMap/TMap/TMap.js +1058 -651
- package/lib/VtxMap/TMap/TMap.js.map +1 -1
- package/lib/VtxMap/index.js +8 -1
- package/lib/VtxMap/index.js.map +1 -1
- package/lib/VtxMap/mapPlayer.js +123 -67
- package/lib/VtxMap/mapPlayer.js.map +1 -1
- package/lib/VtxMap/optimizingPointMap.js +77 -21
- package/lib/VtxMap/optimizingPointMap.js.map +1 -1
- package/lib/VtxMap/style/css.js +6 -0
- package/lib/VtxMap/style/css.js.map +1 -1
- package/lib/VtxMap/style/index.js +6 -0
- package/lib/VtxMap/style/index.js.map +1 -1
- package/lib/VtxMap/zoomMap.js +41 -12
- package/lib/VtxMap/zoomMap.js.map +1 -1
- package/lib/VtxModal/VtxModal.js +63 -19
- package/lib/VtxModal/VtxModal.js.map +1 -1
- package/lib/VtxModal/draggableModal.js +48 -12
- package/lib/VtxModal/draggableModal.js.map +1 -1
- package/lib/VtxModal/index.js +6 -1
- package/lib/VtxModal/index.js.map +1 -1
- package/lib/VtxModal/style/css.js +6 -0
- package/lib/VtxModal/style/css.js.map +1 -1
- package/lib/VtxModal/style/index.js +6 -0
- package/lib/VtxModal/style/index.js.map +1 -1
- package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js +238 -105
- package/lib/VtxSearchCheckMap/VtxSearchCheckMap.js.map +1 -1
- package/lib/VtxSearchCheckMap/index.js +2 -0
- package/lib/VtxSearchCheckMap/index.js.map +1 -1
- package/lib/VtxSearchCheckMap/mapping.js +2 -1
- package/lib/VtxSearchCheckMap/mapping.js.map +1 -1
- package/lib/VtxSearchCheckMap/style/css.js +19 -0
- package/lib/VtxSearchCheckMap/style/css.js.map +1 -1
- package/lib/VtxSearchCheckMap/style/index.js +19 -0
- package/lib/VtxSearchCheckMap/style/index.js.map +1 -1
- package/lib/VtxSearchMap/VtxSearchMap.js +289 -120
- package/lib/VtxSearchMap/VtxSearchMap.js.map +1 -1
- package/lib/VtxSearchMap/index.js +2 -0
- package/lib/VtxSearchMap/index.js.map +1 -1
- package/lib/VtxSearchMap/mapping.js +2 -1
- package/lib/VtxSearchMap/mapping.js.map +1 -1
- package/lib/VtxSearchMap/style/css.js +19 -0
- package/lib/VtxSearchMap/style/css.js.map +1 -1
- package/lib/VtxSearchMap/style/index.js +19 -0
- package/lib/VtxSearchMap/style/index.js.map +1 -1
- package/lib/default.js +13 -4
- package/lib/default.js.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/util.js +94 -0
- package/lib/utils/util.js.map +1 -0
- package/package.json +1 -1
package/lib/VtxMap/OlMap/Map.js
CHANGED
|
@@ -1,57 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
7
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
8
12
|
var _default2 = _interopRequireDefault(require("../../default"));
|
|
13
|
+
|
|
9
14
|
var _MapToolFunction = require("../MapToolFunction");
|
|
15
|
+
|
|
10
16
|
var _immutable = _interopRequireDefault(require("immutable"));
|
|
17
|
+
|
|
11
18
|
var _lodash = require("lodash");
|
|
19
|
+
|
|
12
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
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(
|
|
21
|
+
|
|
22
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, 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(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
23
|
+
|
|
15
24
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
25
|
+
|
|
16
26
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
27
|
+
|
|
17
28
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
29
|
+
|
|
18
30
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
31
|
+
|
|
19
32
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
33
|
+
|
|
20
34
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
35
|
+
|
|
21
36
|
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); }
|
|
22
|
-
|
|
23
|
-
function
|
|
37
|
+
|
|
38
|
+
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; }
|
|
39
|
+
|
|
40
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
41
|
+
|
|
24
42
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
|
-
|
|
26
|
-
function
|
|
43
|
+
|
|
44
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
45
|
+
|
|
46
|
+
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; }
|
|
47
|
+
|
|
27
48
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
28
|
-
|
|
49
|
+
|
|
50
|
+
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); } }
|
|
51
|
+
|
|
29
52
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
53
|
+
|
|
30
54
|
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); }
|
|
55
|
+
|
|
31
56
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
57
|
+
|
|
32
58
|
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); }; }
|
|
59
|
+
|
|
33
60
|
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); }
|
|
61
|
+
|
|
34
62
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
63
|
+
|
|
35
64
|
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; } }
|
|
65
|
+
|
|
36
66
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
67
|
+
|
|
68
|
+
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; }
|
|
69
|
+
|
|
40
70
|
var Set = _immutable["default"].Set;
|
|
71
|
+
|
|
41
72
|
var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
42
73
|
_inherits(OlMap, _React$Component);
|
|
74
|
+
|
|
43
75
|
var _super = _createSuper(OlMap);
|
|
76
|
+
|
|
44
77
|
function OlMap(props) {
|
|
45
78
|
var _this;
|
|
79
|
+
|
|
46
80
|
_classCallCheck(this, OlMap);
|
|
81
|
+
|
|
47
82
|
_this = _super.call(this, props);
|
|
48
|
-
|
|
83
|
+
|
|
49
84
|
_defineProperty(_assertThisInitialized(_this), "loadLayers", function () {
|
|
50
85
|
var nextLayers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
51
86
|
var currentLayers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
52
87
|
var first = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
53
|
-
|
|
54
|
-
// 对比图层的变化,找出需要新增和需要删除的。
|
|
88
|
+
|
|
89
|
+
var t = _assertThisInitialized(_this); // 对比图层的变化,找出需要新增和需要删除的。
|
|
90
|
+
|
|
91
|
+
|
|
55
92
|
var addLayers = nextLayers.filter(function (item) {
|
|
56
93
|
return !currentLayers.map(function (e) {
|
|
57
94
|
return e.coverage;
|
|
@@ -62,6 +99,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
62
99
|
return e.coverage;
|
|
63
100
|
}).includes(item.coverage);
|
|
64
101
|
});
|
|
102
|
+
|
|
65
103
|
if (removeLayers.length > 0) {
|
|
66
104
|
removeLayers.forEach(function (item) {
|
|
67
105
|
var exist = t.olLayers.find(function (e) {
|
|
@@ -70,6 +108,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
70
108
|
exist && exist.layer.setVisible(false);
|
|
71
109
|
});
|
|
72
110
|
}
|
|
111
|
+
|
|
73
112
|
if (addLayers.length > 0) {
|
|
74
113
|
addLayers.map(function (item) {
|
|
75
114
|
if (item.coverage.startsWith("http") || item.coverage.startsWith('/')) {
|
|
@@ -79,17 +118,23 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
79
118
|
t.addSuperMapLayer(item.coverage);
|
|
80
119
|
break;
|
|
81
120
|
// geoServer_geoJSON
|
|
121
|
+
|
|
82
122
|
case 'geoServer':
|
|
83
123
|
t.addGeoServerLayer(item.coverage);
|
|
84
124
|
// geoServer_image
|
|
125
|
+
|
|
85
126
|
case 'geoServer_image':
|
|
86
127
|
t.addGeoServerImageLayer(item);
|
|
128
|
+
|
|
87
129
|
default:
|
|
88
130
|
break;
|
|
89
131
|
}
|
|
132
|
+
} else if (item.coverage.indexOf("WMTS") > -1) {
|
|
133
|
+
t.addTileLayer(JSON.parse(item.coverage));
|
|
90
134
|
} else if (OL_SCREEN[item.coverage]) {
|
|
91
135
|
if (first) {
|
|
92
136
|
var layers = eval(OL_SCREEN[item.coverage].initLayer);
|
|
137
|
+
|
|
93
138
|
if ((0, _lodash.isArray)(layers)) {
|
|
94
139
|
layers.map(function (layer) {
|
|
95
140
|
t.state.gis.addLayer(layer);
|
|
@@ -103,33 +148,50 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
103
148
|
} else {
|
|
104
149
|
if (first) {
|
|
105
150
|
var _layer = eval(OL_SCREEN["default"].initLayer);
|
|
151
|
+
|
|
106
152
|
t.state.gis.addLayer(_layer);
|
|
107
153
|
}
|
|
108
154
|
}
|
|
109
155
|
});
|
|
156
|
+
|
|
110
157
|
_this.zIndexGraphics = []; //需要放在最后的图元,zoom和pan时刷新dom到最后
|
|
158
|
+
|
|
111
159
|
_this.htmlPointsId = 'vtx_gmap_html_points'; //html点位容器id class管理
|
|
160
|
+
|
|
112
161
|
_this.pointCollectionId = 'vtx_gmap_html_pointCollection'; //海量点canvas点位容器id class管理
|
|
162
|
+
|
|
113
163
|
_this.Label = {}; //所有label 集合
|
|
164
|
+
|
|
114
165
|
_this.labelLayer = {
|
|
115
166
|
x: 0,
|
|
116
167
|
y: 0
|
|
117
168
|
}; //label图层 位置管理
|
|
169
|
+
|
|
118
170
|
_this.viewer = null;
|
|
119
171
|
_this.GM = new _MapToolFunction.graphicManage(); //初始化 图元管理方法
|
|
172
|
+
|
|
120
173
|
_this.getPolygonArea = _MapToolFunction.getPolygonArea;
|
|
121
174
|
_this.layer = null; //保存地图图层数据
|
|
175
|
+
|
|
122
176
|
_this.loadTimer = null; //初始化地图 load时延缓数据处理
|
|
177
|
+
|
|
123
178
|
_this.animTimer = {}; //点位跳动动画 定时集合
|
|
179
|
+
|
|
124
180
|
_this.animCount = {}; //点位跳动动画 定时计数
|
|
181
|
+
|
|
125
182
|
_this.moveToTimer = null; //moveTo时间对象
|
|
183
|
+
|
|
126
184
|
_this.drawToolbar = null; //地图绘制对象即interaction
|
|
185
|
+
|
|
127
186
|
_this.drawParam = {}; //缓存 绘制的数据
|
|
187
|
+
|
|
128
188
|
_this.editToolbar = null; //编辑对象
|
|
189
|
+
|
|
129
190
|
_this.editId = ''; //当前编辑的图元id
|
|
191
|
+
|
|
130
192
|
_this.drawSource = null;
|
|
131
|
-
_this.drawVector = null;
|
|
132
|
-
|
|
193
|
+
_this.drawVector = null; // 图元绘制保存
|
|
194
|
+
|
|
133
195
|
_this.drawInfo = {
|
|
134
196
|
sketch: null,
|
|
135
197
|
listener: null
|
|
@@ -144,15 +206,23 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
144
206
|
isCount: false
|
|
145
207
|
};
|
|
146
208
|
_this.heatmap = null; //热力图对象
|
|
209
|
+
|
|
147
210
|
_this.clusterMarkers = []; //聚合点位id数组
|
|
211
|
+
|
|
148
212
|
_this.clusterPs = []; //聚合集合点
|
|
213
|
+
|
|
149
214
|
_this.clusterPt = []; //地图中聚合点集合
|
|
215
|
+
|
|
150
216
|
_this.morepoints = []; //海量点集合
|
|
217
|
+
|
|
151
218
|
_this.areaRestriction = null; //区域限制数据
|
|
219
|
+
|
|
152
220
|
_this.movePoints = [];
|
|
153
221
|
_this.olLayers = []; // ol图层集合 {address:'', layer: ''}
|
|
222
|
+
|
|
154
223
|
_this.baseLayer = null; // 地图图层
|
|
155
224
|
//是否绘制测距
|
|
225
|
+
|
|
156
226
|
_this.rangingTool = {
|
|
157
227
|
isRanging: false,
|
|
158
228
|
//是否开启状态
|
|
@@ -163,8 +233,10 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
163
233
|
distance: 0,
|
|
164
234
|
//测距长度
|
|
165
235
|
mapRangingTool: null //测距回调
|
|
236
|
+
|
|
166
237
|
};
|
|
167
238
|
_this.rangingTools = {}; //测距点线缓存
|
|
239
|
+
|
|
168
240
|
_this.rangingInfo = {
|
|
169
241
|
sketch: null,
|
|
170
242
|
helpTooltipElement: null,
|
|
@@ -217,10 +289,13 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
217
289
|
}
|
|
218
290
|
};
|
|
219
291
|
_this.frameSelectProps = {};
|
|
292
|
+
|
|
220
293
|
_this.loadMapJs();
|
|
294
|
+
|
|
221
295
|
return _this;
|
|
222
|
-
}
|
|
223
|
-
|
|
296
|
+
} // 引入ol样式
|
|
297
|
+
|
|
298
|
+
|
|
224
299
|
_createClass(OlMap, [{
|
|
225
300
|
key: "loadMapJs",
|
|
226
301
|
value: function loadMapJs() {
|
|
@@ -252,13 +327,13 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
252
327
|
}).appendTo('head');
|
|
253
328
|
}
|
|
254
329
|
});
|
|
255
|
-
}
|
|
256
|
-
|
|
330
|
+
} // 初始化地圖
|
|
331
|
+
|
|
257
332
|
}, {
|
|
258
333
|
key: "init",
|
|
259
334
|
value: function init() {
|
|
260
|
-
var t = this;
|
|
261
|
-
|
|
335
|
+
var t = this; // 创建地图
|
|
336
|
+
|
|
262
337
|
t.createMap();
|
|
263
338
|
t.drawSource = new ol.source.Vector({
|
|
264
339
|
wrapX: false
|
|
@@ -266,86 +341,103 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
266
341
|
t.drawVector = new ol.layer.Vector({
|
|
267
342
|
source: t.drawSource
|
|
268
343
|
});
|
|
344
|
+
|
|
269
345
|
var initData = function initData() {
|
|
270
346
|
var _t$props = t.props,
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
t.setCenter();
|
|
282
|
-
|
|
347
|
+
mapPoints = _t$props.mapPoints,
|
|
348
|
+
mapLines = _t$props.mapLines,
|
|
349
|
+
mapPolygons = _t$props.mapPolygons,
|
|
350
|
+
mapCircles = _t$props.mapCircles,
|
|
351
|
+
mapVisiblePoints = _t$props.mapVisiblePoints,
|
|
352
|
+
mapCluster = _t$props.mapCluster,
|
|
353
|
+
mapPointCollection = _t$props.mapPointCollection,
|
|
354
|
+
areaRestriction = _t$props.areaRestriction,
|
|
355
|
+
heatMapData = _t$props.heatMapData; // 初始化中心点
|
|
356
|
+
|
|
357
|
+
t.setCenter(); // 添加点
|
|
358
|
+
|
|
283
359
|
if (mapPoints instanceof Array) {
|
|
284
360
|
t.addPoint(mapPoints);
|
|
285
|
-
}
|
|
286
|
-
|
|
361
|
+
} //添加线
|
|
362
|
+
|
|
363
|
+
|
|
287
364
|
if (mapLines instanceof Array) {
|
|
288
365
|
t.addLine(mapLines);
|
|
289
|
-
}
|
|
290
|
-
|
|
366
|
+
} //添加面
|
|
367
|
+
|
|
368
|
+
|
|
291
369
|
if (mapPolygons instanceof Array) {
|
|
292
370
|
t.addPolygon(mapPolygons);
|
|
293
|
-
}
|
|
294
|
-
|
|
371
|
+
} //添加圆
|
|
372
|
+
|
|
373
|
+
|
|
295
374
|
if (mapCircles instanceof Array) {
|
|
296
375
|
t.addCircle(mapCircles);
|
|
297
|
-
}
|
|
298
|
-
|
|
376
|
+
} //是否设置比例尺
|
|
377
|
+
|
|
378
|
+
|
|
299
379
|
if (t.props.showControl) {
|
|
300
380
|
t.showControl(t.props);
|
|
301
|
-
}
|
|
302
|
-
|
|
381
|
+
} // 画热力图
|
|
382
|
+
|
|
383
|
+
|
|
303
384
|
if (heatMapData) {
|
|
304
385
|
t.heatMapOverlay(heatMapData);
|
|
305
|
-
}
|
|
306
|
-
|
|
386
|
+
} //设置点聚合
|
|
387
|
+
|
|
388
|
+
|
|
307
389
|
if (mapCluster instanceof Array) {
|
|
308
390
|
t.cluster(mapCluster);
|
|
309
391
|
}
|
|
310
392
|
/*设置指定图元展示*/
|
|
393
|
+
|
|
394
|
+
|
|
311
395
|
if (mapVisiblePoints) {
|
|
312
396
|
t.setVisiblePoints(mapVisiblePoints);
|
|
313
|
-
}
|
|
314
|
-
|
|
397
|
+
} //添加海量点
|
|
398
|
+
|
|
399
|
+
|
|
315
400
|
if (mapPointCollection instanceof Array) {
|
|
316
401
|
t.addPointCollection(mapPointCollection);
|
|
317
|
-
}
|
|
318
|
-
|
|
402
|
+
} //设置区域限制
|
|
403
|
+
|
|
404
|
+
|
|
319
405
|
if (areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
|
|
320
406
|
t.setAreaRestriction(areaRestriction);
|
|
321
407
|
}
|
|
408
|
+
|
|
322
409
|
t.setState({
|
|
323
410
|
mapCreated: true
|
|
324
411
|
});
|
|
325
412
|
};
|
|
413
|
+
|
|
326
414
|
var event = function event(e, status) {
|
|
327
415
|
var gis = t.state.gis;
|
|
328
416
|
var overall_feature = null; //鼠标移入事件时记录当前的feature,为鼠标移出要素时保存操作的要素对象
|
|
417
|
+
|
|
329
418
|
var dragAddMoveFlag = false; //记录地图拖拽和移动事件
|
|
330
419
|
// 地图开始加载时
|
|
420
|
+
|
|
331
421
|
gis.on('loadstart', function () {
|
|
332
422
|
gis.getTargetElement().classList.add('spinner');
|
|
333
|
-
});
|
|
334
|
-
|
|
423
|
+
}); // 地图加载结束时
|
|
424
|
+
|
|
335
425
|
gis.on('loadend', function () {
|
|
336
426
|
gis.getTargetElement().classList.remove('spinner');
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
gis.on('dbclick', function (evt) {});
|
|
340
|
-
|
|
427
|
+
}); // 地图双击事件
|
|
428
|
+
|
|
429
|
+
gis.on('dbclick', function (evt) {}); // 地图点击事件
|
|
430
|
+
|
|
341
431
|
gis.on('singleclick', function (evt) {
|
|
342
432
|
var feature = gis.forEachFeatureAtPixel(evt.pixel, function (feature) {
|
|
343
433
|
return feature;
|
|
344
434
|
});
|
|
435
|
+
|
|
345
436
|
if (feature) {
|
|
346
437
|
var target = feature.getProperties();
|
|
347
438
|
var id = '';
|
|
348
439
|
var elementId = '';
|
|
440
|
+
|
|
349
441
|
if ((0, _lodash.isArray)(target.features)) {
|
|
350
442
|
// 处理聚合点击
|
|
351
443
|
var properties = target.features[0].getProperties();
|
|
@@ -355,23 +447,25 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
355
447
|
} else {
|
|
356
448
|
id = target.id;
|
|
357
449
|
elementId = target.element;
|
|
358
|
-
}
|
|
359
|
-
// top: e.clientY,//当前点所在的位置(屏幕)
|
|
450
|
+
} // top: e.clientY,//当前点所在的位置(屏幕)
|
|
360
451
|
// left: e.clientX,
|
|
452
|
+
|
|
453
|
+
|
|
361
454
|
t.clickGraphic(id || elementId, evt, target);
|
|
362
455
|
} else {
|
|
363
456
|
t.clickMap(evt);
|
|
364
457
|
}
|
|
365
|
-
});
|
|
366
|
-
|
|
458
|
+
}); // 鼠标移动事件 - 当鼠标指向要素时改变光标状态
|
|
459
|
+
|
|
367
460
|
gis.on('pointermove', function (evt) {
|
|
368
461
|
var pixel = gis.getEventPixel(evt.originalEvent);
|
|
369
462
|
var hit = gis.hasFeatureAtPixel(pixel);
|
|
370
|
-
gis.getTargetElement().style.cursor = hit ? 'pointer' : 'default';
|
|
371
|
-
|
|
463
|
+
gis.getTargetElement().style.cursor = hit ? 'pointer' : 'default'; // 获取到当前鼠标移动下的feature
|
|
464
|
+
|
|
372
465
|
var feature = gis.forEachFeatureAtPixel(pixel, function (feature, layer) {
|
|
373
466
|
return feature;
|
|
374
467
|
});
|
|
468
|
+
|
|
375
469
|
if (feature) {
|
|
376
470
|
overall_feature = feature;
|
|
377
471
|
var values = feature.getProperties();
|
|
@@ -382,20 +476,22 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
382
476
|
type: 'mousein',
|
|
383
477
|
event: evt
|
|
384
478
|
});
|
|
479
|
+
|
|
385
480
|
var _values = overall_feature.getProperties();
|
|
481
|
+
|
|
386
482
|
t.mouseOutGraphic(_values.id, evt);
|
|
387
483
|
overall_feature = null;
|
|
388
484
|
}
|
|
389
485
|
}
|
|
390
|
-
});
|
|
391
|
-
|
|
486
|
+
}); // 鼠标拖拽事件 - 拖拽开始即是地图移动开始
|
|
487
|
+
|
|
392
488
|
gis.on('pointerdrag', function (evt) {
|
|
393
489
|
dragAddMoveFlag = true;
|
|
394
490
|
t.dragMapStart(evt);
|
|
395
491
|
t.moveStart(evt);
|
|
396
492
|
});
|
|
397
|
-
var zoom = 0;
|
|
398
|
-
|
|
493
|
+
var zoom = 0; // 地图移动事件 - 移动结束即是拖拽事件结束 也是地图缩放事件(无开始和结束事件)的监听
|
|
494
|
+
|
|
399
495
|
gis.on('moveend', function (evt) {
|
|
400
496
|
t.dragMapEnd(evt);
|
|
401
497
|
t.moveEnd(evt);
|
|
@@ -404,46 +500,51 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
404
500
|
t.zoomEnd(evt);
|
|
405
501
|
}, 300);
|
|
406
502
|
dragAddMoveFlag = false;
|
|
407
|
-
});
|
|
408
|
-
// gis.getViewport().addEventListener('mouseout', function () {
|
|
503
|
+
}); // gis.getViewport().addEventListener('mouseout', function () {
|
|
409
504
|
// helpTooltipElement.classList.add('hidden');
|
|
410
505
|
// });
|
|
411
506
|
};
|
|
507
|
+
|
|
412
508
|
event();
|
|
413
509
|
t.setCenter(t.props.center);
|
|
414
510
|
initData();
|
|
415
|
-
}
|
|
416
|
-
|
|
511
|
+
} // 创建地图
|
|
512
|
+
|
|
417
513
|
}, {
|
|
418
514
|
key: "createMap",
|
|
419
515
|
value: function createMap() {
|
|
420
516
|
var t = this;
|
|
421
517
|
var _t$props2 = t.props,
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
518
|
+
_t$props2$olProps = _t$props2.olProps,
|
|
519
|
+
olProps = _t$props2$olProps === void 0 ? {} : _t$props2$olProps,
|
|
520
|
+
_t$props2$mapCenter = _t$props2.mapCenter,
|
|
521
|
+
mapCenter = _t$props2$mapCenter === void 0 ? [] : _t$props2$mapCenter,
|
|
522
|
+
mapId = _t$props2.mapId,
|
|
523
|
+
mapZoomLevel = _t$props2.mapZoomLevel,
|
|
524
|
+
minZoom = _t$props2.minZoom,
|
|
525
|
+
maxZoom = _t$props2.maxZoom;
|
|
430
526
|
var projection = olProps.projection,
|
|
431
|
-
|
|
527
|
+
olCoverage = olProps.olCoverage;
|
|
528
|
+
|
|
432
529
|
if (window.VtxMap) {
|
|
433
530
|
window.VtxMap[mapId] = null;
|
|
434
531
|
} else {
|
|
435
532
|
window.VtxMap = {};
|
|
436
533
|
}
|
|
534
|
+
|
|
437
535
|
if (!minZoom) {
|
|
438
536
|
minZoom = 2;
|
|
439
537
|
}
|
|
538
|
+
|
|
440
539
|
if (!maxZoom) {
|
|
441
540
|
maxZoom = 19;
|
|
442
541
|
}
|
|
542
|
+
|
|
443
543
|
if (!projection) {
|
|
444
544
|
projection = 'EPSG:4326';
|
|
445
|
-
}
|
|
446
|
-
|
|
545
|
+
} //中心点
|
|
546
|
+
|
|
547
|
+
|
|
447
548
|
var center = mapCenter && mapCenter instanceof Array && mapCenter.length == 2 ? mapCenter : [116.400433, 39.906705];
|
|
448
549
|
center = [parseFloat(center[0]), parseFloat(center[1])];
|
|
449
550
|
window.VtxMap[mapId] = t.state.gis = new ol.Map({
|
|
@@ -460,8 +561,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
460
561
|
rotate: false,
|
|
461
562
|
attribution: false
|
|
462
563
|
})
|
|
463
|
-
});
|
|
464
|
-
|
|
564
|
+
}); // 基本地图视图
|
|
565
|
+
|
|
465
566
|
t.viewer = new ol.View({
|
|
466
567
|
center: center,
|
|
467
568
|
zoom: mapZoomLevel || 10,
|
|
@@ -471,44 +572,127 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
471
572
|
});
|
|
472
573
|
t.loadLayers(olCoverage, [], true);
|
|
473
574
|
t.initPropsForUser();
|
|
474
|
-
}
|
|
575
|
+
} // 加载图层
|
|
576
|
+
|
|
577
|
+
}, {
|
|
578
|
+
key: "getWMTS",
|
|
579
|
+
value: // wmts图层资源
|
|
580
|
+
function getWMTS(options) {
|
|
581
|
+
var url = options.url,
|
|
582
|
+
params = options.params,
|
|
583
|
+
sourceOptions = options.sourceOptions; //切片名
|
|
584
|
+
|
|
585
|
+
var matrixIds = ['EPSG:4326:0', 'EPSG:4326:1', 'EPSG:4326:2', 'EPSG:4326:3', 'EPSG:4326:4', 'EPSG:4326:5', 'EPSG:4326:6', 'EPSG:4326:7', 'EPSG:4326:8', 'EPSG:4326:9', 'EPSG:4326:10', 'EPSG:4326:11', 'EPSG:4326:12', 'EPSG:4326:13', 'EPSG:4326:14', 'EPSG:4326:15', 'EPSG:4326:16', 'EPSG:4326:17', 'EPSG:4326:18']; //分辨率
|
|
586
|
+
|
|
587
|
+
var resolutions = [0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125, 0.02197265625, 0.010986328125, 0.0054931640625, 0.00274658203125, 0.001373291015625, 6.866455078125e-4, 3.4332275390625e-4, 1.71661376953125e-4, 8.58306884765625e-5, 4.291534423828125e-5, 2.1457672119140625e-5, 1.0728836059570312e-5, 5.364418029785156e-6, 2.682209014892578e-6]; //切片策略
|
|
588
|
+
|
|
589
|
+
var tilegrid = new ol.tilegrid.WMTS({
|
|
590
|
+
extent: [-180.0, -90.0, 180.0, 90.0],
|
|
591
|
+
//范围
|
|
592
|
+
tileSize: [256, 256],
|
|
593
|
+
origin: [-180.0, 90.0],
|
|
594
|
+
//切片原点
|
|
595
|
+
resolutions: resolutions,
|
|
596
|
+
//分辨率
|
|
597
|
+
matrixIds: matrixIds //层级标识列表,与地图级数保持一致
|
|
598
|
+
|
|
599
|
+
}); //设置地图投影
|
|
600
|
+
|
|
601
|
+
var projection = new ol.proj.Projection({
|
|
602
|
+
code: 'EPSG:4326',
|
|
603
|
+
units: 'degrees',
|
|
604
|
+
axisOrientation: 'neu'
|
|
605
|
+
});
|
|
606
|
+
return new ol.source.WMTS(_objectSpread({
|
|
607
|
+
url: url,
|
|
608
|
+
layer: params === null || params === void 0 ? void 0 : params.layer,
|
|
609
|
+
format: 'image/png',
|
|
610
|
+
matrixSet: 'EPSG:4326',
|
|
611
|
+
projection: projection,
|
|
612
|
+
tileGrid: tilegrid
|
|
613
|
+
}, sourceOptions));
|
|
614
|
+
} // 添加普通图层
|
|
615
|
+
|
|
616
|
+
}, {
|
|
617
|
+
key: "addTileLayer",
|
|
618
|
+
value: function addTileLayer(_ref) {
|
|
619
|
+
var url = _ref.url,
|
|
620
|
+
_ref$params = _ref.params,
|
|
621
|
+
params = _ref$params === void 0 ? {} : _ref$params,
|
|
622
|
+
_ref$sourceOptions = _ref.sourceOptions,
|
|
623
|
+
sourceOptions = _ref$sourceOptions === void 0 ? {} : _ref$sourceOptions,
|
|
624
|
+
type = _ref.type,
|
|
625
|
+
source = _ref.source;
|
|
626
|
+
|
|
627
|
+
if (url) {
|
|
628
|
+
var exist = this.olLayers.find(function (item) {
|
|
629
|
+
return item.address === url;
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
if (exist) {
|
|
633
|
+
exist.layer.setVisible(true);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
var layerSource = source || (type === 'WMTS' ? this.getWMTS({
|
|
638
|
+
url: url,
|
|
639
|
+
params: params,
|
|
640
|
+
sourceOptions: sourceOptions
|
|
641
|
+
}) : new ol.source.XYZ(_objectSpread({
|
|
642
|
+
url: url
|
|
643
|
+
}, sourceOptions)));
|
|
644
|
+
|
|
645
|
+
var _layer2 = new ol.layer.Tile({
|
|
646
|
+
source: layerSource
|
|
647
|
+
}); // 将图层添加到地图上
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
this.state.gis.addLayer(_layer2);
|
|
651
|
+
this.olLayers.push({
|
|
652
|
+
address: url,
|
|
653
|
+
layer: _layer2
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
} // 添加超图图层
|
|
657
|
+
|
|
475
658
|
}, {
|
|
476
659
|
key: "addSuperMapLayer",
|
|
477
|
-
value:
|
|
478
|
-
// 添加超图图层
|
|
479
|
-
function addSuperMapLayer(url) {
|
|
660
|
+
value: function addSuperMapLayer(url) {
|
|
480
661
|
var exist = this.olLayers.find(function (item) {
|
|
481
662
|
return item.address === url;
|
|
482
663
|
});
|
|
664
|
+
|
|
483
665
|
if (exist) {
|
|
484
666
|
exist.layer.setVisible(true);
|
|
485
667
|
return;
|
|
486
668
|
}
|
|
669
|
+
|
|
487
670
|
var layer = new ol.layer.Tile({
|
|
488
671
|
source: new ol.source.TileSuperMapRest({
|
|
489
672
|
url: url
|
|
490
673
|
})
|
|
491
|
-
});
|
|
492
|
-
|
|
674
|
+
}); // 将图层添加到地图上
|
|
675
|
+
|
|
493
676
|
this.state.gis.addLayer(layer);
|
|
494
677
|
this.olLayers.push({
|
|
495
678
|
address: url,
|
|
496
679
|
layer: layer
|
|
497
680
|
});
|
|
498
|
-
}
|
|
499
|
-
|
|
681
|
+
} // 添加geoServer_geoJSON图层
|
|
682
|
+
|
|
500
683
|
}, {
|
|
501
684
|
key: "addGeoServerLayer",
|
|
502
685
|
value: function addGeoServerLayer(_url) {
|
|
503
686
|
var exist = this.olLayers.find(function (item) {
|
|
504
687
|
return item.address === _url;
|
|
505
688
|
});
|
|
689
|
+
|
|
506
690
|
if (exist) {
|
|
507
691
|
exist.layer.setVisible(true);
|
|
508
692
|
return;
|
|
509
|
-
}
|
|
693
|
+
} // 矢量数据源
|
|
694
|
+
|
|
510
695
|
|
|
511
|
-
// 矢量数据源
|
|
512
696
|
var vectorSource = new ol.source.Vector({
|
|
513
697
|
// 设置格式化类型
|
|
514
698
|
format: new ol.format.GeoJSON(),
|
|
@@ -517,15 +701,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
517
701
|
return "".concat(_url, "&bbox=").concat(extent.join(','));
|
|
518
702
|
},
|
|
519
703
|
strategy: ol.loadingstrategy.bbox
|
|
520
|
-
});
|
|
704
|
+
}); // 矢量图层
|
|
521
705
|
|
|
522
|
-
// 矢量图层
|
|
523
706
|
var layer = new ol.layer.Vector({
|
|
524
707
|
// 设置数据源
|
|
525
708
|
source: vectorSource,
|
|
526
709
|
// 设置图层样式也可以 function (feature) { /** 根据内容动态加载样式 **/ return Style}
|
|
527
710
|
style: function style(feature) {
|
|
528
711
|
var _icon$;
|
|
712
|
+
|
|
529
713
|
var el = feature.A || {};
|
|
530
714
|
var icon = JSON.parse(el.icon || '[]');
|
|
531
715
|
var mapIcon = (_icon$ = icon[0]) !== null && _icon$ !== void 0 && _icon$.id ? "/cloudFile/common/downloadFile?id=".concat(icon[0].id) : require("../images/defaultMarker.png");
|
|
@@ -546,8 +730,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
546
730
|
})
|
|
547
731
|
});
|
|
548
732
|
}
|
|
549
|
-
});
|
|
550
|
-
|
|
733
|
+
}); // 将图层添加到地图上
|
|
734
|
+
|
|
551
735
|
this.state.gis.addLayer(layer);
|
|
552
736
|
this.olLayers.push({
|
|
553
737
|
address: _url,
|
|
@@ -558,7 +742,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
558
742
|
key: "formatUrl",
|
|
559
743
|
value: function formatUrl(url) {
|
|
560
744
|
var param = {},
|
|
561
|
-
|
|
745
|
+
address = url.split("?")[0];
|
|
562
746
|
url.split("?")[1].split("&").map(function (item) {
|
|
563
747
|
var json = item.split("=");
|
|
564
748
|
param[json[0].toUpperCase()] = json[1] ? decodeURIComponent(json[1]) : '';
|
|
@@ -567,8 +751,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
567
751
|
param: param,
|
|
568
752
|
address: address
|
|
569
753
|
};
|
|
570
|
-
}
|
|
571
|
-
|
|
754
|
+
} // 添加geoServer_image图层
|
|
755
|
+
|
|
572
756
|
}, {
|
|
573
757
|
key: "addGeoServerImageLayer",
|
|
574
758
|
value: function addGeoServerImageLayer(item) {
|
|
@@ -576,15 +760,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
576
760
|
var exist = this.olLayers.find(function (item) {
|
|
577
761
|
return item.address === url;
|
|
578
762
|
});
|
|
763
|
+
|
|
579
764
|
if (exist) {
|
|
580
765
|
exist.layer.setVisible(true);
|
|
581
766
|
return;
|
|
582
767
|
}
|
|
768
|
+
|
|
583
769
|
var _this$formatUrl = this.formatUrl(url),
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
770
|
+
_this$formatUrl$param = _this$formatUrl.param,
|
|
771
|
+
param = _this$formatUrl$param === void 0 ? {} : _this$formatUrl$param,
|
|
772
|
+
address = _this$formatUrl.address; // 矢量数据源
|
|
773
|
+
|
|
774
|
+
|
|
588
775
|
var vectorSource = new ol.source.ImageWMS({
|
|
589
776
|
url: address,
|
|
590
777
|
serverType: 'geoserver',
|
|
@@ -593,122 +780,140 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
593
780
|
params: _objectSpread(_objectSpread({
|
|
594
781
|
VERSION: '1.1.0'
|
|
595
782
|
}, item.param || {}), param)
|
|
596
|
-
});
|
|
783
|
+
}); // 矢量图层
|
|
597
784
|
|
|
598
|
-
// 矢量图层
|
|
599
785
|
var layer = new ol.layer.Image({
|
|
600
786
|
// 设置数据源
|
|
601
787
|
source: vectorSource
|
|
602
|
-
});
|
|
603
|
-
|
|
788
|
+
}); // 将图层添加到地图上
|
|
789
|
+
|
|
604
790
|
this.state.gis.addLayer(layer);
|
|
605
791
|
this.olLayers.push({
|
|
606
792
|
address: url,
|
|
607
793
|
layer: layer,
|
|
608
794
|
source: vectorSource
|
|
609
795
|
});
|
|
610
|
-
}
|
|
611
|
-
|
|
796
|
+
} // 初始化对外方法
|
|
797
|
+
|
|
612
798
|
}, {
|
|
613
799
|
key: "initPropsForUser",
|
|
614
800
|
value: function initPropsForUser() {
|
|
615
801
|
var t = this;
|
|
802
|
+
|
|
616
803
|
t.state.gis["getCenter"] = function () {
|
|
617
804
|
return t.getCenter();
|
|
618
805
|
};
|
|
806
|
+
|
|
619
807
|
t.state.gis["setCenter"] = function (gt) {
|
|
620
808
|
t.setCenter(gt);
|
|
621
809
|
};
|
|
810
|
+
|
|
622
811
|
t.state.gis["getZoomLevel"] = function () {
|
|
623
812
|
return t.getZoomLevel();
|
|
624
813
|
};
|
|
814
|
+
|
|
625
815
|
t.state.gis["showInfoWindow"] = function (obj) {
|
|
626
816
|
return t.showInfoWindow(obj);
|
|
627
817
|
};
|
|
818
|
+
|
|
628
819
|
t.state.gis["hideInfoWindow"] = function () {
|
|
629
820
|
return t.hideInfoWindow();
|
|
630
821
|
};
|
|
822
|
+
|
|
631
823
|
t.state.gis["frameSelect"] = function () {
|
|
632
824
|
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
633
825
|
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
634
826
|
return t.frameSelect(obj, callback);
|
|
635
827
|
};
|
|
828
|
+
|
|
636
829
|
t.state.gis["clearFrameSelect"] = function () {
|
|
637
830
|
return t.clearFrameSelect();
|
|
638
831
|
};
|
|
832
|
+
|
|
639
833
|
t.state.gis["clearFrameSelectById"] = function (id) {
|
|
640
834
|
return t.clearFrameSelectById(id);
|
|
641
835
|
};
|
|
836
|
+
|
|
642
837
|
t.state.gis["refresh"] = function () {
|
|
643
838
|
t.refresh();
|
|
644
839
|
};
|
|
645
|
-
}
|
|
646
|
-
|
|
840
|
+
} // 设置中心点
|
|
841
|
+
|
|
647
842
|
}, {
|
|
648
843
|
key: "setCenter",
|
|
649
844
|
value: function setCenter(gt) {
|
|
650
845
|
var t = this;
|
|
846
|
+
|
|
651
847
|
if (!t.state.gis) {
|
|
652
848
|
return;
|
|
653
849
|
}
|
|
850
|
+
|
|
654
851
|
if (gt) {
|
|
655
852
|
//经纬度 必须存在 否则不操作
|
|
656
853
|
if (!gt[0] || !gt[1]) {
|
|
657
854
|
return false;
|
|
658
|
-
}
|
|
659
|
-
|
|
855
|
+
} //如果设置的经纬度 与当前中心点一样 不操作
|
|
856
|
+
|
|
857
|
+
|
|
660
858
|
var c = t.getCenter();
|
|
859
|
+
|
|
661
860
|
if (c.lng == gt[0] && c.lat == gt[1]) {
|
|
662
861
|
return false;
|
|
663
862
|
}
|
|
863
|
+
|
|
664
864
|
t.state.gis.getView().setCenter(gt);
|
|
665
865
|
t.viewer.animate({
|
|
666
866
|
center: gt,
|
|
667
867
|
duration: 2000
|
|
668
868
|
});
|
|
669
869
|
}
|
|
670
|
-
}
|
|
671
|
-
|
|
870
|
+
} //设置地图缩放层级
|
|
871
|
+
|
|
672
872
|
}, {
|
|
673
873
|
key: "setZoomLevel",
|
|
674
874
|
value: function setZoomLevel(zoom) {
|
|
675
875
|
var t = this;
|
|
676
876
|
var z = t.state.gis.getView().getZoom();
|
|
877
|
+
|
|
677
878
|
if (z == zoom) {
|
|
678
879
|
return false;
|
|
679
880
|
}
|
|
881
|
+
|
|
680
882
|
t.state.gis.getView().setZoom(zoom);
|
|
681
|
-
}
|
|
682
|
-
|
|
883
|
+
} //获取当前中心点
|
|
884
|
+
|
|
683
885
|
}, {
|
|
684
886
|
key: "getCenter",
|
|
685
887
|
value: function getCenter() {
|
|
686
888
|
var t = this;
|
|
687
889
|
var gis = t.state.gis;
|
|
890
|
+
|
|
688
891
|
var _gis$getView$calculat = gis.getView().calculateExtent(gis.getSize()),
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
892
|
+
_gis$getView$calculat2 = _slicedToArray(_gis$getView$calculat, 4),
|
|
893
|
+
xmin = _gis$getView$calculat2[0],
|
|
894
|
+
ymin = _gis$getView$calculat2[1],
|
|
895
|
+
xmax = _gis$getView$calculat2[2],
|
|
896
|
+
ymax = _gis$getView$calculat2[3];
|
|
897
|
+
|
|
694
898
|
return {
|
|
695
899
|
lng: (xmin + xmax) / 2,
|
|
696
900
|
lat: (ymin + ymax) / 2
|
|
697
901
|
};
|
|
698
|
-
}
|
|
699
|
-
|
|
902
|
+
} //编辑图元
|
|
903
|
+
|
|
700
904
|
}, {
|
|
701
905
|
key: "doEdit",
|
|
702
906
|
value: function doEdit(id) {
|
|
703
|
-
var t = this;
|
|
704
|
-
|
|
907
|
+
var t = this; //获取图元对象
|
|
908
|
+
|
|
705
909
|
var gc = t.GM.getGraphic(id);
|
|
706
910
|
var gp = t.GM.getGraphicParam(id);
|
|
707
|
-
if (!gc) return false;
|
|
708
|
-
|
|
911
|
+
if (!gc) return false; //关闭先前编辑的图元
|
|
912
|
+
|
|
709
913
|
if (!!t.state.editId) {
|
|
710
914
|
t.endEdit();
|
|
711
915
|
}
|
|
916
|
+
|
|
712
917
|
if (!t.editToolbar) {
|
|
713
918
|
t.editToolbar = new ol.interaction.Modify({
|
|
714
919
|
source: gp.source,
|
|
@@ -718,23 +923,26 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
718
923
|
} else {
|
|
719
924
|
t.state.gis.addInteraction(t.editToolbar);
|
|
720
925
|
}
|
|
926
|
+
|
|
721
927
|
t.editToolbar.on('modifyend', function (e) {
|
|
722
928
|
var feature = gc;
|
|
723
929
|
e.features.forEach(function (feature) {
|
|
724
930
|
feature = feature;
|
|
725
|
-
});
|
|
726
|
-
|
|
931
|
+
}); //返回参数
|
|
932
|
+
|
|
727
933
|
var param = {
|
|
728
934
|
id: id,
|
|
729
935
|
e: e
|
|
730
|
-
};
|
|
731
|
-
|
|
936
|
+
}; // 绘制内部管理的图元
|
|
937
|
+
|
|
732
938
|
if (gp.geometry.type == 'point') {
|
|
733
939
|
var cur = feature.getProperties().geometry;
|
|
940
|
+
|
|
734
941
|
var _cur$flatCoordinates = _slicedToArray(cur.flatCoordinates, 2),
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
942
|
+
lng = _cur$flatCoordinates[0],
|
|
943
|
+
lat = _cur$flatCoordinates[1]; //处理点返回参数
|
|
944
|
+
|
|
945
|
+
|
|
738
946
|
param = _objectSpread(_objectSpread({}, param), {}, {
|
|
739
947
|
attributes: _objectSpread(_objectSpread({}, gp.attributes), {}, {
|
|
740
948
|
longitude: lng,
|
|
@@ -763,12 +971,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
763
971
|
y: lat
|
|
764
972
|
}
|
|
765
973
|
});
|
|
766
|
-
}
|
|
767
|
-
|
|
974
|
+
} //线
|
|
975
|
+
|
|
976
|
+
|
|
768
977
|
if (gp.geometry.type == 'polyline') {
|
|
769
978
|
var _cur = feature.getProperties().geometry;
|
|
770
979
|
var oddList = [],
|
|
771
|
-
|
|
980
|
+
evenList = [];
|
|
981
|
+
|
|
772
982
|
_cur.flatCoordinates.map(function (item, index) {
|
|
773
983
|
// 判断下标奇偶数
|
|
774
984
|
if (index % 2 === 0) {
|
|
@@ -777,13 +987,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
777
987
|
oddList.push(item);
|
|
778
988
|
}
|
|
779
989
|
});
|
|
990
|
+
|
|
780
991
|
var path = oddList.map(function (item, index) {
|
|
781
992
|
return [evenList[index], oddList[index]];
|
|
782
|
-
});
|
|
783
|
-
|
|
993
|
+
}); //处理线返回参数
|
|
994
|
+
|
|
784
995
|
var _t$dealData = t.dealData(path),
|
|
785
|
-
|
|
786
|
-
|
|
996
|
+
lnglatAry = _t$dealData.lnglatAry,
|
|
997
|
+
_extent = _t$dealData._extent;
|
|
998
|
+
|
|
787
999
|
param = _objectSpread(_objectSpread({}, param), {}, {
|
|
788
1000
|
attributes: _objectSpread(_objectSpread({}, gp.attributes), {}, {
|
|
789
1001
|
paths: path,
|
|
@@ -815,12 +1027,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
815
1027
|
},
|
|
816
1028
|
distance: t.calculateDistance(path)
|
|
817
1029
|
});
|
|
818
|
-
}
|
|
819
|
-
|
|
1030
|
+
} //面
|
|
1031
|
+
|
|
1032
|
+
|
|
820
1033
|
if (gp.geometry.type == 'polygon') {
|
|
821
1034
|
var _cur2 = feature.getProperties().geometry;
|
|
822
1035
|
var _oddList = [],
|
|
823
|
-
|
|
1036
|
+
_evenList = [];
|
|
1037
|
+
|
|
824
1038
|
_cur2.flatCoordinates.map(function (item, index) {
|
|
825
1039
|
// 判断下标奇偶数
|
|
826
1040
|
if (index % 2 === 0) {
|
|
@@ -829,13 +1043,16 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
829
1043
|
_oddList.push(item);
|
|
830
1044
|
}
|
|
831
1045
|
});
|
|
1046
|
+
|
|
832
1047
|
var _path = _oddList.map(function (item, index) {
|
|
833
1048
|
return [_evenList[index], _oddList[index]];
|
|
834
|
-
});
|
|
835
|
-
|
|
1049
|
+
}); //处理线返回参数
|
|
1050
|
+
|
|
1051
|
+
|
|
836
1052
|
var _t$dealData2 = t.dealData(_path),
|
|
837
|
-
|
|
838
|
-
|
|
1053
|
+
_lnglatAry = _t$dealData2.lnglatAry,
|
|
1054
|
+
_extent2 = _t$dealData2._extent;
|
|
1055
|
+
|
|
839
1056
|
param = _objectSpread(_objectSpread({}, param), {}, {
|
|
840
1057
|
attributes: _objectSpread(_objectSpread({}, gp.attributes), {}, {
|
|
841
1058
|
rings: _path,
|
|
@@ -868,9 +1085,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
868
1085
|
area: (0, _MapToolFunction.getPolygonArea)(_path)
|
|
869
1086
|
});
|
|
870
1087
|
}
|
|
1088
|
+
|
|
871
1089
|
if (gp.geometry.type == 'circle') {
|
|
872
1090
|
var _cur3 = feature.getProperties().geometry;
|
|
1091
|
+
|
|
873
1092
|
var center = _cur3.getCenter();
|
|
1093
|
+
|
|
874
1094
|
var sketchCoords_ = [_cur3.flatCoordinates[0], _cur3.flatCoordinates[1]];
|
|
875
1095
|
var sketchCoords_2 = [_cur3.flatCoordinates[2], _cur3.flatCoordinates[3]];
|
|
876
1096
|
var radius = ol.sphere.getDistance(sketchCoords_, sketchCoords_2);
|
|
@@ -915,27 +1135,31 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
915
1135
|
}
|
|
916
1136
|
});
|
|
917
1137
|
}
|
|
1138
|
+
|
|
918
1139
|
if ('editGraphicChange' in t.props && typeof t.props.editGraphicChange == 'function') {
|
|
919
1140
|
t.props.editGraphicChange(param);
|
|
920
1141
|
}
|
|
1142
|
+
|
|
921
1143
|
t.GM.setGraphic(id, feature).setGraphicParam(id, _objectSpread(_objectSpread({}, param), {}, {
|
|
922
1144
|
source: gp.source
|
|
923
1145
|
}));
|
|
924
1146
|
});
|
|
925
1147
|
t.editId = id;
|
|
926
|
-
}
|
|
927
|
-
|
|
1148
|
+
} //关闭编辑
|
|
1149
|
+
|
|
928
1150
|
}, {
|
|
929
1151
|
key: "endEdit",
|
|
930
1152
|
value: function endEdit() {
|
|
931
1153
|
var t = this;
|
|
1154
|
+
|
|
932
1155
|
if (t.editToolbar) {
|
|
933
1156
|
t.state.gis.removeInteraction(t.editToolbar);
|
|
934
1157
|
t.editToolbar = null;
|
|
935
1158
|
}
|
|
1159
|
+
|
|
936
1160
|
t.editId = '';
|
|
937
|
-
}
|
|
938
|
-
|
|
1161
|
+
} // 绘制图元
|
|
1162
|
+
|
|
939
1163
|
}, {
|
|
940
1164
|
key: "draw",
|
|
941
1165
|
value: function draw(obj) {
|
|
@@ -943,35 +1167,38 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
943
1167
|
var drawInfo = t.drawInfo;
|
|
944
1168
|
var gis = t.state.gis;
|
|
945
1169
|
var drawParam = {},
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1170
|
+
image,
|
|
1171
|
+
stroke,
|
|
1172
|
+
fill; //初始化参数
|
|
1173
|
+
|
|
950
1174
|
drawParam.geometryType = obj.geometryType || 'point';
|
|
951
1175
|
drawParam.parameter = obj.parameter ? _objectSpread({}, obj.parameter) : {};
|
|
952
1176
|
drawParam.data = obj.data ? _objectSpread({}, obj.data) : {};
|
|
953
|
-
drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime());
|
|
954
|
-
|
|
955
|
-
t.drawParam = drawParam;
|
|
956
|
-
|
|
1177
|
+
drawParam.data.id = (obj.data || {}).id || "draw".concat(new Date().getTime()); //缓存 绘制的数据
|
|
1178
|
+
|
|
1179
|
+
t.drawParam = drawParam; //判断id是否存在
|
|
1180
|
+
|
|
957
1181
|
var len = t.state.drawIds[drawParam.geometryType].indexOf(drawParam.data.id);
|
|
1182
|
+
|
|
958
1183
|
if (len > -1) {
|
|
959
1184
|
//如果id存在 删除存在的图元,清除drawId中的id数据
|
|
960
1185
|
t.removeGraphic(drawParam.data.id);
|
|
961
1186
|
t.state.drawIds[drawParam.geometryType].splice(len, 1);
|
|
962
1187
|
}
|
|
1188
|
+
|
|
963
1189
|
var type = 'Point',
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1190
|
+
style = new ol.style.Style({
|
|
1191
|
+
image: new ol.style.Icon({
|
|
1192
|
+
anchor: [-drawParam.parameter.markerContentX || -15, -drawParam.parameter.markerContentY || -15],
|
|
1193
|
+
anchorXUnits: 'pixels',
|
|
1194
|
+
anchorYUnits: 'pixels',
|
|
1195
|
+
src: drawParam.parameter.url || require("../images/defaultMarker.png"),
|
|
1196
|
+
opacity: 1,
|
|
1197
|
+
scale: drawParam.parameter.scale || 1
|
|
1198
|
+
})
|
|
1199
|
+
});
|
|
974
1200
|
var geometryFunction;
|
|
1201
|
+
|
|
975
1202
|
switch (drawParam.geometryType) {
|
|
976
1203
|
case 'point':
|
|
977
1204
|
type = 'Point';
|
|
@@ -986,6 +1213,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
986
1213
|
})
|
|
987
1214
|
});
|
|
988
1215
|
break;
|
|
1216
|
+
|
|
989
1217
|
case 'polyline':
|
|
990
1218
|
type = 'LineString';
|
|
991
1219
|
style = new ol.style.Style({
|
|
@@ -996,6 +1224,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
996
1224
|
})
|
|
997
1225
|
});
|
|
998
1226
|
break;
|
|
1227
|
+
|
|
999
1228
|
case 'polygon':
|
|
1000
1229
|
type = 'Polygon';
|
|
1001
1230
|
style = new ol.style.Style({
|
|
@@ -1009,10 +1238,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1009
1238
|
})
|
|
1010
1239
|
});
|
|
1011
1240
|
break;
|
|
1241
|
+
|
|
1012
1242
|
case 'rectangle':
|
|
1013
1243
|
type = 'Circle';
|
|
1014
1244
|
geometryFunction = ol.interaction.Draw.createBox();
|
|
1015
1245
|
break;
|
|
1246
|
+
|
|
1016
1247
|
case 'circle':
|
|
1017
1248
|
type = 'Circle';
|
|
1018
1249
|
style = new ol.style.Style({
|
|
@@ -1027,33 +1258,38 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1027
1258
|
});
|
|
1028
1259
|
break;
|
|
1029
1260
|
}
|
|
1261
|
+
|
|
1030
1262
|
if (!t.drawToolbar) {
|
|
1031
1263
|
t.drawToolbar = new ol.interaction.Draw({
|
|
1032
1264
|
source: t.drawSource,
|
|
1033
1265
|
type: type,
|
|
1034
|
-
geometryFunction: geometryFunction
|
|
1035
|
-
|
|
1266
|
+
geometryFunction: geometryFunction // style: style
|
|
1267
|
+
|
|
1036
1268
|
});
|
|
1037
1269
|
gis.addInteraction(t.drawToolbar);
|
|
1038
1270
|
} else {
|
|
1039
1271
|
gis.addInteraction(t.drawToolbar);
|
|
1040
1272
|
}
|
|
1273
|
+
|
|
1041
1274
|
t.drawToolbar.on('drawend', function (e) {
|
|
1042
1275
|
var _t$frameSelectProps$p;
|
|
1276
|
+
|
|
1043
1277
|
// 关闭绘制事件
|
|
1044
|
-
t.drawToolbar.finishDrawing();
|
|
1045
|
-
|
|
1278
|
+
t.drawToolbar.finishDrawing(); // 移除
|
|
1279
|
+
|
|
1046
1280
|
gis.removeInteraction(t.drawToolbar);
|
|
1047
|
-
var gc = e.feature.getGeometry();
|
|
1048
|
-
|
|
1049
|
-
var param = {};
|
|
1050
|
-
|
|
1281
|
+
var gc = e.feature.getGeometry(); //返回参数
|
|
1282
|
+
|
|
1283
|
+
var param = {}; // 绘制内部管理的图元
|
|
1284
|
+
|
|
1051
1285
|
if (t.drawParam.geometryType == 'point') {
|
|
1052
1286
|
var _gc$flatCoordinates = _slicedToArray(gc.flatCoordinates, 2),
|
|
1053
|
-
|
|
1054
|
-
|
|
1287
|
+
lng = _gc$flatCoordinates[0],
|
|
1288
|
+
lat = _gc$flatCoordinates[1];
|
|
1289
|
+
|
|
1055
1290
|
gc.x = lng;
|
|
1056
1291
|
gc.y = lat;
|
|
1292
|
+
|
|
1057
1293
|
if (t.GM.isRepetition(t.drawParam.data.id)) {
|
|
1058
1294
|
t.updatePoint([{
|
|
1059
1295
|
id: t.drawParam.data.id,
|
|
@@ -1070,9 +1306,9 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1070
1306
|
url: t.drawParam.parameter.url || require("../images/defaultMarker.png"),
|
|
1071
1307
|
config: _objectSpread({}, t.drawParam.parameter)
|
|
1072
1308
|
}], 'point');
|
|
1073
|
-
}
|
|
1309
|
+
} //处理点返回参数
|
|
1310
|
+
|
|
1074
1311
|
|
|
1075
|
-
//处理点返回参数
|
|
1076
1312
|
param = {
|
|
1077
1313
|
id: t.drawParam.data.id,
|
|
1078
1314
|
attributes: {
|
|
@@ -1087,11 +1323,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1087
1323
|
geometryType: 'point',
|
|
1088
1324
|
mapLayer: t.GM.getGraphic(t.drawParam.data.id)
|
|
1089
1325
|
};
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1326
|
+
} //线
|
|
1327
|
+
|
|
1328
|
+
|
|
1092
1329
|
if (t.drawParam.geometryType == 'polyline') {
|
|
1093
1330
|
var oddList = [],
|
|
1094
|
-
|
|
1331
|
+
evenList = [];
|
|
1095
1332
|
gc.flatCoordinates.map(function (item, index) {
|
|
1096
1333
|
// 判断下标奇偶数
|
|
1097
1334
|
if (index % 2 === 0) {
|
|
@@ -1103,6 +1340,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1103
1340
|
var path = oddList.map(function (item, index) {
|
|
1104
1341
|
return [evenList[index], oddList[index]];
|
|
1105
1342
|
});
|
|
1343
|
+
|
|
1106
1344
|
if (t.GM.isRepetition(t.drawParam.data.id)) {
|
|
1107
1345
|
t.updateLine([{
|
|
1108
1346
|
id: t.drawParam.data.id,
|
|
@@ -1115,11 +1353,13 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1115
1353
|
paths: path,
|
|
1116
1354
|
config: _objectSpread({}, t.drawParam.parameter)
|
|
1117
1355
|
}], 'polyline');
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1356
|
+
} //处理线返回参数
|
|
1357
|
+
|
|
1358
|
+
|
|
1120
1359
|
var _t$dealData3 = t.dealData(path),
|
|
1121
|
-
|
|
1122
|
-
|
|
1360
|
+
lnglatAry = _t$dealData3.lnglatAry,
|
|
1361
|
+
_extent = _t$dealData3._extent;
|
|
1362
|
+
|
|
1123
1363
|
param = {
|
|
1124
1364
|
lnglatAry: lnglatAry,
|
|
1125
1365
|
id: t.drawParam.data.id,
|
|
@@ -1135,11 +1375,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1135
1375
|
geometryType: 'polyline',
|
|
1136
1376
|
mapLayer: t.GM.getGraphic(t.drawParam.data.id)
|
|
1137
1377
|
};
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1378
|
+
} //面
|
|
1379
|
+
|
|
1380
|
+
|
|
1140
1381
|
if (t.drawParam.geometryType == 'polygon') {
|
|
1141
1382
|
var _oddList2 = [],
|
|
1142
|
-
|
|
1383
|
+
_evenList2 = [];
|
|
1143
1384
|
gc.flatCoordinates.map(function (item, index) {
|
|
1144
1385
|
// 判断下标奇偶数
|
|
1145
1386
|
if (index % 2 === 0) {
|
|
@@ -1148,9 +1389,11 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1148
1389
|
_oddList2.push(item);
|
|
1149
1390
|
}
|
|
1150
1391
|
});
|
|
1392
|
+
|
|
1151
1393
|
var _path2 = _oddList2.map(function (item, index) {
|
|
1152
1394
|
return [_evenList2[index], _oddList2[index]];
|
|
1153
1395
|
});
|
|
1396
|
+
|
|
1154
1397
|
if (t.GM.isRepetition(t.drawParam.data.id)) {
|
|
1155
1398
|
t.updatePolygon([{
|
|
1156
1399
|
id: t.drawParam.data.id,
|
|
@@ -1163,11 +1406,13 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1163
1406
|
rings: _path2,
|
|
1164
1407
|
config: _objectSpread({}, t.drawParam.parameter)
|
|
1165
1408
|
}], t.drawParam.geometryType);
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1409
|
+
} //处理线返回参数
|
|
1410
|
+
|
|
1411
|
+
|
|
1168
1412
|
var _t$dealData4 = t.dealData(_path2),
|
|
1169
|
-
|
|
1170
|
-
|
|
1413
|
+
_lnglatAry2 = _t$dealData4.lnglatAry,
|
|
1414
|
+
_extent3 = _t$dealData4._extent;
|
|
1415
|
+
|
|
1171
1416
|
param = {
|
|
1172
1417
|
lnglatAry: _lnglatAry2,
|
|
1173
1418
|
id: t.drawParam.data.id,
|
|
@@ -1185,8 +1430,10 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1185
1430
|
mapLayer: t.GM.getGraphic(t.drawParam.data.id)
|
|
1186
1431
|
};
|
|
1187
1432
|
}
|
|
1433
|
+
|
|
1188
1434
|
if (t.drawParam.geometryType == 'rectangle') {
|
|
1189
1435
|
var _path3 = e.feature.getGeometry().getCoordinates()[0];
|
|
1436
|
+
|
|
1190
1437
|
if (t.GM.isRepetition(t.drawParam.data.id)) {
|
|
1191
1438
|
t.updatePolygon([{
|
|
1192
1439
|
id: t.drawParam.data.id,
|
|
@@ -1199,11 +1446,13 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1199
1446
|
rings: _path3,
|
|
1200
1447
|
config: _objectSpread({}, t.drawParam.parameter)
|
|
1201
1448
|
}], t.drawParam.geometryType);
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1449
|
+
} //处理线返回参数
|
|
1450
|
+
|
|
1451
|
+
|
|
1204
1452
|
var _t$dealData5 = t.dealData(_path3),
|
|
1205
|
-
|
|
1206
|
-
|
|
1453
|
+
_lnglatAry3 = _t$dealData5.lnglatAry,
|
|
1454
|
+
_extent4 = _t$dealData5._extent;
|
|
1455
|
+
|
|
1207
1456
|
param = {
|
|
1208
1457
|
lnglatAry: _lnglatAry3,
|
|
1209
1458
|
id: t.drawParam.data.id,
|
|
@@ -1221,12 +1470,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1221
1470
|
mapLayer: t.GM.getGraphic(t.drawParam.data.id)
|
|
1222
1471
|
};
|
|
1223
1472
|
}
|
|
1473
|
+
|
|
1224
1474
|
if (t.drawParam.geometryType == 'circle') {
|
|
1225
1475
|
var center = e.feature.getGeometry().getCenter();
|
|
1226
1476
|
var cur = e.feature.getProperties().geometry;
|
|
1227
1477
|
var sketchCoords_ = [cur.flatCoordinates[0], cur.flatCoordinates[1]];
|
|
1228
1478
|
var sketchCoords_2 = [cur.flatCoordinates[2], cur.flatCoordinates[3]];
|
|
1229
1479
|
var radius = ol.sphere.getDistance(sketchCoords_, sketchCoords_2);
|
|
1480
|
+
|
|
1230
1481
|
if (t.GM.isRepetition(t.drawParam.data.id)) {
|
|
1231
1482
|
t.updateCircle([{
|
|
1232
1483
|
id: t.drawParam.data.id,
|
|
@@ -1244,6 +1495,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1244
1495
|
config: _objectSpread({}, t.drawParam.parameter)
|
|
1245
1496
|
}], t.drawParam.geometryType);
|
|
1246
1497
|
}
|
|
1498
|
+
|
|
1247
1499
|
param = {
|
|
1248
1500
|
area: Math.PI * Math.pow(radius, 2),
|
|
1249
1501
|
attributes: {
|
|
@@ -1260,26 +1512,29 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1260
1512
|
mapLayer: t.GM.getGraphic(t.drawParam.data.id)
|
|
1261
1513
|
};
|
|
1262
1514
|
}
|
|
1515
|
+
|
|
1263
1516
|
if ('drawEnd' in t.props && typeof t.props.drawEnd == 'function') {
|
|
1264
1517
|
t.props.drawEnd(param);
|
|
1265
1518
|
}
|
|
1519
|
+
|
|
1266
1520
|
if (((_t$frameSelectProps$p = t.frameSelectProps[param.attributes.id]) === null || _t$frameSelectProps$p === void 0 ? void 0 : _t$frameSelectProps$p.callback) instanceof Function) {
|
|
1267
1521
|
t.frameSelectProps[param.attributes.id].callback(param);
|
|
1268
1522
|
}
|
|
1269
|
-
});
|
|
1270
|
-
|
|
1523
|
+
}); //保存绘制图元的id便于后期比对
|
|
1524
|
+
|
|
1271
1525
|
t.state.drawIds[drawParam.geometryType].push(drawParam.data.id);
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1526
|
+
} // 关闭绘制
|
|
1527
|
+
|
|
1274
1528
|
}, {
|
|
1275
1529
|
key: "closeDraw",
|
|
1276
1530
|
value: function closeDraw() {
|
|
1277
1531
|
var t = this;
|
|
1278
1532
|
var gis = t.state.gis;
|
|
1533
|
+
|
|
1279
1534
|
if (t.drawToolbar) {
|
|
1280
1535
|
// 关闭绘制事件
|
|
1281
|
-
t.drawToolbar.finishDrawing();
|
|
1282
|
-
|
|
1536
|
+
t.drawToolbar.finishDrawing(); // 移除
|
|
1537
|
+
|
|
1283
1538
|
gis.removeInteraction(t.drawToolbar);
|
|
1284
1539
|
t.drawToolbar = null;
|
|
1285
1540
|
t.drawInfo = {
|
|
@@ -1289,6 +1544,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1289
1544
|
}
|
|
1290
1545
|
}
|
|
1291
1546
|
/*工具方法*/
|
|
1547
|
+
|
|
1292
1548
|
}, {
|
|
1293
1549
|
key: "vtxRangingTool",
|
|
1294
1550
|
value: function vtxRangingTool() {
|
|
@@ -1340,8 +1596,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1340
1596
|
t.createMeasureTooltip();
|
|
1341
1597
|
t.createDeleteTooltip();
|
|
1342
1598
|
t.state.gis.addLayer(t.rangingInfo.drawLayer);
|
|
1343
|
-
t.state.gis.addInteraction(t.rangingInfo.draw);
|
|
1344
|
-
|
|
1599
|
+
t.state.gis.addInteraction(t.rangingInfo.draw); // 开始监听绘制
|
|
1600
|
+
|
|
1345
1601
|
t.rangingInfo.draw.on('drawstart', function (evt) {
|
|
1346
1602
|
t.rangingInfo.feature = evt.feature;
|
|
1347
1603
|
var tooltipCoord = evt.coordinate;
|
|
@@ -1360,29 +1616,32 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1360
1616
|
t.rangingInfo.deleteToolTip.setPosition(tooltipCoord);
|
|
1361
1617
|
t.rangingInfo.deleteToolTip.setOffset([20, 10]);
|
|
1362
1618
|
});
|
|
1363
|
-
});
|
|
1364
|
-
|
|
1619
|
+
}); // 双击绘制完成
|
|
1620
|
+
|
|
1365
1621
|
t.rangingInfo.draw.on('drawend', function () {
|
|
1366
1622
|
t.rangingInfo.measureTooltipElement.className = 'ol-tooltip ol-tooltip-static';
|
|
1367
1623
|
t.rangingInfo.measureTooltip.setOffset([0, -7]);
|
|
1368
1624
|
t.rangingInfo.feature = null;
|
|
1369
|
-
t.rangingInfo.measureTooltipElement = null;
|
|
1370
|
-
|
|
1625
|
+
t.rangingInfo.measureTooltipElement = null; // t.createMeasureTooltip();
|
|
1626
|
+
|
|
1371
1627
|
new ol.Observable.unByKey(t.rangingInfo.listener);
|
|
1372
1628
|
t.state.gis.removeInteraction(t.rangingInfo.draw);
|
|
1629
|
+
|
|
1373
1630
|
if ('mapRangingTool' in t.props) {
|
|
1374
1631
|
t.props.mapRangingTool(obj);
|
|
1375
1632
|
}
|
|
1376
1633
|
});
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1634
|
+
} // 绘图时创建提示
|
|
1635
|
+
|
|
1379
1636
|
}, {
|
|
1380
1637
|
key: "createHelpTooltip",
|
|
1381
1638
|
value: function createHelpTooltip() {
|
|
1382
1639
|
var t = this;
|
|
1640
|
+
|
|
1383
1641
|
if (t.rangingTool.helpTooltipElement) {
|
|
1384
1642
|
t.rangingTool.helpTooltipElement.parentNode.removeChild(t.rangingTool.helpTooltipElement);
|
|
1385
1643
|
}
|
|
1644
|
+
|
|
1386
1645
|
t.rangingTool.helpTooltipElement = document.createElement('div');
|
|
1387
1646
|
t.rangingTool.helpTooltipElement.className = 'ol-tooltip hidden';
|
|
1388
1647
|
t.rangingTool.helpTooltip = new ol.Overlay({
|
|
@@ -1391,15 +1650,17 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1391
1650
|
positioning: 'center-left'
|
|
1392
1651
|
});
|
|
1393
1652
|
t.state.gis.addOverlay(t.rangingTool.helpTooltip);
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1653
|
+
} // 工具画图提示
|
|
1654
|
+
|
|
1396
1655
|
}, {
|
|
1397
1656
|
key: "createMeasureTooltip",
|
|
1398
1657
|
value: function createMeasureTooltip() {
|
|
1399
1658
|
var t = this;
|
|
1659
|
+
|
|
1400
1660
|
if (t.rangingInfo.measureTooltipElement) {
|
|
1401
1661
|
t.rangingInfo.measureTooltipElement.parentNode.removeChild(t.rangingInfo.measureTooltipElement);
|
|
1402
1662
|
}
|
|
1663
|
+
|
|
1403
1664
|
t.rangingInfo.measureTooltipElement = document.createElement('div');
|
|
1404
1665
|
t.rangingInfo.measureTooltipElement.className = 'ol-tooltip ol-tooltip-measure';
|
|
1405
1666
|
t.rangingInfo.measureTooltip = new ol.Overlay({
|
|
@@ -1410,15 +1671,17 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1410
1671
|
insertFirst: false
|
|
1411
1672
|
});
|
|
1412
1673
|
t.state.gis.addOverlay(t.rangingInfo.measureTooltip);
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1674
|
+
} // 创建删除提示
|
|
1675
|
+
|
|
1415
1676
|
}, {
|
|
1416
1677
|
key: "createDeleteTooltip",
|
|
1417
1678
|
value: function createDeleteTooltip() {
|
|
1418
1679
|
var t = this;
|
|
1680
|
+
|
|
1419
1681
|
if (t.rangingInfo.deleteToolTipElement) {
|
|
1420
1682
|
t.rangingInfo.deleteToolTipElement.parentNode.removeChild(t.rangingInfo.deleteToolTipElement);
|
|
1421
1683
|
}
|
|
1684
|
+
|
|
1422
1685
|
t.rangingInfo.deleteToolTipElement = document.createElement('div');
|
|
1423
1686
|
t.rangingInfo.deleteToolTipElement.className = 'ol-tooltip-delete';
|
|
1424
1687
|
t.rangingInfo.deleteToolTipElement.innerHTML = 'X';
|
|
@@ -1445,12 +1708,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1445
1708
|
}, {
|
|
1446
1709
|
key: "formatLength",
|
|
1447
1710
|
value: function formatLength(line) {
|
|
1448
|
-
var flatCoordinates = line.flatCoordinates;
|
|
1449
|
-
|
|
1711
|
+
var flatCoordinates = line.flatCoordinates; // const length = new ol.sphere.getDistance([flatCoordinates[0], flatCoordinates[1]],[flatCoordinates[2], flatCoordinates[3]]);
|
|
1712
|
+
|
|
1450
1713
|
var paths = [];
|
|
1714
|
+
|
|
1451
1715
|
for (var n = 0; n < flatCoordinates.length; n += 2) {
|
|
1452
1716
|
paths.push([flatCoordinates[n], flatCoordinates[n + 1]]);
|
|
1453
1717
|
}
|
|
1718
|
+
|
|
1454
1719
|
var length = 0;
|
|
1455
1720
|
if (paths.length >= 2) paths.map(function (item, index) {
|
|
1456
1721
|
if (index <= paths.length - 2) {
|
|
@@ -1458,21 +1723,23 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1458
1723
|
}
|
|
1459
1724
|
});
|
|
1460
1725
|
var output = '';
|
|
1726
|
+
|
|
1461
1727
|
if (length > 100) {
|
|
1462
1728
|
output = Math.round(length / 1000 * 100) / 100 + ' ' + 'km';
|
|
1463
1729
|
} else {
|
|
1464
1730
|
output = Math.round(length * 100) / 100 + ' ' + 'm';
|
|
1465
1731
|
}
|
|
1732
|
+
|
|
1466
1733
|
return output;
|
|
1467
1734
|
}
|
|
1468
1735
|
}, {
|
|
1469
1736
|
key: "getMapExtent",
|
|
1470
|
-
value:
|
|
1471
|
-
// 获取地图的当前位置状态信息
|
|
1737
|
+
value: // 获取地图的当前位置状态信息
|
|
1472
1738
|
function getMapExtent() {
|
|
1473
1739
|
var t = this;
|
|
1474
1740
|
var gis = t.state.gis;
|
|
1475
1741
|
var obj = {};
|
|
1742
|
+
|
|
1476
1743
|
if (gis) {
|
|
1477
1744
|
var nowBounds = gis.getView().calculateExtent(gis.getSize());
|
|
1478
1745
|
obj.southWest = {
|
|
@@ -1485,10 +1752,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1485
1752
|
};
|
|
1486
1753
|
obj.nowCenter = t.getCenter();
|
|
1487
1754
|
obj.zoom = t.getZoomLevel();
|
|
1755
|
+
|
|
1488
1756
|
var _gis$getSize = gis.getSize(),
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1757
|
+
_gis$getSize2 = _slicedToArray(_gis$getSize, 2),
|
|
1758
|
+
width = _gis$getSize2[0],
|
|
1759
|
+
height = _gis$getSize2[1];
|
|
1760
|
+
|
|
1492
1761
|
obj.mapSize = {
|
|
1493
1762
|
width: width,
|
|
1494
1763
|
height: height
|
|
@@ -1496,13 +1765,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1496
1765
|
obj.radius = ol.sphere.getDistance([obj.nowCenter.lng, obj.nowCenter.lat], [obj.northEast.lng, obj.northEast.lat]);
|
|
1497
1766
|
return obj;
|
|
1498
1767
|
}
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1768
|
+
} //将制定图元展示在视野内 (强制改变地图中心位置)
|
|
1769
|
+
|
|
1501
1770
|
/*
|
|
1502
1771
|
参数arg格式如下1,2
|
|
1503
1772
|
1.string 格式如:'1,a,2,3,4'
|
|
1504
1773
|
2.数组 ['1','2']
|
|
1505
1774
|
*/
|
|
1775
|
+
|
|
1506
1776
|
}, {
|
|
1507
1777
|
key: "setVisiblePoints",
|
|
1508
1778
|
value: function setVisiblePoints(mapVisiblePoints) {
|
|
@@ -1511,50 +1781,64 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1511
1781
|
var arg = null;
|
|
1512
1782
|
var type = mapVisiblePoints.type;
|
|
1513
1783
|
var ary = []; //图元id集合
|
|
1784
|
+
|
|
1514
1785
|
var obj = []; //经纬度集合
|
|
1786
|
+
|
|
1515
1787
|
switch (mapVisiblePoints.fitView) {
|
|
1516
1788
|
case 'point':
|
|
1517
1789
|
arg = this.state.pointIds;
|
|
1518
1790
|
break;
|
|
1791
|
+
|
|
1519
1792
|
case 'line':
|
|
1520
1793
|
arg = this.state.lineIds;
|
|
1521
1794
|
break;
|
|
1795
|
+
|
|
1522
1796
|
case 'polygon':
|
|
1523
1797
|
arg = this.state.polygonIds;
|
|
1524
1798
|
break;
|
|
1799
|
+
|
|
1525
1800
|
case 'circle':
|
|
1526
1801
|
arg = this.state.circleIds;
|
|
1527
1802
|
break;
|
|
1803
|
+
|
|
1528
1804
|
case 'all':
|
|
1529
1805
|
arg = this.state.pointIds.concat(this.state.lineIds).concat(this.state.polygonIds).concat(this.state.circleIds);
|
|
1530
1806
|
break;
|
|
1807
|
+
|
|
1531
1808
|
default:
|
|
1532
1809
|
arg = mapVisiblePoints.fitView;
|
|
1533
1810
|
break;
|
|
1534
1811
|
}
|
|
1812
|
+
|
|
1535
1813
|
if (typeof arg === 'string') {
|
|
1536
1814
|
ary = arg.split(',');
|
|
1537
1815
|
} else if (arg instanceof Array) {
|
|
1538
1816
|
ary = arg;
|
|
1539
1817
|
}
|
|
1818
|
+
|
|
1540
1819
|
for (var i = 0; i < ary.length; i++) {
|
|
1541
1820
|
var g = t.GM.getGraphicParam(ary[i]);
|
|
1821
|
+
|
|
1542
1822
|
if (g) {
|
|
1543
1823
|
switch (g.geometry.type) {
|
|
1544
1824
|
case 'point':
|
|
1545
1825
|
obj.push([g.geometry.x, g.geometry.y]);
|
|
1826
|
+
|
|
1546
1827
|
case 'circle':
|
|
1547
1828
|
obj.push([g.geometry.x, g.geometry.y]);
|
|
1548
1829
|
break;
|
|
1830
|
+
|
|
1549
1831
|
case 'polyline':
|
|
1550
1832
|
obj = [].concat(_toConsumableArray(obj), _toConsumableArray(g.geometry.paths));
|
|
1551
1833
|
break;
|
|
1834
|
+
|
|
1552
1835
|
case 'polygon':
|
|
1553
1836
|
obj = [].concat(_toConsumableArray(obj), _toConsumableArray(g.geometry.rings));
|
|
1554
1837
|
break;
|
|
1555
1838
|
}
|
|
1556
1839
|
}
|
|
1557
1840
|
}
|
|
1841
|
+
|
|
1558
1842
|
if (obj.length > 0) {
|
|
1559
1843
|
var displayRange = new ol.extent.boundingExtent(obj);
|
|
1560
1844
|
gis.getView().fit(displayRange, gis.getSize());
|
|
@@ -1564,14 +1848,17 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1564
1848
|
key: "getFitView",
|
|
1565
1849
|
value: function getFitView(ids) {
|
|
1566
1850
|
var t = this;
|
|
1851
|
+
|
|
1567
1852
|
if (ids.length > 0) {
|
|
1568
1853
|
var maxX = null,
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1854
|
+
maxY = null,
|
|
1855
|
+
minX = null,
|
|
1856
|
+
minY = null;
|
|
1857
|
+
|
|
1572
1858
|
for (var i = 0; i < ids.length; i++) {
|
|
1573
1859
|
var coord = t.GM.getGraphic(ids[i]);
|
|
1574
1860
|
var boundsArry = coord.getGeometry().getExtent();
|
|
1861
|
+
|
|
1575
1862
|
if (minX === null) {
|
|
1576
1863
|
minX = boundsArry[0];
|
|
1577
1864
|
minY = boundsArry[1];
|
|
@@ -1584,12 +1871,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1584
1871
|
maxY = Math.max(boundsArry[3], maxY);
|
|
1585
1872
|
}
|
|
1586
1873
|
}
|
|
1874
|
+
|
|
1587
1875
|
var bounds = [minX, minY, maxX, maxY];
|
|
1588
1876
|
return bounds;
|
|
1589
1877
|
}
|
|
1590
1878
|
}
|
|
1591
1879
|
/*功能方法*/
|
|
1592
1880
|
//获取当前地图的中心位置
|
|
1881
|
+
|
|
1593
1882
|
}, {
|
|
1594
1883
|
key: "getCurrentCenter",
|
|
1595
1884
|
value: function getCurrentCenter() {
|
|
@@ -1597,31 +1886,36 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1597
1886
|
var gis = t.state.gis;
|
|
1598
1887
|
var extent = gis.getView().calculateExtent(gis.getSize());
|
|
1599
1888
|
return [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1889
|
+
} //获取当前比例尺
|
|
1890
|
+
|
|
1602
1891
|
}, {
|
|
1603
1892
|
key: "getZoomLevel",
|
|
1604
1893
|
value: function getZoomLevel() {
|
|
1605
1894
|
var t = this;
|
|
1606
1895
|
return t.state.gis.getView().getZoom();
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1896
|
+
} //获取图元数据
|
|
1897
|
+
|
|
1609
1898
|
}, {
|
|
1610
1899
|
key: "getGraphic",
|
|
1611
1900
|
value: function getGraphic(id) {
|
|
1612
1901
|
var t = this;
|
|
1902
|
+
|
|
1613
1903
|
if (!id) {
|
|
1614
1904
|
return false;
|
|
1615
1905
|
}
|
|
1906
|
+
|
|
1616
1907
|
var gp = t.GM.getGraphicParam(id);
|
|
1617
1908
|
var gg = t.GM.getGraphic(id);
|
|
1909
|
+
|
|
1618
1910
|
if (!gg) {
|
|
1619
1911
|
return false;
|
|
1620
1912
|
}
|
|
1913
|
+
|
|
1621
1914
|
var p = {},
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1915
|
+
pts = [],
|
|
1916
|
+
lng = 0,
|
|
1917
|
+
lat = 0;
|
|
1918
|
+
|
|
1625
1919
|
switch (gp.geometryType) {
|
|
1626
1920
|
case 'point':
|
|
1627
1921
|
lng = gp.geometry.x;
|
|
@@ -1642,6 +1936,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1642
1936
|
})
|
|
1643
1937
|
});
|
|
1644
1938
|
break;
|
|
1939
|
+
|
|
1645
1940
|
case 'polyline':
|
|
1646
1941
|
pts = gp.geometry.paths;
|
|
1647
1942
|
p = _objectSpread(_objectSpread({}, gp), {}, {
|
|
@@ -1657,6 +1952,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1657
1952
|
})
|
|
1658
1953
|
});
|
|
1659
1954
|
break;
|
|
1955
|
+
|
|
1660
1956
|
case 'polygon':
|
|
1661
1957
|
pts = gp.geometry.rings;
|
|
1662
1958
|
p = _objectSpread(_objectSpread({}, gp), {}, {
|
|
@@ -1673,6 +1969,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1673
1969
|
area: (0, _MapToolFunction.getPolygonArea)(pts)
|
|
1674
1970
|
});
|
|
1675
1971
|
break;
|
|
1972
|
+
|
|
1676
1973
|
case 'circle':
|
|
1677
1974
|
lng = gp.geometry.x;
|
|
1678
1975
|
lat = gp.geometry.y;
|
|
@@ -1697,17 +1994,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1697
1994
|
});
|
|
1698
1995
|
break;
|
|
1699
1996
|
}
|
|
1997
|
+
|
|
1700
1998
|
return p;
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1999
|
+
} // 转换dom节点
|
|
2000
|
+
|
|
1703
2001
|
}, {
|
|
1704
2002
|
key: "parseDom",
|
|
1705
2003
|
value: function parseDom(domStr) {
|
|
1706
2004
|
var domObj = document.createElement('div');
|
|
1707
2005
|
domObj.innerHTML = domStr;
|
|
1708
2006
|
return domObj.childNodes;
|
|
1709
|
-
}
|
|
1710
|
-
|
|
2007
|
+
} //添加海量点
|
|
2008
|
+
|
|
1711
2009
|
}, {
|
|
1712
2010
|
key: "addPointCollection",
|
|
1713
2011
|
value: function addPointCollection() {
|
|
@@ -1719,10 +2017,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1719
2017
|
var p = t.state.gis.getPixelFromCoordinate([d.lng, d.lat]);
|
|
1720
2018
|
return [p[0], p[1]];
|
|
1721
2019
|
});
|
|
2020
|
+
|
|
1722
2021
|
var _t$state$gis$getSize = t.state.gis.getSize(),
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
2022
|
+
_t$state$gis$getSize2 = _slicedToArray(_t$state$gis$getSize, 2),
|
|
2023
|
+
width = _t$state$gis$getSize2[0],
|
|
2024
|
+
height = _t$state$gis$getSize2[1];
|
|
2025
|
+
|
|
1726
2026
|
var options = {
|
|
1727
2027
|
size: d.size,
|
|
1728
2028
|
shape: d.shape,
|
|
@@ -1738,8 +2038,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1738
2038
|
});
|
|
1739
2039
|
VotexpointCollection.draw();
|
|
1740
2040
|
});
|
|
1741
|
-
}
|
|
1742
|
-
|
|
2041
|
+
} //更新海量点
|
|
2042
|
+
|
|
1743
2043
|
}, {
|
|
1744
2044
|
key: "updatePointCollection",
|
|
1745
2045
|
value: function updatePointCollection() {
|
|
@@ -1752,10 +2052,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1752
2052
|
var p = t.state.gis.getPixelFromCoordinate([d.lng, d.lat]);
|
|
1753
2053
|
return [p[0], p[1]];
|
|
1754
2054
|
});
|
|
2055
|
+
|
|
1755
2056
|
var _t$state$gis$getSize3 = t.state.gis.getSize(),
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
2057
|
+
_t$state$gis$getSize4 = _slicedToArray(_t$state$gis$getSize3, 2),
|
|
2058
|
+
width = _t$state$gis$getSize4[0],
|
|
2059
|
+
height = _t$state$gis$getSize4[1];
|
|
2060
|
+
|
|
1759
2061
|
var options = {
|
|
1760
2062
|
size: ds.size,
|
|
1761
2063
|
shape: ds.shape,
|
|
@@ -1767,8 +2069,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1767
2069
|
}
|
|
1768
2070
|
});
|
|
1769
2071
|
});
|
|
1770
|
-
}
|
|
1771
|
-
|
|
2072
|
+
} //删除海量点
|
|
2073
|
+
|
|
1772
2074
|
}, {
|
|
1773
2075
|
key: "clearPointCollection",
|
|
1774
2076
|
value: function clearPointCollection() {
|
|
@@ -1781,9 +2083,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1781
2083
|
}
|
|
1782
2084
|
});
|
|
1783
2085
|
});
|
|
1784
|
-
}
|
|
2086
|
+
} //删除全部海量点
|
|
1785
2087
|
|
|
1786
|
-
//删除全部海量点
|
|
1787
2088
|
}, {
|
|
1788
2089
|
key: "clearAllPointCollection",
|
|
1789
2090
|
value: function clearAllPointCollection() {
|
|
@@ -1791,24 +2092,26 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1791
2092
|
t.morepoints.map(function (item, index) {
|
|
1792
2093
|
item.value.clear();
|
|
1793
2094
|
});
|
|
1794
|
-
}
|
|
1795
|
-
|
|
2095
|
+
} // 框选
|
|
2096
|
+
|
|
1796
2097
|
}, {
|
|
1797
2098
|
key: "frameSelect",
|
|
1798
|
-
value: function frameSelect(
|
|
1799
|
-
var geometryType =
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
2099
|
+
value: function frameSelect(_ref2, callback) {
|
|
2100
|
+
var geometryType = _ref2.geometryType,
|
|
2101
|
+
_ref2$parameter = _ref2.parameter,
|
|
2102
|
+
parameter = _ref2$parameter === void 0 ? {} : _ref2$parameter,
|
|
2103
|
+
_ref2$data = _ref2.data,
|
|
2104
|
+
data = _ref2$data === void 0 ? {} : _ref2$data;
|
|
2105
|
+
|
|
1804
2106
|
if (!['polygon', 'circle', 'rectangle'].includes(geometryType)) {
|
|
1805
2107
|
message.warn("传入的类型不支持框选!");
|
|
1806
2108
|
return false;
|
|
1807
2109
|
}
|
|
2110
|
+
|
|
1808
2111
|
var t = this;
|
|
1809
2112
|
var params = {},
|
|
1810
|
-
|
|
1811
|
-
|
|
2113
|
+
type = geometryType || 'polygon',
|
|
2114
|
+
id = data.id || "frameSelectFeature_".concat(Math.random());
|
|
1812
2115
|
params.color = parameter.color || '#FF0000';
|
|
1813
2116
|
params.lineColor = parameter.lineColor || '#FF0000';
|
|
1814
2117
|
params.lineOpacity = parameter.lineOpacity || 1;
|
|
@@ -1827,17 +2130,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1827
2130
|
id: id,
|
|
1828
2131
|
type: geometryType
|
|
1829
2132
|
};
|
|
1830
|
-
}
|
|
1831
|
-
|
|
2133
|
+
} // 清除框选
|
|
2134
|
+
|
|
1832
2135
|
}, {
|
|
1833
2136
|
key: "clearFrameSelect",
|
|
1834
2137
|
value: function clearFrameSelect() {
|
|
1835
2138
|
for (var key in this.frameSelectProps) {
|
|
1836
2139
|
this.removeGraphic(this.frameSelectProps[key].id, this.frameSelectProps[key].type);
|
|
1837
2140
|
}
|
|
2141
|
+
|
|
1838
2142
|
this.frameSelectProps = {};
|
|
1839
|
-
}
|
|
1840
|
-
|
|
2143
|
+
} // 清除框选ById
|
|
2144
|
+
|
|
1841
2145
|
}, {
|
|
1842
2146
|
key: "clearFrameSelectById",
|
|
1843
2147
|
value: function clearFrameSelectById(id) {
|
|
@@ -1852,14 +2156,17 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1852
2156
|
* @content: String|HTML
|
|
1853
2157
|
* @close: boolean
|
|
1854
2158
|
*/
|
|
2159
|
+
|
|
1855
2160
|
}, {
|
|
1856
2161
|
key: "showInfoWindow",
|
|
1857
2162
|
value: function showInfoWindow() {
|
|
1858
2163
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1859
2164
|
var t = this;
|
|
2165
|
+
|
|
1860
2166
|
if (t.popupWindow) {
|
|
1861
2167
|
t.hideInfoWindow();
|
|
1862
2168
|
}
|
|
2169
|
+
|
|
1863
2170
|
t.popupWindow = new Popup({
|
|
1864
2171
|
map: t.state.gis,
|
|
1865
2172
|
position: params.position,
|
|
@@ -1872,31 +2179,38 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1872
2179
|
key: "hideInfoWindow",
|
|
1873
2180
|
value: function hideInfoWindow() {
|
|
1874
2181
|
var t = this;
|
|
2182
|
+
|
|
1875
2183
|
if (t.popupWindow) {
|
|
1876
2184
|
t.popupWindow.removePopup();
|
|
1877
2185
|
}
|
|
2186
|
+
|
|
1878
2187
|
t.popupWindow = null;
|
|
1879
|
-
}
|
|
1880
|
-
|
|
2188
|
+
} // 添加点
|
|
2189
|
+
|
|
1881
2190
|
}, {
|
|
1882
2191
|
key: "addPoint",
|
|
1883
2192
|
value: function addPoint(mapPoints, type) {
|
|
1884
2193
|
var _this2 = this;
|
|
2194
|
+
|
|
1885
2195
|
var t = this;
|
|
1886
2196
|
var ps = [];
|
|
2197
|
+
|
|
1887
2198
|
var psids = _toConsumableArray(t.state.pointIds);
|
|
2199
|
+
|
|
1888
2200
|
mapPoints.map(function (item, index) {
|
|
1889
2201
|
//如果id重复,直接跳过不执行.
|
|
1890
2202
|
if (_this2.GM.isRepetition(item.id)) {
|
|
1891
2203
|
console.warn("\u52A0\u70B9id: ".concat(item.id, " \u91CD\u590D"));
|
|
1892
2204
|
return false;
|
|
1893
|
-
}
|
|
1894
|
-
|
|
2205
|
+
} //点位数据不符合,直接跳过
|
|
2206
|
+
|
|
2207
|
+
|
|
1895
2208
|
if (!item.longitude || !item.latitude) {
|
|
1896
2209
|
console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
|
|
1897
2210
|
return false;
|
|
1898
|
-
}
|
|
1899
|
-
|
|
2211
|
+
} // 创建点位图元要素
|
|
2212
|
+
|
|
2213
|
+
|
|
1900
2214
|
var feature = new ol.Feature({
|
|
1901
2215
|
geometry: new ol.geom.Point([parseFloat(item.longitude), parseFloat(item.latitude)]),
|
|
1902
2216
|
name: item.name,
|
|
@@ -1914,23 +2228,25 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1914
2228
|
zIndex: 100,
|
|
1915
2229
|
deg: 0,
|
|
1916
2230
|
scale: 1
|
|
1917
|
-
};
|
|
1918
|
-
|
|
2231
|
+
}; //初始化默认数据
|
|
2232
|
+
|
|
1919
2233
|
if (item.config) {
|
|
1920
2234
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1921
|
-
}
|
|
1922
|
-
|
|
2235
|
+
} // 覆盖物样式参数
|
|
2236
|
+
|
|
2237
|
+
|
|
1923
2238
|
var style, icon, txt;
|
|
1924
2239
|
var myImage = new Image(cg.width, cg.height);
|
|
2240
|
+
|
|
1925
2241
|
if (!!item.markerContent) {
|
|
1926
|
-
var nodes = t.parseDom(item.markerContent)[0];
|
|
1927
|
-
|
|
2242
|
+
var nodes = t.parseDom(item.markerContent)[0]; // 自定义图层需要把事件加在dom上
|
|
2243
|
+
|
|
1928
2244
|
nodes.addEventListener("click", function (e) {
|
|
1929
2245
|
t.clickGraphic(item.id, _objectSpread(_objectSpread({}, e), {}, {
|
|
1930
2246
|
pixel: [e.clientX, e.clientY]
|
|
1931
2247
|
}));
|
|
1932
|
-
});
|
|
1933
|
-
|
|
2248
|
+
}); // 创建地图自定义覆盖物
|
|
2249
|
+
|
|
1934
2250
|
var pop = new ol.Overlay({
|
|
1935
2251
|
id: item.id,
|
|
1936
2252
|
position: [parseFloat(item.longitude), parseFloat(item.latitude)],
|
|
@@ -1949,8 +2265,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1949
2265
|
height: cg.height
|
|
1950
2266
|
}, function (base64) {
|
|
1951
2267
|
myImage.src = base64;
|
|
1952
|
-
});
|
|
1953
|
-
|
|
2268
|
+
}); // 创建地图要素图标样式
|
|
2269
|
+
|
|
1954
2270
|
style = new ol.style.Style({
|
|
1955
2271
|
image: new ol.style.Icon({
|
|
1956
2272
|
anchor: [-cg.markerContentX, -cg.markerContentY],
|
|
@@ -1963,6 +2279,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1963
2279
|
})
|
|
1964
2280
|
});
|
|
1965
2281
|
}
|
|
2282
|
+
|
|
1966
2283
|
if (!!item.canShowLabel && item.canShowLabel) {
|
|
1967
2284
|
var textStyle = _objectSpread({
|
|
1968
2285
|
textAlign: 'center',
|
|
@@ -1987,17 +2304,20 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1987
2304
|
}),
|
|
1988
2305
|
padding: [2, 5, 2, 5]
|
|
1989
2306
|
}, cg.labelStyle || {});
|
|
2307
|
+
|
|
1990
2308
|
if (cg.labelStyle && cg.labelStyle.fill) {
|
|
1991
2309
|
textStyle['fill'] = new ol.style.Fill({
|
|
1992
2310
|
color: cg.labelStyle.fill
|
|
1993
2311
|
});
|
|
1994
2312
|
}
|
|
2313
|
+
|
|
1995
2314
|
if (cg.labelStyle && cg.labelStyle.backgroundFill) {
|
|
1996
2315
|
textStyle['backgroundFill'] = new ol.style.Fill({
|
|
1997
2316
|
color: cg.labelStyle.backgroundFill
|
|
1998
2317
|
});
|
|
1999
|
-
}
|
|
2000
|
-
|
|
2318
|
+
} // 创建地图要素图标样式
|
|
2319
|
+
|
|
2320
|
+
|
|
2001
2321
|
style = new ol.style.Style({
|
|
2002
2322
|
image: new ol.style.Icon({
|
|
2003
2323
|
anchor: [-cg.markerContentX, -cg.markerContentY],
|
|
@@ -2013,8 +2333,9 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2013
2333
|
text: new ol.style.Text(textStyle)
|
|
2014
2334
|
});
|
|
2015
2335
|
}
|
|
2016
|
-
|
|
2017
|
-
// 初始化适量数据源
|
|
2336
|
+
|
|
2337
|
+
feature.setStyle(style); // 初始化适量数据源
|
|
2338
|
+
|
|
2018
2339
|
var source = new ol.source.Vector({
|
|
2019
2340
|
features: [feature],
|
|
2020
2341
|
name: 'point',
|
|
@@ -2028,16 +2349,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2028
2349
|
t.pointLayers.push({
|
|
2029
2350
|
id: item.id,
|
|
2030
2351
|
layer: pointLayer
|
|
2031
|
-
});
|
|
2032
|
-
|
|
2352
|
+
}); //添加点位图层
|
|
2353
|
+
|
|
2033
2354
|
t.state.gis.addLayer(pointLayer);
|
|
2355
|
+
|
|
2034
2356
|
if (!item.markerContent && cg.BAnimationType == 0) {
|
|
2035
2357
|
marker.setAnimation(BMAP_ANIMATION_BOUNCE);
|
|
2036
2358
|
} else if (!item.markerContent && cg.BAnimationType == 1) {
|
|
2037
2359
|
marker.setAnimation(BMAP_ANIMATION_DROP);
|
|
2038
2360
|
}
|
|
2039
|
-
|
|
2040
|
-
//缓存图元的数据,偏于后期操作
|
|
2361
|
+
|
|
2362
|
+
psids.push(item.id); //缓存图元的数据,偏于后期操作
|
|
2363
|
+
|
|
2041
2364
|
_this2.GM.setGraphic(item.id, feature).setGraphicParam(item.id, {
|
|
2042
2365
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
2043
2366
|
other: item
|
|
@@ -2051,21 +2374,24 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2051
2374
|
source: source
|
|
2052
2375
|
});
|
|
2053
2376
|
});
|
|
2377
|
+
|
|
2054
2378
|
if (type !== 'defined') {
|
|
2055
2379
|
// t.state.pointIds = psids;
|
|
2056
2380
|
t.setState({
|
|
2057
2381
|
pointIds: psids
|
|
2058
2382
|
});
|
|
2059
2383
|
}
|
|
2060
|
-
}
|
|
2061
|
-
|
|
2384
|
+
} //更新点
|
|
2385
|
+
|
|
2062
2386
|
}, {
|
|
2063
2387
|
key: "updatePoint",
|
|
2064
2388
|
value: function updatePoint() {
|
|
2065
2389
|
var _this3 = this;
|
|
2390
|
+
|
|
2066
2391
|
var mapPoints = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2067
2392
|
var t = this;
|
|
2068
2393
|
var index = 0;
|
|
2394
|
+
|
|
2069
2395
|
var dealPoint = function dealPoint(item) {
|
|
2070
2396
|
if (_this3.GM.isRepetition(item.id)) {
|
|
2071
2397
|
//点位数据不符合,直接跳过
|
|
@@ -2073,6 +2399,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2073
2399
|
console.warn("\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
|
|
2074
2400
|
return false;
|
|
2075
2401
|
}
|
|
2402
|
+
|
|
2076
2403
|
var gc = t.GM.getGraphic(item.id);
|
|
2077
2404
|
var gp = t.GM.getGraphicParam(item.id);
|
|
2078
2405
|
var cg = {
|
|
@@ -2087,11 +2414,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2087
2414
|
markerContentY: -30,
|
|
2088
2415
|
deg: 0
|
|
2089
2416
|
};
|
|
2417
|
+
|
|
2090
2418
|
if (item.config) {
|
|
2091
2419
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
2092
2420
|
}
|
|
2421
|
+
|
|
2093
2422
|
var text, icon, _marker;
|
|
2423
|
+
|
|
2094
2424
|
var myImage = new Image(cg.width, cg.height);
|
|
2425
|
+
|
|
2095
2426
|
if (item.markerContent) {
|
|
2096
2427
|
var overlay = t.state.gis.getOverlayById(item.id);
|
|
2097
2428
|
var nodes = t.parseDom(item.markerContent)[0];
|
|
@@ -2121,6 +2452,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2121
2452
|
scale: cg.scale || 1,
|
|
2122
2453
|
rotation: Math.PI / 180 * cg.deg
|
|
2123
2454
|
});
|
|
2455
|
+
|
|
2124
2456
|
if (item.canShowLabel) {
|
|
2125
2457
|
var textStyle = _objectSpread({
|
|
2126
2458
|
textAlign: 'center',
|
|
@@ -2145,18 +2477,22 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2145
2477
|
}),
|
|
2146
2478
|
padding: [2, 5, 2, 5]
|
|
2147
2479
|
}, cg.labelStyle || {});
|
|
2480
|
+
|
|
2148
2481
|
if (cg.labelStyle && cg.labelStyle.fill) {
|
|
2149
2482
|
textStyle['fill'] = new ol.style.Fill({
|
|
2150
2483
|
color: cg.labelStyle.fill
|
|
2151
2484
|
});
|
|
2152
2485
|
}
|
|
2486
|
+
|
|
2153
2487
|
if (cg.labelStyle && cg.labelStyle.backgroundFill) {
|
|
2154
2488
|
textStyle['backgroundFill'] = new ol.style.Fill({
|
|
2155
2489
|
color: cg.labelStyle.backgroundFill
|
|
2156
2490
|
});
|
|
2157
2491
|
}
|
|
2492
|
+
|
|
2158
2493
|
text = new ol.style.Text(textStyle);
|
|
2159
2494
|
}
|
|
2495
|
+
|
|
2160
2496
|
if (text) {
|
|
2161
2497
|
gc.setStyle(new ol.style.Style({
|
|
2162
2498
|
image: icon,
|
|
@@ -2168,7 +2504,9 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2168
2504
|
}));
|
|
2169
2505
|
}
|
|
2170
2506
|
}
|
|
2507
|
+
|
|
2171
2508
|
gc.setGeometry(new ol.geom.Point([parseFloat(item.longitude), parseFloat(item.latitude)]));
|
|
2509
|
+
|
|
2172
2510
|
_this3.GM.setGraphicParam(item.id, {
|
|
2173
2511
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
2174
2512
|
other: item
|
|
@@ -2185,6 +2523,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2185
2523
|
console.warn("\u66F4\u65B0\u7684\u70B9\u4F4Did\u4E0D\u5B58\u5728!");
|
|
2186
2524
|
return false;
|
|
2187
2525
|
}
|
|
2526
|
+
|
|
2188
2527
|
if (index < mapPoints.length - 1) {
|
|
2189
2528
|
requestIdleCallback(function () {
|
|
2190
2529
|
return dealPoint(mapPoints[++index]);
|
|
@@ -2193,13 +2532,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2193
2532
|
t.refresh();
|
|
2194
2533
|
}
|
|
2195
2534
|
};
|
|
2535
|
+
|
|
2196
2536
|
if (!(0, _lodash.isEmpty)(mapPoints)) {
|
|
2197
2537
|
requestIdleCallback(function () {
|
|
2198
2538
|
return dealPoint(mapPoints[index]);
|
|
2199
2539
|
});
|
|
2200
2540
|
}
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2541
|
+
} // 更新图层
|
|
2542
|
+
|
|
2203
2543
|
}, {
|
|
2204
2544
|
key: "refresh",
|
|
2205
2545
|
value: function refresh() {
|
|
@@ -2208,27 +2548,32 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2208
2548
|
clearTimeout(timer);
|
|
2209
2549
|
window.VtxMap[t.props.mapId].redrawText();
|
|
2210
2550
|
}, 100);
|
|
2211
|
-
}
|
|
2212
|
-
|
|
2551
|
+
} // 添加先
|
|
2552
|
+
|
|
2213
2553
|
}, {
|
|
2214
2554
|
key: "addLine",
|
|
2215
2555
|
value: function addLine(mapLines, type) {
|
|
2216
2556
|
var _this4 = this;
|
|
2557
|
+
|
|
2217
2558
|
var t = this;
|
|
2218
2559
|
var ls = [];
|
|
2219
|
-
|
|
2220
|
-
//遍历添加线(图元)
|
|
2560
|
+
|
|
2561
|
+
var lsids = _toConsumableArray(t.state.lineIds); //遍历添加线(图元)
|
|
2562
|
+
|
|
2563
|
+
|
|
2221
2564
|
mapLines.map(function (item, index) {
|
|
2222
2565
|
//如果id重复,直接跳过不执行.
|
|
2223
2566
|
if (_this4.GM.isRepetition(item.id)) {
|
|
2224
2567
|
console.warn("\u591A\u6298\u7EBFid: ".concat(item.id, " \u91CD\u590D"));
|
|
2225
2568
|
return false;
|
|
2226
|
-
}
|
|
2227
|
-
|
|
2569
|
+
} //多折线点位数据不符合,直接跳过
|
|
2570
|
+
|
|
2571
|
+
|
|
2228
2572
|
if (!(item.paths && item.paths.length >= 2)) {
|
|
2229
2573
|
console.warn("\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF");
|
|
2230
2574
|
return false;
|
|
2231
2575
|
}
|
|
2576
|
+
|
|
2232
2577
|
var cg = {
|
|
2233
2578
|
color: '#277ffa',
|
|
2234
2579
|
pellucidity: 0.9,
|
|
@@ -2236,9 +2581,11 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2236
2581
|
lineType: 'solid',
|
|
2237
2582
|
isHidden: false
|
|
2238
2583
|
};
|
|
2584
|
+
|
|
2239
2585
|
if (item.config) {
|
|
2240
2586
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
2241
2587
|
}
|
|
2588
|
+
|
|
2242
2589
|
var style = new ol.style.Style({
|
|
2243
2590
|
stroke: new ol.style.Stroke({
|
|
2244
2591
|
color: cg.color,
|
|
@@ -2262,11 +2609,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2262
2609
|
id: item.id,
|
|
2263
2610
|
source: source
|
|
2264
2611
|
});
|
|
2265
|
-
t.state.gis.addLayer(lineLayer);
|
|
2266
|
-
|
|
2612
|
+
t.state.gis.addLayer(lineLayer); //缓存图元的数据,便于后期操作
|
|
2613
|
+
|
|
2267
2614
|
var pts = item.paths.map(function (itt, ind) {
|
|
2268
2615
|
return _toConsumableArray(itt);
|
|
2269
2616
|
});
|
|
2617
|
+
|
|
2270
2618
|
_this4.GM.setGraphic(item.id, polyline).setGraphicParam(item.id, {
|
|
2271
2619
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
2272
2620
|
paths: pts,
|
|
@@ -2279,21 +2627,24 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2279
2627
|
},
|
|
2280
2628
|
source: source
|
|
2281
2629
|
});
|
|
2630
|
+
|
|
2282
2631
|
ls.push(polyline);
|
|
2283
2632
|
lsids.push(item.id);
|
|
2284
2633
|
t.state.lineIds.push(item.id);
|
|
2285
2634
|
});
|
|
2635
|
+
|
|
2286
2636
|
if (type !== 'defined') {
|
|
2287
2637
|
t.state.lineIds = lsids;
|
|
2288
2638
|
}
|
|
2289
|
-
}
|
|
2290
|
-
|
|
2639
|
+
} //更新线
|
|
2640
|
+
|
|
2291
2641
|
}, {
|
|
2292
2642
|
key: "updateLine",
|
|
2293
2643
|
value: function updateLine(mapLines) {
|
|
2294
2644
|
var _this5 = this;
|
|
2295
|
-
|
|
2296
|
-
//遍历添加线(图元)
|
|
2645
|
+
|
|
2646
|
+
var t = this; //遍历添加线(图元)
|
|
2647
|
+
|
|
2297
2648
|
mapLines.map(function (item, index) {
|
|
2298
2649
|
//判断图元是否存在.
|
|
2299
2650
|
if (_this5.GM.isRepetition(item.id)) {
|
|
@@ -2301,8 +2652,9 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2301
2652
|
if (!(item.paths && item.paths.length >= 2)) {
|
|
2302
2653
|
console.warn("\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF");
|
|
2303
2654
|
return false;
|
|
2304
|
-
}
|
|
2305
|
-
|
|
2655
|
+
} //初始化默认参数
|
|
2656
|
+
|
|
2657
|
+
|
|
2306
2658
|
var cg = {
|
|
2307
2659
|
color: '#277ffa',
|
|
2308
2660
|
pellucidity: 0.9,
|
|
@@ -2310,14 +2662,17 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2310
2662
|
lineType: 'solid',
|
|
2311
2663
|
//'solid' 'dashed'
|
|
2312
2664
|
isHidden: false
|
|
2313
|
-
};
|
|
2314
|
-
|
|
2665
|
+
}; //获取原有的图元
|
|
2666
|
+
|
|
2315
2667
|
var gc = _this5.GM.getGraphic(item.id);
|
|
2316
|
-
|
|
2317
|
-
//重新初始化值
|
|
2668
|
+
|
|
2669
|
+
var gp = _this5.GM.getGraphicParam(item.id); //重新初始化值
|
|
2670
|
+
|
|
2671
|
+
|
|
2318
2672
|
if (item.config) {
|
|
2319
2673
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
2320
2674
|
}
|
|
2675
|
+
|
|
2321
2676
|
var pts = item.paths.map(function (itt, ind) {
|
|
2322
2677
|
return _toConsumableArray(itt);
|
|
2323
2678
|
});
|
|
@@ -2333,6 +2688,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2333
2688
|
return style;
|
|
2334
2689
|
});
|
|
2335
2690
|
gc.setGeometry(new ol.geom.LineString(pts));
|
|
2691
|
+
|
|
2336
2692
|
_this5.GM.setGraphicParam(item.id, {
|
|
2337
2693
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
2338
2694
|
paths: pts,
|
|
@@ -2350,27 +2706,32 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2350
2706
|
return false;
|
|
2351
2707
|
}
|
|
2352
2708
|
});
|
|
2353
|
-
}
|
|
2354
|
-
|
|
2709
|
+
} //添加面
|
|
2710
|
+
|
|
2355
2711
|
}, {
|
|
2356
2712
|
key: "addPolygon",
|
|
2357
2713
|
value: function addPolygon(mapPolygons) {
|
|
2358
2714
|
var _this6 = this;
|
|
2715
|
+
|
|
2359
2716
|
var t = this;
|
|
2360
2717
|
var pgs = [];
|
|
2361
|
-
|
|
2362
|
-
//遍历添加面(图元)
|
|
2718
|
+
|
|
2719
|
+
var pgsids = _toConsumableArray(t.state.polygonIds); //遍历添加面(图元)
|
|
2720
|
+
|
|
2721
|
+
|
|
2363
2722
|
mapPolygons.map(function (item, index) {
|
|
2364
2723
|
//如果id重复,直接跳过不执行.
|
|
2365
2724
|
if (_this6.GM.isRepetition(item.id)) {
|
|
2366
2725
|
console.warn("\u591A\u8FB9\u5F62id: ".concat(item.id, " \u91CD\u590D"));
|
|
2367
2726
|
return false;
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2727
|
+
} //多边形点位数据不符合,直接跳过
|
|
2728
|
+
|
|
2729
|
+
|
|
2370
2730
|
if (!(item.rings && item.rings.length >= 3)) {
|
|
2371
2731
|
console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
|
|
2372
2732
|
return false;
|
|
2373
2733
|
}
|
|
2734
|
+
|
|
2374
2735
|
var cg = {
|
|
2375
2736
|
lineType: 'solid',
|
|
2376
2737
|
lineWidth: 5,
|
|
@@ -2379,9 +2740,11 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2379
2740
|
color: '#fff',
|
|
2380
2741
|
pellucidity: 0.5
|
|
2381
2742
|
};
|
|
2743
|
+
|
|
2382
2744
|
if (item.config) {
|
|
2383
2745
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
2384
2746
|
}
|
|
2747
|
+
|
|
2385
2748
|
var style = new ol.style.Style({
|
|
2386
2749
|
stroke: new ol.style.Stroke({
|
|
2387
2750
|
color: cg.lineColor,
|
|
@@ -2408,11 +2771,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2408
2771
|
id: item.id,
|
|
2409
2772
|
source: source
|
|
2410
2773
|
});
|
|
2411
|
-
t.state.gis.addLayer(polygonLayer);
|
|
2412
|
-
|
|
2774
|
+
t.state.gis.addLayer(polygonLayer); //缓存图元的数据,便于后期操作
|
|
2775
|
+
|
|
2413
2776
|
var pts = item.rings.map(function (itt, ind) {
|
|
2414
2777
|
return _toConsumableArray(itt);
|
|
2415
2778
|
});
|
|
2779
|
+
|
|
2416
2780
|
_this6.GM.setGraphic(item.id, polygon).setGraphicParam(item.id, {
|
|
2417
2781
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
2418
2782
|
rings: pts,
|
|
@@ -2425,16 +2789,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2425
2789
|
},
|
|
2426
2790
|
source: source
|
|
2427
2791
|
});
|
|
2792
|
+
|
|
2428
2793
|
pgs.push(polygon);
|
|
2429
2794
|
pgsids.push(item.id);
|
|
2430
2795
|
});
|
|
2431
2796
|
t.state.polygonIds = pgsids;
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2797
|
+
} //更新面
|
|
2798
|
+
|
|
2434
2799
|
}, {
|
|
2435
2800
|
key: "updatePolygon",
|
|
2436
2801
|
value: function updatePolygon(mapPolygons) {
|
|
2437
2802
|
var _this7 = this;
|
|
2803
|
+
|
|
2438
2804
|
var t = this;
|
|
2439
2805
|
mapPolygons.map(function (item, index) {
|
|
2440
2806
|
//判断图元是否存在.
|
|
@@ -2443,11 +2809,13 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2443
2809
|
if (!(item.rings && item.rings.length >= 3)) {
|
|
2444
2810
|
console.warn("\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF");
|
|
2445
2811
|
return false;
|
|
2446
|
-
}
|
|
2447
|
-
|
|
2812
|
+
} //获取原有的图元
|
|
2813
|
+
|
|
2814
|
+
|
|
2448
2815
|
var gc = _this7.GM.getGraphic(item.id);
|
|
2449
|
-
|
|
2450
|
-
//获取原有的面属性,转换key值
|
|
2816
|
+
|
|
2817
|
+
var gp = t.GM.getGraphicParam(item.id); //获取原有的面属性,转换key值
|
|
2818
|
+
|
|
2451
2819
|
var cg = {
|
|
2452
2820
|
lineType: 'solid',
|
|
2453
2821
|
lineWidth: 5,
|
|
@@ -2455,11 +2823,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2455
2823
|
lineOpacity: 1,
|
|
2456
2824
|
color: '#fff',
|
|
2457
2825
|
pellucidity: 0.5
|
|
2458
|
-
};
|
|
2459
|
-
|
|
2826
|
+
}; //重新初始化值
|
|
2827
|
+
|
|
2460
2828
|
if (item.config) {
|
|
2461
2829
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
2462
2830
|
}
|
|
2831
|
+
|
|
2463
2832
|
var pts = item.rings.map(function (itt, ind) {
|
|
2464
2833
|
return _toConsumableArray(itt);
|
|
2465
2834
|
});
|
|
@@ -2474,6 +2843,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2474
2843
|
color: cg.pellucidity ? getRgbColor(cg.color, cg.pellucidity) : cg.color
|
|
2475
2844
|
})
|
|
2476
2845
|
}));
|
|
2846
|
+
|
|
2477
2847
|
_this7.GM.setGraphicParam(item.id, {
|
|
2478
2848
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
2479
2849
|
rings: pts,
|
|
@@ -2491,39 +2861,46 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2491
2861
|
return false;
|
|
2492
2862
|
}
|
|
2493
2863
|
});
|
|
2494
|
-
}
|
|
2495
|
-
|
|
2864
|
+
} //添加圆 circle
|
|
2865
|
+
|
|
2496
2866
|
}, {
|
|
2497
2867
|
key: "addCircle",
|
|
2498
2868
|
value: function addCircle(mapCircles, type) {
|
|
2499
2869
|
var t = this;
|
|
2870
|
+
|
|
2500
2871
|
var ccsids = _toConsumableArray(t.state.circleIds);
|
|
2872
|
+
|
|
2501
2873
|
if (type) {
|
|
2502
2874
|
ccsids = _toConsumableArray(t.state.drawIds[type]);
|
|
2503
2875
|
}
|
|
2876
|
+
|
|
2504
2877
|
mapCircles.map(function (item, index) {
|
|
2505
2878
|
//如果id重复,直接跳过不执行.
|
|
2506
2879
|
if (t.GM.isRepetition(item.id)) {
|
|
2507
2880
|
console.warn("\u5706id: ".concat(item.id, " \u91CD\u590D"));
|
|
2508
2881
|
return false;
|
|
2509
|
-
}
|
|
2510
|
-
|
|
2882
|
+
} //圆 点位数据不符合,直接跳过
|
|
2883
|
+
|
|
2884
|
+
|
|
2511
2885
|
if (!item.longitude || !item.latitude) {
|
|
2512
2886
|
console.warn("\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF");
|
|
2513
2887
|
return false;
|
|
2514
2888
|
}
|
|
2889
|
+
|
|
2515
2890
|
var cg = {
|
|
2516
2891
|
lineType: 'solid',
|
|
2517
2892
|
lineWidth: 5,
|
|
2518
2893
|
lineColor: '#277ffa',
|
|
2519
2894
|
lineOpacity: 1,
|
|
2520
2895
|
color: '#fff',
|
|
2521
|
-
pellucidity: 0.5
|
|
2522
|
-
|
|
2896
|
+
pellucidity: 0.5 // isHidden: false //后期需要在加
|
|
2897
|
+
|
|
2523
2898
|
};
|
|
2899
|
+
|
|
2524
2900
|
if (item.config) {
|
|
2525
2901
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
2526
2902
|
}
|
|
2903
|
+
|
|
2527
2904
|
var style = new ol.style.Style({
|
|
2528
2905
|
stroke: new ol.style.Stroke({
|
|
2529
2906
|
color: cg.lineColor,
|
|
@@ -2568,15 +2945,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2568
2945
|
},
|
|
2569
2946
|
source: source
|
|
2570
2947
|
});
|
|
2571
|
-
});
|
|
2572
|
-
|
|
2948
|
+
}); //添加绘制点
|
|
2949
|
+
|
|
2573
2950
|
if (type) {
|
|
2574
2951
|
t.state.drawIds = _objectSpread(_objectSpread({}, t.state.drawIds), {}, _defineProperty({}, type, ccsids));
|
|
2575
2952
|
} else {
|
|
2576
2953
|
t.state.circleIds = ccsids;
|
|
2577
2954
|
}
|
|
2578
|
-
}
|
|
2579
|
-
|
|
2955
|
+
} //更新圆
|
|
2956
|
+
|
|
2580
2957
|
}, {
|
|
2581
2958
|
key: "updateCircle",
|
|
2582
2959
|
value: function updateCircle(mapCircles) {
|
|
@@ -2592,23 +2969,26 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2592
2969
|
} else {
|
|
2593
2970
|
console.warn("\u66F4\u65B0\u7684\u5706id\u4E0D\u5B58\u5728!");
|
|
2594
2971
|
return false;
|
|
2595
|
-
}
|
|
2596
|
-
|
|
2972
|
+
} //获取原有的图元
|
|
2973
|
+
|
|
2974
|
+
|
|
2597
2975
|
var gc = t.GM.getGraphic(item.id);
|
|
2598
|
-
var gp = t.GM.getGraphicParam(item.id);
|
|
2599
|
-
|
|
2976
|
+
var gp = t.GM.getGraphicParam(item.id); //获取原有的面属性,转换key值
|
|
2977
|
+
|
|
2600
2978
|
var cg = {
|
|
2601
2979
|
lineType: 'solid',
|
|
2602
2980
|
lineWidth: 5,
|
|
2603
2981
|
lineColor: '#277ffa',
|
|
2604
2982
|
lineOpacity: 1,
|
|
2605
2983
|
color: '#fff',
|
|
2606
|
-
pellucidity: 0.5
|
|
2607
|
-
|
|
2984
|
+
pellucidity: 0.5 // isHidden: false //后期需要在加
|
|
2985
|
+
|
|
2608
2986
|
};
|
|
2987
|
+
|
|
2609
2988
|
if (item.config) {
|
|
2610
2989
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
2611
2990
|
}
|
|
2991
|
+
|
|
2612
2992
|
var metersPerUnit = t.state.gis.getView().getProjection().getMetersPerUnit();
|
|
2613
2993
|
var circleRadius = item.radius / metersPerUnit;
|
|
2614
2994
|
gc.setGeometry(new ol.geom.Circle([item.longitude, item.latitude], parseFloat(circleRadius)));
|
|
@@ -2635,106 +3015,126 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2635
3015
|
},
|
|
2636
3016
|
source: gp.source
|
|
2637
3017
|
});
|
|
2638
|
-
});
|
|
2639
|
-
|
|
2640
|
-
}
|
|
2641
|
-
// 工具方法
|
|
3018
|
+
}); //刷新图元
|
|
3019
|
+
} // 工具方法
|
|
2642
3020
|
//删除图元
|
|
3021
|
+
|
|
2643
3022
|
}, {
|
|
2644
3023
|
key: "removeGraphic",
|
|
2645
3024
|
value: function removeGraphic(id, type) {
|
|
2646
3025
|
var t = this;
|
|
2647
3026
|
var graphic = t.GM.getGraphic(id);
|
|
2648
|
-
var gp = t.GM.getGraphicParam(id);
|
|
2649
|
-
|
|
3027
|
+
var gp = t.GM.getGraphicParam(id); //刪除label
|
|
3028
|
+
|
|
2650
3029
|
if (t.Label[id]) {
|
|
2651
3030
|
t.Label[id].html.remove();
|
|
2652
3031
|
delete t.Label[id];
|
|
2653
3032
|
}
|
|
3033
|
+
|
|
2654
3034
|
if (!!graphic) {
|
|
2655
3035
|
//清除聚合点 避免异常
|
|
2656
3036
|
// t._cluster.removeMarker(this.GM.getGraphic(id));
|
|
2657
3037
|
//清除地图中图元
|
|
2658
3038
|
// const layers = t.state.gis.getLayers().getArray();
|
|
2659
3039
|
// const layer = layers.filter(item => item.getProperties().name == type)[0];
|
|
2660
|
-
gp.source.removeFeature(graphic);
|
|
2661
|
-
// layer && layer.getSource().removeFeature(graphic);
|
|
3040
|
+
gp.source.removeFeature(graphic); // layer && layer.getSource().removeFeature(graphic);
|
|
2662
3041
|
//清除对应id的图元数据缓存
|
|
3042
|
+
|
|
2663
3043
|
t.GM.removeGraphic(id);
|
|
2664
3044
|
t.GM.removeGraphicParam(id);
|
|
3045
|
+
|
|
2665
3046
|
if (t.state.gis.getOverlayById(id)) {
|
|
2666
3047
|
t.state.gis.removeOverlay(t.state.gis.getOverlayById(id));
|
|
2667
3048
|
}
|
|
2668
3049
|
} else {
|
|
2669
3050
|
return false;
|
|
2670
3051
|
}
|
|
3052
|
+
|
|
2671
3053
|
for (var i = 0; i < t.movePoints.length; i++) {
|
|
2672
3054
|
if (t.movePoints[i].id == id) {
|
|
2673
3055
|
t.movePoints.splice(i, 1);
|
|
2674
3056
|
continue;
|
|
2675
3057
|
}
|
|
2676
3058
|
}
|
|
3059
|
+
|
|
2677
3060
|
var ids = [];
|
|
3061
|
+
|
|
2678
3062
|
switch (type) {
|
|
2679
3063
|
case 'point':
|
|
2680
3064
|
ids = t.state.pointIds;
|
|
2681
3065
|
break;
|
|
3066
|
+
|
|
2682
3067
|
case 'line':
|
|
2683
3068
|
ids = t.state.lineIds;
|
|
2684
3069
|
break;
|
|
3070
|
+
|
|
2685
3071
|
case 'polygon':
|
|
2686
3072
|
ids = t.state.polygonIds;
|
|
2687
3073
|
break;
|
|
3074
|
+
|
|
2688
3075
|
case 'circle':
|
|
2689
3076
|
ids = t.state.circleIds;
|
|
2690
3077
|
break;
|
|
3078
|
+
|
|
2691
3079
|
case 'draw':
|
|
2692
3080
|
if (t.state.drawIds.point.indexOf(id) > -1) {
|
|
2693
3081
|
t.state.drawIds.point.splice(t.state.drawIds.point.indexOf(id), 1);
|
|
2694
3082
|
}
|
|
3083
|
+
|
|
2695
3084
|
if (t.state.drawIds.polyline.indexOf(id) > -1) {
|
|
2696
3085
|
t.state.drawIds.polyline.splice(t.state.drawIds.polyline.indexOf(id), 1);
|
|
2697
3086
|
}
|
|
3087
|
+
|
|
2698
3088
|
if (t.state.drawIds.polygon.indexOf(id) > -1) {
|
|
2699
3089
|
t.state.drawIds.polygon.splice(t.state.drawIds.polygon.indexOf(id), 1);
|
|
2700
3090
|
}
|
|
3091
|
+
|
|
2701
3092
|
if (t.state.drawIds.circle.indexOf(id) > -1) {
|
|
2702
3093
|
t.state.drawIds.circle.splice(t.state.drawIds.circle.indexOf(id), 1);
|
|
2703
3094
|
}
|
|
3095
|
+
|
|
2704
3096
|
if (t.state.drawIds.rectangle.indexOf(id) > -1) {
|
|
2705
3097
|
t.state.drawIds.rectangle.splice(t.state.drawIds.rectangle.indexOf(id), 1);
|
|
2706
3098
|
}
|
|
3099
|
+
|
|
2707
3100
|
break;
|
|
3101
|
+
|
|
2708
3102
|
default:
|
|
2709
3103
|
if (t.state.pointIds.indexOf(id) > -1) {
|
|
2710
3104
|
t.state.pointIds.splice(t.state.pointIds.indexOf(id), 1);
|
|
2711
3105
|
}
|
|
3106
|
+
|
|
2712
3107
|
if (t.state.lineIds.indexOf(id) > -1) {
|
|
2713
3108
|
t.state.lineIds.splice(t.state.lineIds.indexOf(id), 1);
|
|
2714
3109
|
}
|
|
3110
|
+
|
|
2715
3111
|
if (t.state.polygonIds.indexOf(id) > -1) {
|
|
2716
3112
|
t.state.polygonIds.splice(t.state.polygonIds.indexOf(id), 1);
|
|
2717
3113
|
}
|
|
3114
|
+
|
|
2718
3115
|
if (t.state.circleIds.indexOf(id) > -1) {
|
|
2719
3116
|
t.state.circleIds.splice(t.state.circleIds.indexOf(id), 1);
|
|
2720
3117
|
}
|
|
3118
|
+
|
|
2721
3119
|
break;
|
|
2722
3120
|
}
|
|
3121
|
+
|
|
2723
3122
|
if (id == t.state.editId) {
|
|
2724
3123
|
t.state.editId = '';
|
|
2725
3124
|
}
|
|
3125
|
+
|
|
2726
3126
|
if (ids.indexOf(id) != -1) {
|
|
2727
3127
|
ids.splice(ids.indexOf(id), 1);
|
|
2728
3128
|
}
|
|
2729
|
-
}
|
|
2730
|
-
|
|
3129
|
+
} //清空地图
|
|
3130
|
+
|
|
2731
3131
|
}, {
|
|
2732
3132
|
key: "clearAll",
|
|
2733
3133
|
value: function clearAll() {
|
|
2734
3134
|
var t = this;
|
|
2735
3135
|
var gis = t.state.gis;
|
|
2736
|
-
var layers = gis.getLayers();
|
|
2737
|
-
|
|
3136
|
+
var layers = gis.getLayers(); //清空热力图
|
|
3137
|
+
|
|
2738
3138
|
if (t.heatmap) {
|
|
2739
3139
|
var hMap = layers.filter(function (item) {
|
|
2740
3140
|
return item.name == 'heatMap';
|
|
@@ -2742,6 +3142,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2742
3142
|
hMap.getSource().clear();
|
|
2743
3143
|
gis.removeLayer(layer);
|
|
2744
3144
|
}
|
|
3145
|
+
|
|
2745
3146
|
t.heatmap = null;
|
|
2746
3147
|
t.movePoints = [];
|
|
2747
3148
|
t.state.pointIds = [];
|
|
@@ -2751,6 +3152,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2751
3152
|
});
|
|
2752
3153
|
t.clearAllPointCollection();
|
|
2753
3154
|
t.closeDraw();
|
|
3155
|
+
|
|
2754
3156
|
if (t.clusterInfo.clusterHulls || t.clusterInfo.clusters || t.clusterInfo.clusterCircles) {
|
|
2755
3157
|
t.clusterHulls.getSource().clear();
|
|
2756
3158
|
t.clusterInfo.clusterSource = null;
|
|
@@ -2760,69 +3162,82 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2760
3162
|
t.clusterInfo.clusterHulls = null;
|
|
2761
3163
|
t.clusterInfo.clusters = null;
|
|
2762
3164
|
t.clusterInfo.clusterCircles = null;
|
|
2763
|
-
}
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
//循环所有id删除
|
|
3165
|
+
} //清空缓存数据
|
|
3166
|
+
|
|
3167
|
+
|
|
3168
|
+
t.GM.clearAll(); //循环所有id删除
|
|
3169
|
+
|
|
2767
3170
|
var _t$state = t.state,
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
3171
|
+
pointIds = _t$state.pointIds,
|
|
3172
|
+
lineIds = _t$state.lineIds,
|
|
3173
|
+
polygonIds = _t$state.polygonIds,
|
|
3174
|
+
circleIds = _t$state.circleIds,
|
|
3175
|
+
drawIds = _t$state.drawIds; //拷贝数组,避免原数组操作,影响循环
|
|
3176
|
+
|
|
2774
3177
|
var ps = _toConsumableArray(pointIds),
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
3178
|
+
ls = _toConsumableArray(lineIds),
|
|
3179
|
+
pgs = _toConsumableArray(polygonIds),
|
|
3180
|
+
cs = _toConsumableArray(circleIds); // 删除点
|
|
3181
|
+
|
|
3182
|
+
|
|
2779
3183
|
for (var i = 0; i < ps.length; i++) {
|
|
2780
3184
|
t.removeGraphic(ps[i], 'point');
|
|
2781
|
-
}
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
// 删除面
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
3185
|
+
} // 删除线
|
|
3186
|
+
|
|
3187
|
+
|
|
3188
|
+
for (var _i2 = 0; _i2 < ls.length; _i2++) {
|
|
3189
|
+
t.removeGraphic(ls[_i2], 'line');
|
|
3190
|
+
} // 删除面
|
|
3191
|
+
|
|
3192
|
+
|
|
3193
|
+
for (var _i3 = 0; _i3 < pgs.length; _i3++) {
|
|
3194
|
+
t.removeGraphic(pgs[_i3], 'polygon');
|
|
3195
|
+
} // 删除圆
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
for (var _i4 = 0; _i4 < cs.length; _i4++) {
|
|
3199
|
+
t.removeGraphic(cs[_i4], 'circle');
|
|
3200
|
+
} //删除绘制的点
|
|
3201
|
+
|
|
3202
|
+
|
|
2795
3203
|
var point = drawIds.point,
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
3204
|
+
polyline = drawIds.polyline,
|
|
3205
|
+
polygon = drawIds.polygon,
|
|
3206
|
+
circle = drawIds.circle,
|
|
3207
|
+
rectangle = drawIds.rectangle;
|
|
3208
|
+
|
|
3209
|
+
for (var i = 0; i < point.length; i++) {
|
|
3210
|
+
t.removeGraphic(point[i]);
|
|
2802
3211
|
}
|
|
3212
|
+
|
|
2803
3213
|
for (var _i5 = 0; _i5 < polyline.length; _i5++) {
|
|
2804
3214
|
t.removeGraphic(polyline[_i5]);
|
|
2805
3215
|
}
|
|
3216
|
+
|
|
2806
3217
|
for (var _i6 = 0; _i6 < polygon.length; _i6++) {
|
|
2807
3218
|
t.removeGraphic(polygon[_i6]);
|
|
2808
3219
|
}
|
|
3220
|
+
|
|
2809
3221
|
for (var _i7 = 0; _i7 < circle.length; _i7++) {
|
|
2810
3222
|
t.removeGraphic(circle[_i7]);
|
|
2811
3223
|
}
|
|
3224
|
+
|
|
2812
3225
|
for (var _i8 = 0; _i8 < rectangle.length; _i8++) {
|
|
2813
3226
|
t.removeGraphic(rectangle[_i8]);
|
|
2814
3227
|
}
|
|
2815
|
-
}
|
|
2816
|
-
|
|
3228
|
+
} //展示比例尺
|
|
3229
|
+
|
|
2817
3230
|
}, {
|
|
2818
3231
|
key: "showControl",
|
|
2819
3232
|
value: function showControl(props) {
|
|
2820
3233
|
var t = this;
|
|
2821
3234
|
var gis = t.state.gis;
|
|
2822
3235
|
var config = props.showControl;
|
|
3236
|
+
|
|
2823
3237
|
if (t.scaleControl) {
|
|
2824
3238
|
gis.removeControl(t.scaleControl);
|
|
2825
3239
|
}
|
|
3240
|
+
|
|
2826
3241
|
t.scaleControl = new ol.control.ScaleLine({
|
|
2827
3242
|
units: 'metric',
|
|
2828
3243
|
//设置度量单位
|
|
@@ -2860,61 +3275,65 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2860
3275
|
});
|
|
2861
3276
|
}
|
|
2862
3277
|
}, 20);
|
|
2863
|
-
}
|
|
2864
|
-
|
|
3278
|
+
} //设置区域限制
|
|
3279
|
+
|
|
2865
3280
|
}, {
|
|
2866
3281
|
key: "setAreaRestriction",
|
|
2867
3282
|
value: function setAreaRestriction(areaRestriction) {
|
|
2868
3283
|
var t = this;
|
|
3284
|
+
|
|
2869
3285
|
var _t$dealData6 = t.dealData(areaRestriction),
|
|
2870
|
-
|
|
3286
|
+
_et = _t$dealData6._extent;
|
|
3287
|
+
|
|
2871
3288
|
t.areaRestriction = t.state.gis.getView().setProperties({
|
|
2872
3289
|
extent: [_et.xmax, _et.ymax, _et.xmin, _et.ymin]
|
|
2873
3290
|
}, false);
|
|
2874
|
-
}
|
|
2875
|
-
|
|
3291
|
+
} //关闭区域限制
|
|
3292
|
+
|
|
2876
3293
|
}, {
|
|
2877
3294
|
key: "clearAreaRestriction",
|
|
2878
3295
|
value: function clearAreaRestriction() {
|
|
2879
3296
|
var t = this;
|
|
2880
3297
|
t.areaRestriction = null;
|
|
2881
|
-
}
|
|
2882
|
-
|
|
3298
|
+
} //区域限制逻辑
|
|
3299
|
+
|
|
2883
3300
|
}, {
|
|
2884
3301
|
key: "dealAreaRestriction",
|
|
2885
3302
|
value: function dealAreaRestriction(e) {
|
|
2886
|
-
var t = this;
|
|
2887
|
-
|
|
3303
|
+
var t = this; //如果在区域内,不处理
|
|
3304
|
+
|
|
2888
3305
|
if (t.areaRestriction.contains(e.extent.getCenter())) {
|
|
2889
3306
|
return;
|
|
2890
|
-
}
|
|
2891
|
-
// if(t.containsExtent(t.areaRestriction,e.extent)){
|
|
3307
|
+
} // if(t.containsExtent(t.areaRestriction,e.extent)){
|
|
2892
3308
|
// return;
|
|
2893
3309
|
// }
|
|
3310
|
+
|
|
3311
|
+
|
|
2894
3312
|
var _t$areaRestriction = t.areaRestriction,
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
3313
|
+
xmin1 = _t$areaRestriction.xmin,
|
|
3314
|
+
xmax1 = _t$areaRestriction.xmax,
|
|
3315
|
+
ymin1 = _t$areaRestriction.ymin,
|
|
3316
|
+
ymax1 = _t$areaRestriction.ymax;
|
|
2899
3317
|
var _e$extent = e.extent,
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
3318
|
+
xmin2 = _e$extent.xmin,
|
|
3319
|
+
xmax2 = _e$extent.xmax,
|
|
3320
|
+
ymin2 = _e$extent.ymin,
|
|
3321
|
+
ymax2 = _e$extent.ymax;
|
|
2904
3322
|
var x = e.extent.getCenter().x,
|
|
2905
|
-
|
|
3323
|
+
y = e.extent.getCenter().y;
|
|
2906
3324
|
if (x < xmin1) x = xmin1 + 0.1;
|
|
2907
3325
|
if (x > xmax1) x = xmax1 - 0.1;
|
|
2908
3326
|
if (y < ymin1) y = ymin1 + 0.1;
|
|
2909
3327
|
if (y > ymax1) y = ymax1 - 0.1;
|
|
2910
3328
|
t.state.gis.getView().setCenter([x, y]);
|
|
2911
|
-
}
|
|
2912
|
-
|
|
3329
|
+
} //聚合地图图元(arg为空时聚合全部点)
|
|
3330
|
+
|
|
2913
3331
|
}, {
|
|
2914
3332
|
key: "cluster",
|
|
2915
3333
|
value: function cluster(arg) {
|
|
2916
3334
|
var t = this;
|
|
2917
3335
|
var ary = [];
|
|
3336
|
+
|
|
2918
3337
|
if (!arg) {
|
|
2919
3338
|
var pointIds = t.state.pointIds;
|
|
2920
3339
|
ary = pointIds;
|
|
@@ -2925,6 +3344,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2925
3344
|
ary = arg.split(',');
|
|
2926
3345
|
}
|
|
2927
3346
|
}
|
|
3347
|
+
|
|
2928
3348
|
t.pointLayers.map(function (item) {
|
|
2929
3349
|
t.state.gis.removeLayer(item.layer);
|
|
2930
3350
|
t.pointLayers = [];
|
|
@@ -2941,6 +3361,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2941
3361
|
minDistance: 0,
|
|
2942
3362
|
source: source
|
|
2943
3363
|
});
|
|
3364
|
+
|
|
2944
3365
|
if (t.clusterInfo.clusterHulls) {
|
|
2945
3366
|
t.clusterInfo.clusterHulls.setSource(t.clusterInfo.clusterSource);
|
|
2946
3367
|
} else {
|
|
@@ -2950,6 +3371,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2950
3371
|
});
|
|
2951
3372
|
t.state.gis.addLayer(t.clusterInfo.clusterHulls);
|
|
2952
3373
|
}
|
|
3374
|
+
|
|
2953
3375
|
if (t.clusterInfo.clusters) {
|
|
2954
3376
|
t.clusterInfo.clusters.setSource(t.clusterInfo.clusterSource);
|
|
2955
3377
|
} else {
|
|
@@ -2959,6 +3381,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2959
3381
|
});
|
|
2960
3382
|
t.state.gis.addLayer(t.clusterInfo.clusters);
|
|
2961
3383
|
}
|
|
3384
|
+
|
|
2962
3385
|
if (t.clusterInfo.clusterCircles) {
|
|
2963
3386
|
t.clusterInfo.clusterCircles.setSource(t.clusterInfo.clusterSource);
|
|
2964
3387
|
} else {
|
|
@@ -2968,6 +3391,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2968
3391
|
});
|
|
2969
3392
|
t.state.gis.addLayer(t.clusterInfo.clusterCircles);
|
|
2970
3393
|
}
|
|
3394
|
+
|
|
2971
3395
|
function clusterMemberStyle(clusterMember) {
|
|
2972
3396
|
var style = clusterMember.getStyle();
|
|
2973
3397
|
var image = style && style.getImage ? style.getImage() : null;
|
|
@@ -2977,10 +3401,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2977
3401
|
text: text
|
|
2978
3402
|
});
|
|
2979
3403
|
}
|
|
3404
|
+
|
|
2980
3405
|
function clusterCircleStyle(cluster, resolution) {
|
|
2981
3406
|
if (cluster !== t.clusterInfo.clickFeature || resolution !== t.clusterInfo.clickResolution) {
|
|
2982
3407
|
return;
|
|
2983
3408
|
}
|
|
3409
|
+
|
|
2984
3410
|
var clusterMembers = cluster.get('features');
|
|
2985
3411
|
var centerCoordinates = cluster.getGeometry().getCoordinates();
|
|
2986
3412
|
return generatePointsCircle(clusterMembers.length, cluster.getGeometry().getCoordinates(), resolution).reduce(function (styles, coordinates, i) {
|
|
@@ -2999,24 +3425,30 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2999
3425
|
return styles;
|
|
3000
3426
|
}, []);
|
|
3001
3427
|
}
|
|
3428
|
+
|
|
3002
3429
|
function generatePointsCircle(count, clusterCenter, resolution) {
|
|
3003
3430
|
var circumference = 1 * 28 * (2 + count);
|
|
3004
3431
|
var legLength = circumference / (Math.PI * 2); //radius from circumference
|
|
3432
|
+
|
|
3005
3433
|
var angleStep = Math.PI * 2 / count;
|
|
3006
3434
|
var res = [];
|
|
3007
3435
|
var angle;
|
|
3008
3436
|
legLength = Math.max(legLength, 35) * resolution; // Minimum distance to get outside the cluster icon.
|
|
3437
|
+
|
|
3009
3438
|
for (var i = 0; i < count; ++i) {
|
|
3010
3439
|
// Clockwise, like spiral.
|
|
3011
3440
|
angle = Math.PI / 2 + i * angleStep;
|
|
3012
3441
|
res.push([clusterCenter[0] + legLength * Math.cos(angle), clusterCenter[1] + legLength * Math.sin(angle)]);
|
|
3013
3442
|
}
|
|
3443
|
+
|
|
3014
3444
|
return res;
|
|
3015
3445
|
}
|
|
3446
|
+
|
|
3016
3447
|
function clusterHullStyle(cluster) {
|
|
3017
3448
|
if (cluster !== t.clusterInfo.hoverFeature) {
|
|
3018
3449
|
return;
|
|
3019
3450
|
}
|
|
3451
|
+
|
|
3020
3452
|
var originalFeatures = cluster.get('features');
|
|
3021
3453
|
var points = originalFeatures.map(function (feature) {
|
|
3022
3454
|
return feature.getGeometry().getCoordinates();
|
|
@@ -3032,8 +3464,10 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3032
3464
|
})
|
|
3033
3465
|
});
|
|
3034
3466
|
}
|
|
3467
|
+
|
|
3035
3468
|
function clusterStyle(feature) {
|
|
3036
3469
|
var size = feature.get('features').length;
|
|
3470
|
+
|
|
3037
3471
|
if (size > 2) {
|
|
3038
3472
|
return [new ol.style.Style({
|
|
3039
3473
|
image: new ol.style.Circle({
|
|
@@ -3072,22 +3506,27 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3072
3506
|
value: function clearCluster(arg) {
|
|
3073
3507
|
var t = this;
|
|
3074
3508
|
var ids = arg && (arg === null || arg === void 0 ? void 0 : arg.length) > 0 ? arg : t.state.pointIds;
|
|
3509
|
+
|
|
3075
3510
|
if (t.clusterInfo.clusterHulls) {
|
|
3076
3511
|
t.state.gis.removeLayer(t.clusterInfo.clusterHulls);
|
|
3077
3512
|
t.clusterInfo.clusterHulls = null;
|
|
3078
3513
|
}
|
|
3514
|
+
|
|
3079
3515
|
if (t.clusterInfo.clusters) {
|
|
3080
3516
|
t.state.gis.removeLayer(t.clusterInfo.clusters);
|
|
3081
3517
|
t.clusterInfo.clusters = null;
|
|
3082
3518
|
}
|
|
3519
|
+
|
|
3083
3520
|
if (t.clusterInfo.clusterCircles) {
|
|
3084
3521
|
t.state.gis.removeLayer(t.clusterInfo.clusterCircles);
|
|
3085
3522
|
t.clusterInfo.clusterCircles = null;
|
|
3086
3523
|
}
|
|
3524
|
+
|
|
3087
3525
|
ids.map(function (id) {
|
|
3088
3526
|
if (t.GM.getGraphic(id)) {
|
|
3089
3527
|
t.GM.removeGraphic(id);
|
|
3090
3528
|
}
|
|
3529
|
+
|
|
3091
3530
|
t.state.pointIds.splice(t.state.pointIds.indexOf(id), 1);
|
|
3092
3531
|
});
|
|
3093
3532
|
t.addPoint(t.props.mapPoints);
|
|
@@ -3095,20 +3534,21 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3095
3534
|
}
|
|
3096
3535
|
/*公共方法*/
|
|
3097
3536
|
//判断extent1是否在extent2内部
|
|
3537
|
+
|
|
3098
3538
|
}, {
|
|
3099
3539
|
key: "containsExtent",
|
|
3100
3540
|
value: function containsExtent(e1, e2) {
|
|
3101
3541
|
var xmin1 = e1.xmin,
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3542
|
+
xmax1 = e1.xmax,
|
|
3543
|
+
ymin1 = e1.ymin,
|
|
3544
|
+
ymax1 = e1.ymax;
|
|
3105
3545
|
var xmin2 = e2.xmin,
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3546
|
+
xmax2 = e2.xmax,
|
|
3547
|
+
ymin2 = e2.ymin,
|
|
3548
|
+
ymax2 = e2.ymax;
|
|
3109
3549
|
return xmin2 > xmin1 && xmax2 < xmax1 && ymin2 > ymin1 && ymax2 < ymax1;
|
|
3110
|
-
}
|
|
3111
|
-
|
|
3550
|
+
} //将图元z-index设置成最高
|
|
3551
|
+
|
|
3112
3552
|
}, {
|
|
3113
3553
|
key: "czIndex",
|
|
3114
3554
|
value: function czIndex(id) {
|
|
@@ -3119,8 +3559,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3119
3559
|
key: "equalsPoint",
|
|
3120
3560
|
value: function equalsPoint(a, b) {
|
|
3121
3561
|
return a.x == b.x && a.y == b.y;
|
|
3122
|
-
}
|
|
3123
|
-
|
|
3562
|
+
} //计算2点间距离 单位m 精确到2位小数
|
|
3563
|
+
|
|
3124
3564
|
}, {
|
|
3125
3565
|
key: "calculatePointsDistance",
|
|
3126
3566
|
value: function calculatePointsDistance(fp, ep) {
|
|
@@ -3128,16 +3568,18 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3128
3568
|
var distance = ol.sphere.getDistance(fp, ep);
|
|
3129
3569
|
console.log(distance);
|
|
3130
3570
|
return Math.round(distance);
|
|
3131
|
-
}
|
|
3132
|
-
|
|
3571
|
+
} //计算多个点的距离(常用于线计算)
|
|
3572
|
+
|
|
3133
3573
|
}, {
|
|
3134
3574
|
key: "calculateDistance",
|
|
3135
3575
|
value: function calculateDistance(ps) {
|
|
3136
3576
|
var t = this,
|
|
3137
|
-
|
|
3577
|
+
totalDistance = 0;
|
|
3578
|
+
|
|
3138
3579
|
if (ps.length < 0) {
|
|
3139
3580
|
return 0;
|
|
3140
3581
|
}
|
|
3582
|
+
|
|
3141
3583
|
for (var i = 0; i < ps.length; i++) {
|
|
3142
3584
|
if (i < ps.length - 1) {
|
|
3143
3585
|
var distance = t.calculatePointsDistance(ps[i], ps[i + 1]);
|
|
@@ -3145,37 +3587,43 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3145
3587
|
totalDistance += distance;
|
|
3146
3588
|
}
|
|
3147
3589
|
}
|
|
3590
|
+
|
|
3148
3591
|
console.log(totalDistance);
|
|
3149
3592
|
return Math.round(totalDistance * 100) / 100;
|
|
3150
|
-
}
|
|
3151
|
-
|
|
3593
|
+
} //处理线和面的 经纬度数据
|
|
3594
|
+
|
|
3152
3595
|
}, {
|
|
3153
3596
|
key: "dealData",
|
|
3154
3597
|
value: function dealData(paths) {
|
|
3155
3598
|
//区别点和圆的经纬度数据处理
|
|
3156
3599
|
var lnglatAry = [],
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3600
|
+
_extent = {
|
|
3601
|
+
xmax: 0,
|
|
3602
|
+
xmin: 0,
|
|
3603
|
+
ymax: 0,
|
|
3604
|
+
ymin: 0
|
|
3605
|
+
},
|
|
3606
|
+
path = [];
|
|
3164
3607
|
path = paths.map(function (item, index) {
|
|
3165
3608
|
var lng = item[0],
|
|
3166
|
-
|
|
3609
|
+
lat = item[1];
|
|
3610
|
+
|
|
3167
3611
|
if (lng > _extent.xmax) {
|
|
3168
3612
|
_extent.xmax = lng;
|
|
3169
3613
|
}
|
|
3614
|
+
|
|
3170
3615
|
if (lng < _extent.xmin || _extent.xmin == 0) {
|
|
3171
3616
|
_extent.xmin = lng;
|
|
3172
3617
|
}
|
|
3618
|
+
|
|
3173
3619
|
if (lat > _extent.ymax) {
|
|
3174
3620
|
_extent.ymax = lat;
|
|
3175
3621
|
}
|
|
3622
|
+
|
|
3176
3623
|
if (lat < _extent.ymin || _extent.ymin == 0) {
|
|
3177
3624
|
_extent.ymin = lat;
|
|
3178
3625
|
}
|
|
3626
|
+
|
|
3179
3627
|
lnglatAry.push({
|
|
3180
3628
|
lngX: lng,
|
|
3181
3629
|
latX: lat
|
|
@@ -3187,50 +3635,55 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3187
3635
|
_extent: _extent,
|
|
3188
3636
|
path: path
|
|
3189
3637
|
};
|
|
3190
|
-
}
|
|
3191
|
-
|
|
3638
|
+
} //处理点位图元的添加 和 更新
|
|
3639
|
+
|
|
3192
3640
|
}, {
|
|
3193
3641
|
key: "dealLabelGraphics",
|
|
3194
3642
|
value: function dealLabelGraphics(id, label) {
|
|
3195
3643
|
var t = this;
|
|
3644
|
+
|
|
3196
3645
|
if (label) {
|
|
3197
|
-
var position = (t.GM.getGraphic(id) || {}).geometry || label.position;
|
|
3198
|
-
|
|
3646
|
+
var position = (t.GM.getGraphic(id) || {}).geometry || label.position; //经纬度转top和left
|
|
3647
|
+
|
|
3199
3648
|
var tl = t.state.gis.toScreen(position),
|
|
3200
|
-
|
|
3201
|
-
|
|
3649
|
+
lbl = _objectSpread({}, label); //渲染優化
|
|
3650
|
+
|
|
3651
|
+
|
|
3202
3652
|
if (!(tl.y < -50 || tl.x < -50 || tl.y > t.state.gis.height || tl.x > t.state.gis.width)) {
|
|
3203
3653
|
//设置label的位置(通过定位来实现)
|
|
3204
3654
|
label.html.css({
|
|
3205
3655
|
position: 'absolute',
|
|
3206
3656
|
top: tl.y + (label.offset.y || 0) - t.labelLayer.y,
|
|
3207
3657
|
left: tl.x + (label.offset.x || 0) - t.labelLayer.x
|
|
3208
|
-
});
|
|
3209
|
-
|
|
3658
|
+
}); //添加点位到(地图)
|
|
3659
|
+
|
|
3210
3660
|
$("#".concat(t.htmlPointsId)).append(label.html);
|
|
3211
3661
|
lbl.add = true;
|
|
3212
3662
|
} else {
|
|
3213
3663
|
lbl.add = false;
|
|
3214
|
-
}
|
|
3215
|
-
|
|
3664
|
+
} //记录下label的dom对象,用于后期修改和删除(基本是删除)
|
|
3665
|
+
|
|
3666
|
+
|
|
3216
3667
|
t.Label[id] = lbl;
|
|
3217
3668
|
}
|
|
3218
|
-
}
|
|
3219
|
-
|
|
3669
|
+
} //点的跳动动画
|
|
3670
|
+
|
|
3220
3671
|
}, {
|
|
3221
3672
|
key: "pointAnimation",
|
|
3222
3673
|
value: function pointAnimation(id, marker) {
|
|
3223
|
-
var t = this;
|
|
3224
|
-
|
|
3674
|
+
var t = this; //null时关闭跳动
|
|
3675
|
+
|
|
3225
3676
|
if (!!marker) {
|
|
3226
3677
|
if (t.animTimer[id]) {
|
|
3227
3678
|
clearInterval(t.animTimer[id]);
|
|
3228
3679
|
}
|
|
3680
|
+
|
|
3229
3681
|
t.animTimer[id] = setInterval(function () {
|
|
3230
3682
|
//点被隐藏时,没有执行,定时不关
|
|
3231
3683
|
if (marker.symbol) {
|
|
3232
|
-
var shape = _objectSpread({}, marker.symbol);
|
|
3233
|
-
|
|
3684
|
+
var shape = _objectSpread({}, marker.symbol); //初始数据 点位有变动,重新刷新数据
|
|
3685
|
+
|
|
3686
|
+
|
|
3234
3687
|
if (!t.animCount[id] || shape.yoffset != t.animCount[id].now) {
|
|
3235
3688
|
t.animCount[id] = {
|
|
3236
3689
|
start: shape.yoffset,
|
|
@@ -3238,12 +3691,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3238
3691
|
notation: -1
|
|
3239
3692
|
};
|
|
3240
3693
|
}
|
|
3694
|
+
|
|
3241
3695
|
if (t.animCount[id].now - t.animCount[id].start == 20) {
|
|
3242
3696
|
t.animCount[id].notation = -1;
|
|
3243
3697
|
}
|
|
3698
|
+
|
|
3244
3699
|
if (t.animCount[id].now - t.animCount[id].start == 0) {
|
|
3245
3700
|
t.animCount[id].notation = 1;
|
|
3246
3701
|
}
|
|
3702
|
+
|
|
3247
3703
|
shape.yoffset = t.animCount[id].now = t.animCount[id].now + t.animCount[id].notation * 2;
|
|
3248
3704
|
marker.symbol.setOffset(shape.xoffset, shape.yoffset);
|
|
3249
3705
|
t.state.gis.graphics.refresh();
|
|
@@ -3257,93 +3713,107 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3257
3713
|
key: "moveAnimation",
|
|
3258
3714
|
value: function moveAnimation() {
|
|
3259
3715
|
var t = this;
|
|
3716
|
+
|
|
3260
3717
|
if (t.moveToTimer) {
|
|
3261
3718
|
clearInterval(t.moveToTimer);
|
|
3262
3719
|
}
|
|
3720
|
+
|
|
3263
3721
|
t.moveToTimer = setInterval(function () {
|
|
3264
3722
|
for (var i = 0; i < t.movePoints.length; i++) {
|
|
3265
3723
|
t.movePoints[i].waitTime += 10;
|
|
3266
3724
|
t.movePoints[i].deleteTime -= 10;
|
|
3267
3725
|
}
|
|
3726
|
+
|
|
3268
3727
|
t.movePoints.sort(function (x, y) {
|
|
3269
3728
|
return y.waitTime - x.waitTime;
|
|
3270
3729
|
});
|
|
3271
3730
|
var nowMovePoints = t.movePoints.slice(0, 10),
|
|
3272
|
-
|
|
3731
|
+
deleteIndex = [];
|
|
3732
|
+
|
|
3273
3733
|
for (var _i9 = 0; _i9 < nowMovePoints.length; _i9++) {
|
|
3274
3734
|
var _nowMovePoints$_i = nowMovePoints[_i9],
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3735
|
+
id = _nowMovePoints$_i.id,
|
|
3736
|
+
rx = _nowMovePoints$_i.rx,
|
|
3737
|
+
ry = _nowMovePoints$_i.ry,
|
|
3738
|
+
waitTime = _nowMovePoints$_i.waitTime,
|
|
3739
|
+
deleteTime = _nowMovePoints$_i.deleteTime,
|
|
3740
|
+
ddeg = _nowMovePoints$_i.ddeg;
|
|
3281
3741
|
var gc = t.GM.getGraphic(id);
|
|
3742
|
+
|
|
3282
3743
|
if (!gc || !gc._graphicsLayer) {
|
|
3283
3744
|
clearInterval(t.moveToTimer);
|
|
3284
3745
|
} else {
|
|
3285
3746
|
var gg = gc.getGeometry();
|
|
3286
3747
|
var tx = gg[0] + rx,
|
|
3287
|
-
|
|
3748
|
+
ty = gg[1] + ry;
|
|
3288
3749
|
gc.setGeometry([tx, ty]);
|
|
3289
3750
|
t.movePoints[_i9].waitTime = 0;
|
|
3751
|
+
|
|
3290
3752
|
if (deleteTime <= 0) {
|
|
3291
3753
|
deleteIndex.push(_i9);
|
|
3292
3754
|
}
|
|
3293
3755
|
}
|
|
3294
3756
|
}
|
|
3757
|
+
|
|
3295
3758
|
deleteIndex.sort(function (a, b) {
|
|
3296
3759
|
return b - a;
|
|
3297
3760
|
});
|
|
3761
|
+
|
|
3298
3762
|
for (var _i10 = 0; _i10 < deleteIndex.length; _i10++) {
|
|
3299
3763
|
t.movePoints.splice(deleteIndex[_i10], 1);
|
|
3300
3764
|
}
|
|
3765
|
+
|
|
3301
3766
|
if (nowMovePoints.length == 0) {
|
|
3302
3767
|
clearInterval(t.moveToTimer);
|
|
3303
3768
|
}
|
|
3304
3769
|
}, 10);
|
|
3305
|
-
}
|
|
3306
|
-
|
|
3770
|
+
} //点位移动动画效果
|
|
3771
|
+
|
|
3307
3772
|
}, {
|
|
3308
3773
|
key: "moveTo",
|
|
3309
3774
|
value: function moveTo(id, lnglat, delay, autoRotation, urlright, urlleft) {
|
|
3310
3775
|
delay = delay || 3;
|
|
3311
3776
|
var t = this,
|
|
3312
|
-
|
|
3777
|
+
timer = 10;
|
|
3313
3778
|
delay = eval(delay) * 1000;
|
|
3314
3779
|
var count = delay / timer,
|
|
3315
|
-
|
|
3780
|
+
gc = this.GM.getGraphic(id);
|
|
3316
3781
|
var s = gc.geometry,
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3782
|
+
e = {
|
|
3783
|
+
x: lnglat[0],
|
|
3784
|
+
y: lnglat[1]
|
|
3785
|
+
};
|
|
3786
|
+
|
|
3321
3787
|
if (t.equalsPoint(s, e)) {
|
|
3322
3788
|
return false;
|
|
3323
3789
|
} else {
|
|
3324
3790
|
var ddeg = 0,
|
|
3325
|
-
|
|
3326
|
-
|
|
3791
|
+
url = null; //计算角度,旋转
|
|
3792
|
+
|
|
3327
3793
|
if (autoRotation) {
|
|
3328
3794
|
//自己实现旋转
|
|
3329
3795
|
ddeg = t.rotateDeg(gc.geometry, lnglat);
|
|
3796
|
+
|
|
3330
3797
|
if (urlleft && ddeg < -90 && ddeg > -270) {
|
|
3331
3798
|
ddeg += 180;
|
|
3332
3799
|
url = urlleft;
|
|
3333
3800
|
} else {
|
|
3334
3801
|
url = urlright;
|
|
3335
3802
|
}
|
|
3803
|
+
|
|
3336
3804
|
gc.setStyle(new ol.style.Style({
|
|
3337
3805
|
image: new ol.style.Icon({
|
|
3338
3806
|
src: url,
|
|
3339
3807
|
rotation: Math.PI / 180 * ddeg
|
|
3340
3808
|
})
|
|
3341
3809
|
}));
|
|
3342
|
-
}
|
|
3343
|
-
|
|
3810
|
+
} //拆分延迟移动定位
|
|
3811
|
+
|
|
3812
|
+
|
|
3344
3813
|
var rx = (e.x - s.x) / count,
|
|
3345
|
-
|
|
3814
|
+
ry = (e.y - s.y) / count;
|
|
3346
3815
|
var isHave = false;
|
|
3816
|
+
|
|
3347
3817
|
for (var i = 0; i < t.movePoints.length; i++) {
|
|
3348
3818
|
if (t.movePoints[i].id == id) {
|
|
3349
3819
|
t.movePoints.splice(i, 1, {
|
|
@@ -3356,6 +3826,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3356
3826
|
isHave = true;
|
|
3357
3827
|
}
|
|
3358
3828
|
}
|
|
3829
|
+
|
|
3359
3830
|
if (!isHave) {
|
|
3360
3831
|
t.movePoints.push({
|
|
3361
3832
|
id: id,
|
|
@@ -3366,30 +3837,34 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3366
3837
|
});
|
|
3367
3838
|
}
|
|
3368
3839
|
}
|
|
3369
|
-
}
|
|
3370
|
-
|
|
3840
|
+
} //点位角度旋转(以指向东(右)为0°)
|
|
3841
|
+
|
|
3371
3842
|
}, {
|
|
3372
3843
|
key: "rotateDeg",
|
|
3373
3844
|
value: function rotateDeg(sp, ep) {
|
|
3374
3845
|
var t = this;
|
|
3375
3846
|
var spLngLat = sp;
|
|
3847
|
+
|
|
3376
3848
|
if (Array.isArray(sp)) {
|
|
3377
3849
|
spLngLat = new ol.geom.Point(sp[0], sp[1]);
|
|
3378
3850
|
}
|
|
3851
|
+
|
|
3379
3852
|
var s = t.state.gis.getPixelFromCoordinate(spLngLat),
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3853
|
+
//获取当前点位的经纬度
|
|
3854
|
+
e = t.state.gis.getPixelFromCoordinate(new ol.geom.Point(ep[0], ep[1])),
|
|
3855
|
+
deg = 0;
|
|
3856
|
+
|
|
3383
3857
|
if (e.x != s.x) {
|
|
3384
3858
|
var tan = (e.y - s.y) / (e.x - s.x),
|
|
3385
|
-
|
|
3386
|
-
deg = atan * 360 / (2 * Math.PI);
|
|
3387
|
-
|
|
3859
|
+
atan = Math.atan(tan);
|
|
3860
|
+
deg = atan * 360 / (2 * Math.PI); //degree correction;
|
|
3861
|
+
|
|
3388
3862
|
if (e.x < s.x) {
|
|
3389
3863
|
deg = -deg + 90 + 90;
|
|
3390
3864
|
} else {
|
|
3391
3865
|
deg = -deg;
|
|
3392
3866
|
}
|
|
3867
|
+
|
|
3393
3868
|
deg = -deg;
|
|
3394
3869
|
} else {
|
|
3395
3870
|
var disy = e.y - s.y;
|
|
@@ -3398,15 +3873,16 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3398
3873
|
if (disy == 0) bias = 0;
|
|
3399
3874
|
deg = -bias * 90;
|
|
3400
3875
|
}
|
|
3876
|
+
|
|
3401
3877
|
return deg;
|
|
3402
|
-
}
|
|
3403
|
-
|
|
3878
|
+
} //对比对象数据是否相等
|
|
3879
|
+
|
|
3404
3880
|
}, {
|
|
3405
3881
|
key: "deepEqual",
|
|
3406
3882
|
value: function deepEqual(a, b) {
|
|
3407
3883
|
return _immutable["default"].is(_immutable["default"].fromJS(a), _immutable["default"].fromJS(b));
|
|
3408
|
-
}
|
|
3409
|
-
|
|
3884
|
+
} //数据解析(分析,新增,更新,删除对应的数据)
|
|
3885
|
+
|
|
3410
3886
|
}, {
|
|
3411
3887
|
key: "dataMatch",
|
|
3412
3888
|
value: function dataMatch(oldData, newData, type) {
|
|
@@ -3437,13 +3913,14 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3437
3913
|
updatedData: updatedData,
|
|
3438
3914
|
replacedData: replacedData
|
|
3439
3915
|
};
|
|
3440
|
-
}
|
|
3441
|
-
|
|
3916
|
+
} //处理需要增加图元的数据(避免意外问题)
|
|
3917
|
+
|
|
3442
3918
|
}, {
|
|
3443
3919
|
key: "dealAdd",
|
|
3444
3920
|
value: function dealAdd(ary, ids) {
|
|
3445
3921
|
var ads = [],
|
|
3446
|
-
|
|
3922
|
+
otherupds = [];
|
|
3923
|
+
|
|
3447
3924
|
for (var i = 0; i < ary.length; i++) {
|
|
3448
3925
|
if (ids.indexOf(ary[i].id) > -1) {
|
|
3449
3926
|
otherupds.push(ary[i]);
|
|
@@ -3451,17 +3928,19 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3451
3928
|
ads.push(ary[i]);
|
|
3452
3929
|
}
|
|
3453
3930
|
}
|
|
3931
|
+
|
|
3454
3932
|
return {
|
|
3455
3933
|
ads: ads,
|
|
3456
3934
|
otherupds: otherupds
|
|
3457
3935
|
};
|
|
3458
|
-
}
|
|
3459
|
-
|
|
3936
|
+
} //处理需要更新图元的数据(避免意外问题)
|
|
3937
|
+
|
|
3460
3938
|
}, {
|
|
3461
3939
|
key: "dealUpdate",
|
|
3462
3940
|
value: function dealUpdate(ary, ids) {
|
|
3463
3941
|
var upds = [],
|
|
3464
|
-
|
|
3942
|
+
otherads = [];
|
|
3943
|
+
|
|
3465
3944
|
for (var i = 0; i < ary.length; i++) {
|
|
3466
3945
|
if (ids.indexOf(ary[i].id) > -1) {
|
|
3467
3946
|
upds.push(ary[i]);
|
|
@@ -3469,6 +3948,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3469
3948
|
otherads.push(ary[i]);
|
|
3470
3949
|
}
|
|
3471
3950
|
}
|
|
3951
|
+
|
|
3472
3952
|
return {
|
|
3473
3953
|
upds: upds,
|
|
3474
3954
|
otherads: otherads
|
|
@@ -3486,8 +3966,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3486
3966
|
height: '100%'
|
|
3487
3967
|
}
|
|
3488
3968
|
});
|
|
3489
|
-
}
|
|
3490
|
-
|
|
3969
|
+
} //初始化
|
|
3970
|
+
|
|
3491
3971
|
}, {
|
|
3492
3972
|
key: "componentDidMount",
|
|
3493
3973
|
value: function componentDidMount() {
|
|
@@ -3495,74 +3975,75 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3495
3975
|
t.loadMapComplete.then(function () {
|
|
3496
3976
|
t.init();
|
|
3497
3977
|
});
|
|
3498
|
-
}
|
|
3499
|
-
|
|
3978
|
+
} //已加载组件,收到新的参数时调用
|
|
3979
|
+
|
|
3500
3980
|
}, {
|
|
3501
3981
|
key: "componentWillReceiveProps",
|
|
3502
3982
|
value: function componentWillReceiveProps(nextProps, prevProps) {
|
|
3503
|
-
var t = this;
|
|
3504
|
-
|
|
3983
|
+
var t = this; //点/线旧数据
|
|
3984
|
+
|
|
3505
3985
|
var _t$state2 = t.state,
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3986
|
+
pointIds = _t$state2.pointIds,
|
|
3987
|
+
lineIds = _t$state2.lineIds,
|
|
3988
|
+
polygonIds = _t$state2.polygonIds,
|
|
3989
|
+
circleIds = _t$state2.circleIds,
|
|
3990
|
+
drawIds = _t$state2.drawIds;
|
|
3511
3991
|
var point = drawIds.point,
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3992
|
+
polyline = drawIds.polyline,
|
|
3993
|
+
polygon = drawIds.polygon,
|
|
3994
|
+
circle = drawIds.circle,
|
|
3995
|
+
rectangle = drawIds.rectangle; //点/线新数据
|
|
3996
|
+
|
|
3517
3997
|
var _nextProps$mapPoints = nextProps.mapPoints,
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3998
|
+
mapPoints = _nextProps$mapPoints === void 0 ? [] : _nextProps$mapPoints,
|
|
3999
|
+
_nextProps$mapLines = nextProps.mapLines,
|
|
4000
|
+
mapLines = _nextProps$mapLines === void 0 ? [] : _nextProps$mapLines,
|
|
4001
|
+
_nextProps$mapPolygon = nextProps.mapPolygons,
|
|
4002
|
+
mapPolygons = _nextProps$mapPolygon === void 0 ? [] : _nextProps$mapPolygon,
|
|
4003
|
+
_nextProps$mapCircles = nextProps.mapCircles,
|
|
4004
|
+
mapCircles = _nextProps$mapCircles === void 0 ? [] : _nextProps$mapCircles,
|
|
4005
|
+
_nextProps$customized = nextProps.customizedBoundary,
|
|
4006
|
+
customizedBoundary = _nextProps$customized === void 0 ? [] : _nextProps$customized,
|
|
4007
|
+
isOpenTrafficInfo = nextProps.isOpenTrafficInfo,
|
|
4008
|
+
boundaryName = nextProps.boundaryName,
|
|
4009
|
+
heatMapData = nextProps.heatMapData,
|
|
4010
|
+
mapVisiblePoints = nextProps.mapVisiblePoints,
|
|
4011
|
+
setVisiblePoints = nextProps.setVisiblePoints,
|
|
4012
|
+
setCenter = nextProps.setCenter,
|
|
4013
|
+
mapCenter = nextProps.mapCenter,
|
|
4014
|
+
setZoomLevel = nextProps.setZoomLevel,
|
|
4015
|
+
mapZoomLevel = nextProps.mapZoomLevel,
|
|
4016
|
+
setCluster = nextProps.setCluster,
|
|
4017
|
+
mapCluster = nextProps.mapCluster,
|
|
4018
|
+
isRangingTool = nextProps.isRangingTool,
|
|
4019
|
+
mapRangingTool = nextProps.mapRangingTool,
|
|
4020
|
+
isRemove = nextProps.isRemove,
|
|
4021
|
+
mapRemove = nextProps.mapRemove,
|
|
4022
|
+
mapDraw = nextProps.mapDraw,
|
|
4023
|
+
isDraw = nextProps.isDraw,
|
|
4024
|
+
isCloseDraw = nextProps.isCloseDraw,
|
|
4025
|
+
editGraphicId = nextProps.editGraphicId,
|
|
4026
|
+
isDoEdit = nextProps.isDoEdit,
|
|
4027
|
+
isEndEdit = nextProps.isEndEdit,
|
|
4028
|
+
mapPointCollection = nextProps.mapPointCollection,
|
|
4029
|
+
isclearAllPointCollection = nextProps.isclearAllPointCollection,
|
|
4030
|
+
isSetAreaRestriction = nextProps.isSetAreaRestriction,
|
|
4031
|
+
areaRestriction = nextProps.areaRestriction,
|
|
4032
|
+
isClearAreaRestriction = nextProps.isClearAreaRestriction,
|
|
4033
|
+
isClearAll = nextProps.isClearAll,
|
|
4034
|
+
olProps = nextProps.olProps; // 等待地图加载
|
|
4035
|
+
|
|
3556
4036
|
if (!t.state.mapCreated) return;
|
|
3557
4037
|
/*点数据处理
|
|
3558
4038
|
pointData[2]相同的点,执行刷新
|
|
3559
4039
|
pointData[1]的数据在idsForGraphicId中不存在的,执行新增
|
|
3560
4040
|
pointData[0]数据中多余的id,执行删除
|
|
3561
4041
|
*/
|
|
4042
|
+
|
|
3562
4043
|
if (mapPoints instanceof Array && t.props.mapPoints instanceof Array && !t.deepEqual(mapPoints, t.props.mapPoints)) {
|
|
3563
4044
|
var oldMapPoints = t.props.mapPoints;
|
|
3564
|
-
var newMapPoints = mapPoints;
|
|
3565
|
-
|
|
4045
|
+
var newMapPoints = mapPoints; //过滤编辑的图元
|
|
4046
|
+
|
|
3566
4047
|
if (!!t.editId) {
|
|
3567
4048
|
oldMapPoints = t.props.mapPoints.filter(function (item) {
|
|
3568
4049
|
return item.id !== editGraphicId;
|
|
@@ -3571,41 +4052,52 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3571
4052
|
return item.id !== editGraphicId;
|
|
3572
4053
|
});
|
|
3573
4054
|
}
|
|
4055
|
+
|
|
3574
4056
|
var _t$dataMatch = t.dataMatch(oldMapPoints, newMapPoints, 'id'),
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
4057
|
+
deletedDataIDs = _t$dataMatch.deletedDataIDs,
|
|
4058
|
+
addedData = _t$dataMatch.addedData,
|
|
4059
|
+
updatedData = _t$dataMatch.updatedData;
|
|
4060
|
+
|
|
3578
4061
|
var _t$dealAdd = t.dealAdd(addedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
|
|
3579
|
-
|
|
3580
|
-
|
|
4062
|
+
ads = _t$dealAdd.ads,
|
|
4063
|
+
otherupds = _t$dealAdd.otherupds;
|
|
4064
|
+
|
|
3581
4065
|
var _t$dealUpdate = t.dealUpdate(updatedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
4066
|
+
upds = _t$dealUpdate.upds,
|
|
4067
|
+
otherads = _t$dealUpdate.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
4068
|
+
|
|
4069
|
+
|
|
3585
4070
|
var index = 0;
|
|
4071
|
+
|
|
3586
4072
|
var removeGraphic = function removeGraphic(id) {
|
|
3587
4073
|
t.removeGraphic(id, 'point');
|
|
4074
|
+
|
|
3588
4075
|
if (index < deletedDataIDs.length - 1) {
|
|
3589
4076
|
requestIdleCallback(function () {
|
|
3590
4077
|
return removeGraphic(deletedDataIDs[++index]);
|
|
3591
4078
|
});
|
|
3592
4079
|
}
|
|
3593
4080
|
};
|
|
4081
|
+
|
|
3594
4082
|
if (!(0, _lodash.isEmpty)(deletedDataIDs)) {
|
|
3595
4083
|
removeGraphic(deletedDataIDs[index]);
|
|
3596
|
-
}
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
//更新
|
|
4084
|
+
} //增加
|
|
4085
|
+
|
|
4086
|
+
|
|
4087
|
+
t.addPoint([].concat(_toConsumableArray(ads), _toConsumableArray(otherads))); //更新
|
|
4088
|
+
|
|
3600
4089
|
t.updatePoint([].concat(_toConsumableArray(upds), _toConsumableArray(otherupds)));
|
|
3601
4090
|
}
|
|
3602
4091
|
/*
|
|
3603
4092
|
线数据处理
|
|
3604
4093
|
先全删除,再新增
|
|
3605
4094
|
*/
|
|
4095
|
+
|
|
4096
|
+
|
|
3606
4097
|
if (mapLines instanceof Array && t.props.mapLines instanceof Array && !t.deepEqual(mapLines, t.props.mapLines)) {
|
|
3607
4098
|
var oldMapLines = t.props.mapLines;
|
|
3608
4099
|
var newMapLines = mapLines;
|
|
4100
|
+
|
|
3609
4101
|
if (!!t.editId) {
|
|
3610
4102
|
oldMapLines = t.props.mapLines.filter(function (item) {
|
|
3611
4103
|
return item.id !== editGraphicId;
|
|
@@ -3614,41 +4106,50 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3614
4106
|
return item.id !== editGraphicId;
|
|
3615
4107
|
});
|
|
3616
4108
|
}
|
|
4109
|
+
|
|
3617
4110
|
var _t$dataMatch2 = t.dataMatch(oldMapLines, newMapLines, 'id'),
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
4111
|
+
_deletedDataIDs = _t$dataMatch2.deletedDataIDs,
|
|
4112
|
+
_addedData = _t$dataMatch2.addedData,
|
|
4113
|
+
_updatedData = _t$dataMatch2.updatedData;
|
|
4114
|
+
|
|
3621
4115
|
var _t$dealAdd2 = t.dealAdd(_addedData, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
|
|
3622
|
-
|
|
3623
|
-
|
|
4116
|
+
_ads = _t$dealAdd2.ads,
|
|
4117
|
+
_otherupds = _t$dealAdd2.otherupds;
|
|
4118
|
+
|
|
3624
4119
|
var _t$dealUpdate2 = t.dealUpdate(_updatedData, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
4120
|
+
_upds = _t$dealUpdate2.upds,
|
|
4121
|
+
_otherads = _t$dealUpdate2.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
4122
|
+
|
|
4123
|
+
|
|
3628
4124
|
var _iterator = _createForOfIteratorHelper(_deletedDataIDs),
|
|
3629
|
-
|
|
4125
|
+
_step;
|
|
4126
|
+
|
|
3630
4127
|
try {
|
|
3631
4128
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
3632
4129
|
var id = _step.value;
|
|
3633
4130
|
t.removeGraphic(id, 'line');
|
|
3634
|
-
}
|
|
3635
|
-
|
|
4131
|
+
} //增加
|
|
4132
|
+
|
|
3636
4133
|
} catch (err) {
|
|
3637
4134
|
_iterator.e(err);
|
|
3638
4135
|
} finally {
|
|
3639
4136
|
_iterator.f();
|
|
3640
4137
|
}
|
|
3641
|
-
|
|
3642
|
-
//更新
|
|
4138
|
+
|
|
4139
|
+
t.addLine([].concat(_toConsumableArray(_ads), _toConsumableArray(_otherads))); //更新
|
|
4140
|
+
|
|
3643
4141
|
t.updateLine([].concat(_toConsumableArray(_upds), _toConsumableArray(_otherupds)));
|
|
3644
4142
|
}
|
|
3645
4143
|
/*
|
|
3646
4144
|
面数据处理
|
|
3647
4145
|
先全删除,再新增
|
|
3648
4146
|
*/
|
|
4147
|
+
|
|
4148
|
+
|
|
3649
4149
|
if (mapPolygons instanceof Array && t.props.mapPolygons instanceof Array && !t.deepEqual(mapPolygons, t.props.mapPolygons)) {
|
|
3650
4150
|
var oldMapPolygons = t.props.mapPolygons;
|
|
3651
4151
|
var newMapPolygons = mapPolygons;
|
|
4152
|
+
|
|
3652
4153
|
if (!!t.editId) {
|
|
3653
4154
|
oldMapPolygons = t.props.mapPolygons.filter(function (item) {
|
|
3654
4155
|
return item.id !== editGraphicId;
|
|
@@ -3657,41 +4158,50 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3657
4158
|
return item.id !== editGraphicId;
|
|
3658
4159
|
});
|
|
3659
4160
|
}
|
|
4161
|
+
|
|
3660
4162
|
var _t$dataMatch3 = t.dataMatch(oldMapPolygons, newMapPolygons, 'id'),
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
4163
|
+
_deletedDataIDs2 = _t$dataMatch3.deletedDataIDs,
|
|
4164
|
+
_addedData2 = _t$dataMatch3.addedData,
|
|
4165
|
+
_updatedData2 = _t$dataMatch3.updatedData;
|
|
4166
|
+
|
|
3664
4167
|
var _t$dealAdd3 = t.dealAdd(_addedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
|
|
3665
|
-
|
|
3666
|
-
|
|
4168
|
+
_ads2 = _t$dealAdd3.ads,
|
|
4169
|
+
_otherupds2 = _t$dealAdd3.otherupds;
|
|
4170
|
+
|
|
3667
4171
|
var _t$dealUpdate3 = t.dealUpdate(_updatedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
4172
|
+
_upds2 = _t$dealUpdate3.upds,
|
|
4173
|
+
_otherads2 = _t$dealUpdate3.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
4174
|
+
|
|
4175
|
+
|
|
3671
4176
|
var _iterator2 = _createForOfIteratorHelper(_deletedDataIDs2),
|
|
3672
|
-
|
|
4177
|
+
_step2;
|
|
4178
|
+
|
|
3673
4179
|
try {
|
|
3674
4180
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
3675
4181
|
var _id = _step2.value;
|
|
3676
4182
|
t.removeGraphic(_id, 'polygon');
|
|
3677
|
-
}
|
|
3678
|
-
|
|
4183
|
+
} //增加
|
|
4184
|
+
|
|
3679
4185
|
} catch (err) {
|
|
3680
4186
|
_iterator2.e(err);
|
|
3681
4187
|
} finally {
|
|
3682
4188
|
_iterator2.f();
|
|
3683
4189
|
}
|
|
3684
|
-
|
|
3685
|
-
//更新
|
|
4190
|
+
|
|
4191
|
+
t.addPolygon([].concat(_toConsumableArray(_ads2), _toConsumableArray(_otherads2))); //更新
|
|
4192
|
+
|
|
3686
4193
|
t.updatePolygon([].concat(_toConsumableArray(_upds2), _toConsumableArray(_otherupds2)));
|
|
3687
4194
|
}
|
|
3688
4195
|
/*
|
|
3689
4196
|
圆数据处理
|
|
3690
4197
|
先全删除,再新增
|
|
3691
4198
|
*/
|
|
4199
|
+
|
|
4200
|
+
|
|
3692
4201
|
if (mapCircles instanceof Array && t.props.mapCircles instanceof Array && !t.deepEqual(mapCircles, t.props.mapCircles)) {
|
|
3693
4202
|
var oldMapCircles = t.props.mapCircles;
|
|
3694
4203
|
var newMapCircles = mapCircles;
|
|
4204
|
+
|
|
3695
4205
|
if (!!t.editId) {
|
|
3696
4206
|
oldMapCircles = t.props.mapCircles.filter(function (item) {
|
|
3697
4207
|
return item.id !== editGraphicId;
|
|
@@ -3700,121 +4210,147 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3700
4210
|
return item.id !== editGraphicId;
|
|
3701
4211
|
});
|
|
3702
4212
|
}
|
|
4213
|
+
|
|
3703
4214
|
var _t$dataMatch4 = t.dataMatch(oldMapCircles, newMapCircles, 'id'),
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
4215
|
+
_deletedDataIDs3 = _t$dataMatch4.deletedDataIDs,
|
|
4216
|
+
_addedData3 = _t$dataMatch4.addedData,
|
|
4217
|
+
_updatedData3 = _t$dataMatch4.updatedData;
|
|
4218
|
+
|
|
3707
4219
|
var _t$dealAdd4 = t.dealAdd(_addedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
|
|
3708
|
-
|
|
3709
|
-
|
|
4220
|
+
_ads3 = _t$dealAdd4.ads,
|
|
4221
|
+
_otherupds3 = _t$dealAdd4.otherupds;
|
|
4222
|
+
|
|
3710
4223
|
var _t$dealUpdate4 = t.dealUpdate(_updatedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
4224
|
+
_upds3 = _t$dealUpdate4.upds,
|
|
4225
|
+
_otherads3 = _t$dealUpdate4.otherads; //删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
4226
|
+
|
|
4227
|
+
|
|
3714
4228
|
var _iterator3 = _createForOfIteratorHelper(_deletedDataIDs3),
|
|
3715
|
-
|
|
4229
|
+
_step3;
|
|
4230
|
+
|
|
3716
4231
|
try {
|
|
3717
4232
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
3718
4233
|
var _id2 = _step3.value;
|
|
3719
4234
|
t.removeGraphic(_id2, 'circle');
|
|
3720
|
-
}
|
|
3721
|
-
|
|
4235
|
+
} //增加
|
|
4236
|
+
|
|
3722
4237
|
} catch (err) {
|
|
3723
4238
|
_iterator3.e(err);
|
|
3724
4239
|
} finally {
|
|
3725
4240
|
_iterator3.f();
|
|
3726
4241
|
}
|
|
3727
|
-
|
|
3728
|
-
//更新
|
|
4242
|
+
|
|
4243
|
+
t.addCircle([].concat(_toConsumableArray(_ads3), _toConsumableArray(_otherads3))); //更新
|
|
4244
|
+
|
|
3729
4245
|
t.updateCircle([].concat(_toConsumableArray(_upds3), _toConsumableArray(_otherupds3)));
|
|
3730
|
-
}
|
|
3731
|
-
|
|
4246
|
+
} //图元编辑调用
|
|
4247
|
+
|
|
4248
|
+
|
|
3732
4249
|
if (typeof isDoEdit == 'boolean' && isDoEdit || isDoEdit && isDoEdit !== t.props.isDoEdit) {
|
|
3733
4250
|
t.doEdit(editGraphicId);
|
|
3734
|
-
}
|
|
3735
|
-
|
|
4251
|
+
} // 获取热力图
|
|
4252
|
+
|
|
4253
|
+
|
|
3736
4254
|
if (heatMapData && heatMapData.data && !t.deepEqual(heatMapData, t.props.heatMapData)) {
|
|
3737
4255
|
t.heatMapOverlay(heatMapData);
|
|
3738
4256
|
} else if (!t.deepEqual(heatMapData, t.props.heatMapData)) {
|
|
3739
4257
|
t.clearHeatMap(heatMapData);
|
|
3740
|
-
}
|
|
3741
|
-
|
|
4258
|
+
} //清空地图
|
|
4259
|
+
|
|
4260
|
+
|
|
3742
4261
|
if (typeof isClearAll == 'boolean' && isClearAll || isClearAll && isClearAll !== t.props.isClearAll) {
|
|
3743
4262
|
t.clearAll();
|
|
3744
|
-
}
|
|
3745
|
-
|
|
4263
|
+
} //测距工具调用
|
|
4264
|
+
|
|
4265
|
+
|
|
3746
4266
|
if (typeof isRangingTool == 'boolean' && isRangingTool || isRangingTool && isRangingTool !== t.props.isRangingTool) {
|
|
3747
4267
|
t.vtxRangingTool(mapRangingTool);
|
|
3748
4268
|
}
|
|
3749
4269
|
/*设置指定图元展示*/
|
|
4270
|
+
|
|
4271
|
+
|
|
3750
4272
|
if (typeof setVisiblePoints == 'boolean' && setVisiblePoints || setVisiblePoints && setVisiblePoints !== t.props.setVisiblePoints) {
|
|
3751
4273
|
t.setVisiblePoints(mapVisiblePoints);
|
|
3752
|
-
}
|
|
3753
|
-
//设置中心点
|
|
4274
|
+
} //设置中心点
|
|
3754
4275
|
// if ((typeof (setCenter) == 'boolean' && setCenter) || (setCenter && setCenter !== t.props.setCenter)) {
|
|
3755
4276
|
// if (!(t.getCurrentCenter().lng == mapCenter[0] && t.getCurrentCenter().lat == mapCenter[1])) {
|
|
3756
4277
|
// t.setCenter(mapCenter);
|
|
3757
4278
|
// }
|
|
3758
4279
|
// }
|
|
4280
|
+
|
|
4281
|
+
|
|
3759
4282
|
if (nextProps.mapCenter && nextProps.mapCenter.length > 0 && JSON.stringify(nextProps.mapCenter) !== JSON.stringify(this.props.mapCenter)) {
|
|
3760
4283
|
t.setCenter(mapCenter);
|
|
3761
|
-
}
|
|
3762
|
-
|
|
4284
|
+
} //设置点聚合
|
|
4285
|
+
|
|
4286
|
+
|
|
3763
4287
|
if (typeof setCluster == 'boolean' && setCluster || setCluster && setCluster !== t.props.setCluster) {
|
|
3764
4288
|
t.cluster(mapCluster);
|
|
3765
4289
|
}
|
|
4290
|
+
|
|
3766
4291
|
if (!setCluster && setCluster !== t.props.setCluster) {
|
|
3767
4292
|
t.clearCluster(mapCluster);
|
|
3768
|
-
}
|
|
3769
|
-
|
|
4293
|
+
} //图元编辑调用
|
|
4294
|
+
|
|
4295
|
+
|
|
3770
4296
|
if (typeof isDoEdit == 'boolean' && isDoEdit || isDoEdit && isDoEdit !== t.props.isDoEdit) {
|
|
3771
4297
|
t.doEdit(editGraphicId);
|
|
3772
|
-
}
|
|
3773
|
-
|
|
4298
|
+
} //关闭图元编辑
|
|
4299
|
+
|
|
4300
|
+
|
|
3774
4301
|
if (typeof isEndEdit == 'boolean' && isEndEdit || isEndEdit && isEndEdit !== t.props.isEndEdit) {
|
|
3775
4302
|
t.endEdit();
|
|
3776
|
-
}
|
|
3777
|
-
|
|
4303
|
+
} //绘制图元
|
|
4304
|
+
|
|
4305
|
+
|
|
3778
4306
|
if (typeof isDraw == 'boolean' && isDraw || isDraw && isDraw !== t.props.isDraw) {
|
|
3779
4307
|
t.draw(mapDraw);
|
|
3780
|
-
}
|
|
3781
|
-
|
|
4308
|
+
} //关闭绘制
|
|
4309
|
+
|
|
4310
|
+
|
|
3782
4311
|
if (typeof isCloseDraw == 'boolean' && isCloseDraw || isCloseDraw && isCloseDraw !== t.props.isCloseDraw) {
|
|
3783
4312
|
t.closeDraw();
|
|
3784
|
-
}
|
|
3785
|
-
|
|
4313
|
+
} //单独删除操作
|
|
4314
|
+
|
|
4315
|
+
|
|
3786
4316
|
if (typeof isRemove == 'boolean' && isRemove || isRemove && isRemove !== t.props.isRemove) {
|
|
3787
4317
|
mapRemove.map(function (item, index) {
|
|
3788
4318
|
t.removeGraphic(item.id, item.type);
|
|
3789
4319
|
});
|
|
3790
|
-
}
|
|
3791
|
-
|
|
4320
|
+
} //设置区域限制
|
|
4321
|
+
|
|
4322
|
+
|
|
3792
4323
|
if (typeof isSetAreaRestriction == 'boolean' && isSetAreaRestriction || isSetAreaRestriction && isSetAreaRestriction !== t.props.isSetAreaRestriction && areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
|
|
3793
4324
|
t.setAreaRestriction(areaRestriction);
|
|
3794
|
-
}
|
|
3795
|
-
|
|
4325
|
+
} //关闭区域限制
|
|
4326
|
+
|
|
4327
|
+
|
|
3796
4328
|
if (typeof isClearAreaRestriction == 'boolean' && isClearAreaRestriction || isClearAreaRestriction && isClearAreaRestriction !== t.props.isClearAreaRestriction) {
|
|
3797
4329
|
t.clearAreaRestriction();
|
|
3798
|
-
}
|
|
3799
|
-
|
|
4330
|
+
} // 设置地图层级
|
|
4331
|
+
|
|
4332
|
+
|
|
3800
4333
|
if (typeof setZoomLevel == 'boolean' && setZoomLevel || setZoomLevel && setZoomLevel !== t.props.setZoomLevel) {
|
|
3801
4334
|
t.setZoomLevel(mapZoomLevel);
|
|
3802
|
-
}
|
|
3803
|
-
|
|
4335
|
+
} // 比例尺控件位置改变
|
|
4336
|
+
|
|
4337
|
+
|
|
3804
4338
|
if (nextProps.showControl && JSON.stringify(nextProps.showControl) != JSON.stringify(t.props.showControl)) {
|
|
3805
4339
|
t.showControl(nextProps);
|
|
3806
|
-
}
|
|
3807
|
-
|
|
4340
|
+
} // 更新需要加载的图层
|
|
4341
|
+
|
|
4342
|
+
|
|
3808
4343
|
if (nextProps.olProps && JSON.stringify(nextProps.olProps) !== JSON.stringify(t.props.olProps)) {
|
|
3809
4344
|
t.loadLayers(nextProps.olProps.olCoverage, t.props.olProps.olCoverage);
|
|
3810
4345
|
}
|
|
3811
|
-
}
|
|
3812
|
-
// 地图事件
|
|
4346
|
+
} // 地图事件
|
|
3813
4347
|
//地图点击事件
|
|
4348
|
+
|
|
3814
4349
|
}, {
|
|
3815
4350
|
key: "clickMap",
|
|
3816
4351
|
value: function clickMap(e) {
|
|
3817
4352
|
var t = this;
|
|
4353
|
+
|
|
3818
4354
|
if (typeof t.props.clickMap === 'function') {
|
|
3819
4355
|
var obj = t.getMapExtent();
|
|
3820
4356
|
obj.e = e;
|
|
@@ -3832,17 +4368,20 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3832
4368
|
temp.push(t.getFeatureInfo(e, t.state.gis.getView(), item.layer.getSource()));
|
|
3833
4369
|
}
|
|
3834
4370
|
});
|
|
4371
|
+
|
|
3835
4372
|
if (temp.length) {
|
|
3836
4373
|
obj.features = temp;
|
|
3837
4374
|
}
|
|
4375
|
+
|
|
3838
4376
|
t.props.clickMap(obj);
|
|
3839
4377
|
}
|
|
3840
|
-
}
|
|
3841
|
-
|
|
4378
|
+
} // 获取geoServer要素
|
|
4379
|
+
|
|
3842
4380
|
}, {
|
|
3843
4381
|
key: "getFeatureInfo",
|
|
3844
4382
|
value: function getFeatureInfo(event, view, source) {
|
|
3845
4383
|
var _this8 = this;
|
|
4384
|
+
|
|
3846
4385
|
var sourceParam = source.getParams();
|
|
3847
4386
|
var url = source.getFeatureInfoUrl(event.coordinate, view.getResolution(), view.getProjection(), {
|
|
3848
4387
|
cql_filter: sourceParam === null || sourceParam === void 0 ? void 0 : sourceParam.cql_filter,
|
|
@@ -3851,41 +4390,49 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3851
4390
|
REQUEST: "GetFeatureInfo",
|
|
3852
4391
|
FEATURE_COUNT: 50
|
|
3853
4392
|
});
|
|
4393
|
+
|
|
3854
4394
|
var _this$formatUrl2 = this.formatUrl(url),
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
// let temp = param.BBOX.split(",");
|
|
4395
|
+
param = _this$formatUrl2.param,
|
|
4396
|
+
address = _this$formatUrl2.address; // let temp = param.BBOX.split(",");
|
|
3858
4397
|
// let BBOX = [temp[1],temp[0],temp[3],temp[2]].join(",");
|
|
3859
4398
|
// param.BBOX = BBOX;
|
|
4399
|
+
|
|
4400
|
+
|
|
3860
4401
|
param.QUERY_LAYERS = param.LAYERS;
|
|
3861
4402
|
var temp = [];
|
|
4403
|
+
|
|
3862
4404
|
for (var key in param) {
|
|
3863
4405
|
temp.push("".concat(key, "=").concat(param[key]));
|
|
3864
4406
|
}
|
|
4407
|
+
|
|
3865
4408
|
address += "?".concat(temp.join("&"));
|
|
3866
4409
|
var geoJsonFormat = new ol.format.GeoJSON();
|
|
3867
4410
|
return fetch(address).then(function (res) {
|
|
3868
4411
|
return res.json();
|
|
3869
4412
|
}).then(function (data) {
|
|
3870
4413
|
var _data$features;
|
|
4414
|
+
|
|
3871
4415
|
var features = [];
|
|
4416
|
+
|
|
3872
4417
|
if (data !== null && data !== void 0 && (_data$features = data.features) !== null && _data$features !== void 0 && _data$features.length) {
|
|
3873
4418
|
features = geoJsonFormat.readFeatures(data);
|
|
3874
4419
|
features.map(function (item) {
|
|
3875
4420
|
item.key = _this8 === null || _this8 === void 0 ? void 0 : _this8.key;
|
|
3876
4421
|
});
|
|
3877
4422
|
}
|
|
4423
|
+
|
|
3878
4424
|
return features;
|
|
3879
4425
|
})["catch"](function () {
|
|
3880
4426
|
return [];
|
|
3881
4427
|
});
|
|
3882
|
-
}
|
|
3883
|
-
|
|
4428
|
+
} // 要素鼠标悬浮事件
|
|
4429
|
+
|
|
3884
4430
|
}, {
|
|
3885
4431
|
key: "mouseOverGraphic",
|
|
3886
4432
|
value: function mouseOverGraphic(id, e) {
|
|
3887
4433
|
var t = this;
|
|
3888
4434
|
if (t.state.editId == id) return false;
|
|
4435
|
+
|
|
3889
4436
|
if (typeof t.props.mouseOverGraphic === 'function') {
|
|
3890
4437
|
var obj = {
|
|
3891
4438
|
e: e,
|
|
@@ -3897,14 +4444,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3897
4444
|
};
|
|
3898
4445
|
t.props.mouseOverGraphic(obj);
|
|
3899
4446
|
}
|
|
3900
|
-
}
|
|
3901
|
-
|
|
4447
|
+
} // 要素鼠标移开事件
|
|
4448
|
+
|
|
3902
4449
|
}, {
|
|
3903
4450
|
key: "mouseOutGraphic",
|
|
3904
4451
|
value: function mouseOutGraphic(id, e) {
|
|
3905
|
-
var t = this;
|
|
3906
|
-
|
|
4452
|
+
var t = this; //编辑中的图元关闭其他事件返回
|
|
4453
|
+
|
|
3907
4454
|
if (t.state.editId == id) return false;
|
|
4455
|
+
|
|
3908
4456
|
if (typeof t.props.mouseOutGraphic === 'function') {
|
|
3909
4457
|
var obj = {
|
|
3910
4458
|
e: e,
|
|
@@ -3916,30 +4464,32 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3916
4464
|
};
|
|
3917
4465
|
t.props.mouseOutGraphic(obj);
|
|
3918
4466
|
}
|
|
3919
|
-
}
|
|
3920
|
-
|
|
4467
|
+
} //地图拖动之前事件
|
|
4468
|
+
|
|
3921
4469
|
}, {
|
|
3922
4470
|
key: "dragMapStart",
|
|
3923
4471
|
value: function dragMapStart(e) {
|
|
3924
4472
|
var t = this;
|
|
4473
|
+
|
|
3925
4474
|
if (typeof t.props.dragMapStart === 'function') {
|
|
3926
4475
|
var obj = t.getMapExtent();
|
|
3927
4476
|
obj.e = e;
|
|
3928
4477
|
t.props.dragMapStart(obj);
|
|
3929
4478
|
}
|
|
3930
|
-
}
|
|
3931
|
-
|
|
4479
|
+
} //地图拖动结束后事件
|
|
4480
|
+
|
|
3932
4481
|
}, {
|
|
3933
4482
|
key: "dragMapEnd",
|
|
3934
4483
|
value: function dragMapEnd(e) {
|
|
3935
4484
|
var t = this;
|
|
4485
|
+
|
|
3936
4486
|
if (typeof t.props.dragMapEnd === 'function') {
|
|
3937
4487
|
var obj = t.getMapExtent();
|
|
3938
4488
|
obj.e = e;
|
|
3939
4489
|
t.props.dragMapEnd(obj);
|
|
3940
4490
|
}
|
|
3941
|
-
}
|
|
3942
|
-
|
|
4491
|
+
} //热力图
|
|
4492
|
+
|
|
3943
4493
|
}, {
|
|
3944
4494
|
key: "heatMapOverlay",
|
|
3945
4495
|
value: function heatMapOverlay() {
|
|
@@ -3952,23 +4502,28 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3952
4502
|
opacity: 0.7,
|
|
3953
4503
|
gradient: ['#00f', '#0ff', '#0f0', '#ff0', '#f00']
|
|
3954
4504
|
};
|
|
4505
|
+
|
|
3955
4506
|
if (d.config) {
|
|
3956
4507
|
cg = _objectSpread(_objectSpread({}, cg), d.config);
|
|
3957
4508
|
}
|
|
4509
|
+
|
|
3958
4510
|
var gradient = [];
|
|
4511
|
+
|
|
3959
4512
|
if (cg.gradient) {
|
|
3960
4513
|
for (var key in cg.gradient) {
|
|
3961
4514
|
gradient.push(cg.gradient[key]);
|
|
3962
4515
|
}
|
|
4516
|
+
|
|
3963
4517
|
cg.gradient = gradient;
|
|
3964
|
-
}
|
|
3965
|
-
// if(d.data){
|
|
4518
|
+
} // if(d.data){
|
|
3966
4519
|
// t.state.pointIds = [];
|
|
3967
4520
|
// t.pointLayers.map(item => {
|
|
3968
4521
|
// t.state.gis.removeLayer(item.layer);
|
|
3969
4522
|
// t.pointLayers=[];
|
|
3970
4523
|
// })
|
|
3971
4524
|
// }
|
|
4525
|
+
|
|
4526
|
+
|
|
3972
4527
|
var heatData = {
|
|
3973
4528
|
type: 'FeatureCollection',
|
|
3974
4529
|
features: (d.data || []).map(function (item) {
|
|
@@ -4007,63 +4562,69 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
4007
4562
|
if (t.heatmap) t.state.gis.removeLayer(t.heatmap);
|
|
4008
4563
|
t.heatmap = null;
|
|
4009
4564
|
t.refresh();
|
|
4010
|
-
}
|
|
4011
|
-
|
|
4565
|
+
} //地图移动之前事件
|
|
4566
|
+
|
|
4012
4567
|
}, {
|
|
4013
4568
|
key: "moveStart",
|
|
4014
4569
|
value: function moveStart(e) {
|
|
4015
4570
|
var t = this;
|
|
4571
|
+
|
|
4016
4572
|
if (typeof t.props.moveStart === 'function') {
|
|
4017
4573
|
var obj = t.getMapExtent();
|
|
4018
4574
|
obj.e = e;
|
|
4019
4575
|
t.props.moveStart(obj);
|
|
4020
4576
|
}
|
|
4021
|
-
}
|
|
4022
|
-
|
|
4577
|
+
} //地图移动结束后事件
|
|
4578
|
+
|
|
4023
4579
|
}, {
|
|
4024
4580
|
key: "moveEnd",
|
|
4025
4581
|
value: function moveEnd(e) {
|
|
4026
4582
|
var t = this;
|
|
4583
|
+
|
|
4027
4584
|
if (typeof t.props.moveEnd === 'function') {
|
|
4028
4585
|
var obj = t.getMapExtent();
|
|
4029
4586
|
obj.e = e;
|
|
4030
4587
|
t.props.moveEnd(obj);
|
|
4031
4588
|
}
|
|
4032
|
-
}
|
|
4033
|
-
|
|
4589
|
+
} //地图更改缩放级别开始时触发触发此事件
|
|
4590
|
+
|
|
4034
4591
|
}, {
|
|
4035
4592
|
key: "zoomStart",
|
|
4036
4593
|
value: function zoomStart(e) {
|
|
4037
4594
|
var t = this;
|
|
4595
|
+
|
|
4038
4596
|
if (typeof t.props.zoomStart === 'function') {
|
|
4039
4597
|
var obj = t.getMapExtent();
|
|
4040
4598
|
obj.e = e;
|
|
4041
4599
|
t.props.zoomStart(obj);
|
|
4042
4600
|
}
|
|
4043
|
-
}
|
|
4044
|
-
|
|
4601
|
+
} //地图更改缩放级别结束时触发触发此事件
|
|
4602
|
+
|
|
4045
4603
|
}, {
|
|
4046
4604
|
key: "zoomEnd",
|
|
4047
4605
|
value: function zoomEnd(e) {
|
|
4048
4606
|
var t = this;
|
|
4607
|
+
|
|
4049
4608
|
if (typeof t.props.zoomEnd === 'function') {
|
|
4050
4609
|
var obj = t.getMapExtent();
|
|
4051
4610
|
obj.e = e;
|
|
4052
4611
|
t.props.zoomEnd(obj);
|
|
4053
4612
|
}
|
|
4054
|
-
}
|
|
4055
|
-
|
|
4613
|
+
} // 图元点击事件
|
|
4614
|
+
|
|
4056
4615
|
}, {
|
|
4057
4616
|
key: "clickGraphic",
|
|
4058
4617
|
value: function clickGraphic(id, e) {
|
|
4059
4618
|
var target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
4060
|
-
var t = this;
|
|
4061
|
-
|
|
4619
|
+
var t = this; //编辑中的图元关闭其他事件返回
|
|
4620
|
+
|
|
4062
4621
|
if (t.editId == id) return false;
|
|
4622
|
+
|
|
4063
4623
|
if (typeof t.props.clickGraphic === 'function') {
|
|
4064
4624
|
var _e$pixel = _slicedToArray(e.pixel, 2),
|
|
4065
|
-
|
|
4066
|
-
|
|
4625
|
+
clientX = _e$pixel[0],
|
|
4626
|
+
clientY = _e$pixel[1];
|
|
4627
|
+
|
|
4067
4628
|
var param = t.getGraphic(id, clientX, clientY);
|
|
4068
4629
|
var obj = {
|
|
4069
4630
|
param: param,
|
|
@@ -4087,27 +4648,38 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
4087
4648
|
value: function componentWillUnmount() {
|
|
4088
4649
|
//关闭moveTo定时
|
|
4089
4650
|
var t = this;
|
|
4651
|
+
|
|
4090
4652
|
if (t.moveToTimer) {
|
|
4091
4653
|
clearInterval(t.moveToTimer);
|
|
4092
|
-
}
|
|
4093
|
-
|
|
4654
|
+
} //关闭animation定时
|
|
4655
|
+
|
|
4656
|
+
|
|
4094
4657
|
for (var j in t.animTimer) {
|
|
4095
4658
|
if (t.animTimer[j]) {
|
|
4096
4659
|
clearInterval(t.animTimer[j]);
|
|
4097
4660
|
}
|
|
4098
4661
|
}
|
|
4662
|
+
|
|
4099
4663
|
window.VtxMap && (window.VtxMap[t.state.mapId] = null);
|
|
4100
4664
|
}
|
|
4101
4665
|
}]);
|
|
4666
|
+
|
|
4102
4667
|
return OlMap;
|
|
4103
4668
|
}(_react["default"].Component);
|
|
4104
|
-
|
|
4669
|
+
|
|
4670
|
+
var _default = OlMap;
|
|
4671
|
+
exports["default"] = _default;
|
|
4672
|
+
|
|
4105
4673
|
var Popup = /*#__PURE__*/function (_React$Component2) {
|
|
4106
4674
|
_inherits(Popup, _React$Component2);
|
|
4675
|
+
|
|
4107
4676
|
var _super2 = _createSuper(Popup);
|
|
4677
|
+
|
|
4108
4678
|
function Popup(props) {
|
|
4109
4679
|
var _this9;
|
|
4680
|
+
|
|
4110
4681
|
_classCallCheck(this, Popup);
|
|
4682
|
+
|
|
4111
4683
|
_this9 = _super2.call(this);
|
|
4112
4684
|
_this9.map = props.map;
|
|
4113
4685
|
_this9.position = props.position;
|
|
@@ -4116,17 +4688,18 @@ var Popup = /*#__PURE__*/function (_React$Component2) {
|
|
|
4116
4688
|
_this9.innerHTML = props.innerHTML;
|
|
4117
4689
|
_this9.closeble = props.close;
|
|
4118
4690
|
return _this9;
|
|
4119
|
-
}
|
|
4691
|
+
} // 弹出框
|
|
4692
|
+
|
|
4120
4693
|
|
|
4121
|
-
// 弹出框
|
|
4122
4694
|
_createClass(Popup, [{
|
|
4123
4695
|
key: "showPopup",
|
|
4124
4696
|
value: function showPopup() {
|
|
4125
4697
|
var t = this;
|
|
4126
|
-
this.removePopup();
|
|
4127
|
-
|
|
4698
|
+
this.removePopup(); // 获取弹出层DOM
|
|
4699
|
+
|
|
4128
4700
|
t.container = document.createElement("div");
|
|
4129
4701
|
t.container['className'] = "ol-popup";
|
|
4702
|
+
|
|
4130
4703
|
if (t.closeble) {
|
|
4131
4704
|
var close = document.createElement("a");
|
|
4132
4705
|
close['className'] = "ol-popup-closer";
|
|
@@ -4135,8 +4708,10 @@ var Popup = /*#__PURE__*/function (_React$Component2) {
|
|
|
4135
4708
|
});
|
|
4136
4709
|
t.container.appendChild(close);
|
|
4137
4710
|
}
|
|
4711
|
+
|
|
4138
4712
|
var content = document.createElement("div");
|
|
4139
4713
|
t.container.appendChild(content);
|
|
4714
|
+
|
|
4140
4715
|
if (t.overlay) {} else {
|
|
4141
4716
|
// 创建Overlay弹出层绑定DOM
|
|
4142
4717
|
t.overlay = new ol.Overlay({
|
|
@@ -4146,85 +4721,100 @@ var Popup = /*#__PURE__*/function (_React$Component2) {
|
|
|
4146
4721
|
duration: 250
|
|
4147
4722
|
}
|
|
4148
4723
|
}
|
|
4149
|
-
});
|
|
4150
|
-
|
|
4724
|
+
}); // 添加到map
|
|
4725
|
+
|
|
4151
4726
|
t.map.addOverlay(t.overlay);
|
|
4152
|
-
}
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
// 设置弹出层位置即可出现
|
|
4727
|
+
} // 弹出层内容
|
|
4728
|
+
|
|
4729
|
+
|
|
4730
|
+
content.innerHTML = t.innerHTML; // 设置弹出层位置即可出现
|
|
4731
|
+
|
|
4156
4732
|
t.overlay.setPosition(t.position);
|
|
4157
|
-
}
|
|
4158
|
-
|
|
4733
|
+
} // 清除弹出框
|
|
4734
|
+
|
|
4159
4735
|
}, {
|
|
4160
4736
|
key: "removePopup",
|
|
4161
4737
|
value: function removePopup() {
|
|
4162
4738
|
if (this.overlay) {
|
|
4163
|
-
this.container.remove();
|
|
4164
|
-
|
|
4739
|
+
this.container.remove(); // 设置位置undefined可达到隐藏清除弹出框
|
|
4740
|
+
|
|
4165
4741
|
this.overlay.setPosition(undefined);
|
|
4166
4742
|
this.overlay = null;
|
|
4167
4743
|
}
|
|
4168
4744
|
}
|
|
4169
4745
|
}]);
|
|
4746
|
+
|
|
4170
4747
|
return Popup;
|
|
4171
4748
|
}(_react["default"].Component);
|
|
4749
|
+
|
|
4172
4750
|
function getRgbColor(color, opacity) {
|
|
4173
4751
|
var reg = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;
|
|
4752
|
+
|
|
4174
4753
|
if (!reg.test(color) && typeof color !== 'string') {
|
|
4175
4754
|
return;
|
|
4176
4755
|
}
|
|
4756
|
+
|
|
4177
4757
|
var newStr = color.toLowerCase().replace(/\#/g, '');
|
|
4178
4758
|
var len = newStr.length;
|
|
4759
|
+
|
|
4179
4760
|
if (len == 3) {
|
|
4180
4761
|
var t = '';
|
|
4762
|
+
|
|
4181
4763
|
for (var i = 0; i < len; i++) {
|
|
4182
4764
|
t += newStr.slice(i, i + 1).concat(newStr.slice(i, i + 1));
|
|
4183
4765
|
}
|
|
4766
|
+
|
|
4184
4767
|
newStr = t;
|
|
4185
4768
|
}
|
|
4769
|
+
|
|
4186
4770
|
var arr = []; //将字符串分隔,两个两个的分隔
|
|
4771
|
+
|
|
4187
4772
|
for (var i = 0; i < 6; i = i + 2) {
|
|
4188
4773
|
var s = newStr.slice(i, i + 2);
|
|
4189
4774
|
arr.push(parseInt('0x' + s));
|
|
4190
4775
|
}
|
|
4776
|
+
|
|
4191
4777
|
return 'rgba(' + arr.join(',') + ',' + opacity + ')';
|
|
4192
|
-
}
|
|
4778
|
+
} // 压缩图片的方法
|
|
4779
|
+
|
|
4193
4780
|
|
|
4194
|
-
// 压缩图片的方法
|
|
4195
4781
|
function canvasDataURL(path, obj, callback) {
|
|
4196
4782
|
var img = new Image();
|
|
4197
4783
|
img.src = path;
|
|
4198
4784
|
img.setAttribute("crossOrigin", 'Anonymous');
|
|
4785
|
+
|
|
4199
4786
|
img.onload = function () {
|
|
4200
|
-
var that = this;
|
|
4201
|
-
|
|
4787
|
+
var that = this; // 默认按比例压缩
|
|
4788
|
+
|
|
4202
4789
|
var w = that.width,
|
|
4203
|
-
|
|
4204
|
-
|
|
4790
|
+
h = that.height,
|
|
4791
|
+
scale = w / h;
|
|
4205
4792
|
w = obj.width || w;
|
|
4206
4793
|
h = obj.height || w / scale;
|
|
4207
4794
|
var quality = 0.7; // 默认图片质量为0.7
|
|
4208
4795
|
//生成canvas
|
|
4796
|
+
|
|
4209
4797
|
var canvas = document.createElement('canvas');
|
|
4210
|
-
var ctx = canvas.getContext('2d');
|
|
4211
|
-
|
|
4798
|
+
var ctx = canvas.getContext('2d'); // 创建属性节点
|
|
4799
|
+
|
|
4212
4800
|
var anw = document.createAttribute("width");
|
|
4213
4801
|
anw.nodeValue = w;
|
|
4214
4802
|
var anh = document.createAttribute("height");
|
|
4215
4803
|
anh.nodeValue = h;
|
|
4216
4804
|
canvas.setAttributeNode(anw);
|
|
4217
4805
|
canvas.setAttributeNode(anh);
|
|
4218
|
-
ctx.drawImage(that, 0, 0, w, h);
|
|
4219
|
-
|
|
4806
|
+
ctx.drawImage(that, 0, 0, w, h); // 图像质量
|
|
4807
|
+
|
|
4220
4808
|
if (obj.quality && obj.quality <= 1 && obj.quality > 0) {
|
|
4221
4809
|
quality = obj.quality;
|
|
4222
|
-
}
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
// 回调函数返回base64的值
|
|
4810
|
+
} // quality值越小,所绘制出的图像越模糊
|
|
4811
|
+
|
|
4812
|
+
|
|
4813
|
+
var base64 = canvas.toDataURL('image/png', quality); // 回调函数返回base64的值
|
|
4814
|
+
|
|
4226
4815
|
callback(base64);
|
|
4227
4816
|
};
|
|
4228
4817
|
}
|
|
4818
|
+
|
|
4229
4819
|
module.exports = exports["default"];
|
|
4230
4820
|
//# sourceMappingURL=Map.js.map
|