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