@vtx/map 1.1.20 → 1.1.22
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 +21 -0
- package/lib/VtxMap/AMap/AMap.js.map +1 -1
- package/lib/VtxMap/BMap/Map.js +21 -0
- package/lib/VtxMap/BMap/Map.js.map +1 -1
- package/lib/VtxMap/OlMap/Map.js +192 -51
- package/lib/VtxMap/OlMap/Map.js.map +1 -1
- package/lib/VtxMap/TMap/TMap.js +22 -0
- package/lib/VtxMap/TMap/TMap.js.map +1 -1
- package/lib/VtxSearchMap/VtxSearchMap.js +11 -1
- package/lib/VtxSearchMap/VtxSearchMap.js.map +1 -1
- package/package.json +1 -1
package/lib/VtxMap/OlMap/Map.js
CHANGED
|
@@ -15,6 +15,8 @@ var _MapToolFunction = require("../MapToolFunction");
|
|
|
15
15
|
|
|
16
16
|
var _immutable = _interopRequireDefault(require("immutable"));
|
|
17
17
|
|
|
18
|
+
var _lodash = require("lodash");
|
|
19
|
+
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
21
|
|
|
20
22
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
@@ -31,8 +33,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
31
33
|
|
|
32
34
|
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; }
|
|
33
35
|
|
|
34
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
|
-
|
|
36
36
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
37
37
|
|
|
38
38
|
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."); }
|
|
@@ -65,6 +65,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
65
65
|
|
|
66
66
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
67
67
|
|
|
68
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
69
|
+
|
|
68
70
|
var Set = _immutable["default"].Set;
|
|
69
71
|
|
|
70
72
|
var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
@@ -78,6 +80,74 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
78
80
|
_classCallCheck(this, OlMap);
|
|
79
81
|
|
|
80
82
|
_this = _super.call(this, props);
|
|
83
|
+
|
|
84
|
+
_defineProperty(_assertThisInitialized(_this), "loadLayers", function () {
|
|
85
|
+
var nextLayers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
86
|
+
var currentLayers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
87
|
+
var first = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
88
|
+
|
|
89
|
+
var t = _assertThisInitialized(_this); // 对比图层的变化,找出需要新增和需要删除的。
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
var addLayers = nextLayers.filter(function (item) {
|
|
93
|
+
return !currentLayers.map(function (e) {
|
|
94
|
+
return e.coverage;
|
|
95
|
+
}).includes(item.coverage);
|
|
96
|
+
});
|
|
97
|
+
var removeLayers = currentLayers.filter(function (item) {
|
|
98
|
+
return !nextLayers.map(function (e) {
|
|
99
|
+
return e.coverage;
|
|
100
|
+
}).includes(item.coverage);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (removeLayers.length > 0) {
|
|
104
|
+
removeLayers.forEach(function (item) {
|
|
105
|
+
var exist = t.olLayers.find(function (e) {
|
|
106
|
+
return e.address === item.coverage;
|
|
107
|
+
});
|
|
108
|
+
exist && exist.layer.setVisible(false);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (addLayers.length > 0) {
|
|
113
|
+
addLayers.map(function (item) {
|
|
114
|
+
if (item.coverage.startsWith("http") || item.coverage.startsWith('/')) {
|
|
115
|
+
switch (item.type) {
|
|
116
|
+
// 超图
|
|
117
|
+
case 'superMap':
|
|
118
|
+
t.addSuperMapLayer(item.coverage);
|
|
119
|
+
break;
|
|
120
|
+
// geoServer
|
|
121
|
+
|
|
122
|
+
case 'geoServer':
|
|
123
|
+
t.addGeoServerLayer(item.coverage);
|
|
124
|
+
|
|
125
|
+
default:
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
} else if (OL_SCREEN[item.coverage]) {
|
|
129
|
+
if (first) {
|
|
130
|
+
var layers = eval(OL_SCREEN[item.coverage].initLayer);
|
|
131
|
+
|
|
132
|
+
if ((0, _lodash.isArray)(layers)) {
|
|
133
|
+
layers.map(function (layer) {
|
|
134
|
+
t.state.gis.addLayer(layer);
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
t.state.gis.addLayer(layers);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
if (first) {
|
|
144
|
+
var _layer = eval(OL_SCREEN["default"].initLayer);
|
|
145
|
+
|
|
146
|
+
t.state.gis.addLayer(_layer);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
81
151
|
_this.zIndexGraphics = []; //需要放在最后的图元,zoom和pan时刷新dom到最后
|
|
82
152
|
|
|
83
153
|
_this.htmlPointsId = 'vtx_gmap_html_points'; //html点位容器id class管理
|
|
@@ -141,7 +211,11 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
141
211
|
|
|
142
212
|
_this.areaRestriction = null; //区域限制数据
|
|
143
213
|
|
|
144
|
-
_this.movePoints = [];
|
|
214
|
+
_this.movePoints = [];
|
|
215
|
+
_this.olLayers = []; // ol图层集合 {address:'', layer: ''}
|
|
216
|
+
|
|
217
|
+
_this.baseLayer = null; // 地图图层
|
|
218
|
+
//是否绘制测距
|
|
145
219
|
|
|
146
220
|
_this.rangingTool = {
|
|
147
221
|
isRanging: false,
|
|
@@ -356,7 +430,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
356
430
|
var target = feature.getProperties(); // top: e.clientY,//当前点所在的位置(屏幕)
|
|
357
431
|
// left: e.clientX,
|
|
358
432
|
|
|
359
|
-
t.clickGraphic(target.id, evt);
|
|
433
|
+
t.clickGraphic(target.id || target.elementId, evt, target);
|
|
360
434
|
} else {
|
|
361
435
|
t.clickMap(evt);
|
|
362
436
|
}
|
|
@@ -475,31 +549,93 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
475
549
|
minZoom: minZoom,
|
|
476
550
|
maxZoom: maxZoom
|
|
477
551
|
});
|
|
552
|
+
t.loadLayers(olCoverage, [], true);
|
|
553
|
+
t.initPropsForUser();
|
|
554
|
+
} // 加载图层
|
|
478
555
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
})
|
|
487
|
-
});
|
|
556
|
+
}, {
|
|
557
|
+
key: "addSuperMapLayer",
|
|
558
|
+
value: // 添加超图图层
|
|
559
|
+
function addSuperMapLayer(url) {
|
|
560
|
+
var exist = this.olLayers.find(function (item) {
|
|
561
|
+
return item.address === url;
|
|
562
|
+
});
|
|
488
563
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
564
|
+
if (exist) {
|
|
565
|
+
exist.layer.setVisible(true);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
492
568
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
569
|
+
var layer = new ol.layer.Tile({
|
|
570
|
+
source: new ol.source.TileSuperMapRest({
|
|
571
|
+
url: url
|
|
572
|
+
})
|
|
573
|
+
}); // 将图层添加到地图上
|
|
498
574
|
|
|
499
|
-
|
|
500
|
-
|
|
575
|
+
this.state.gis.addLayer(layer);
|
|
576
|
+
this.olLayers.push({
|
|
577
|
+
address: url,
|
|
578
|
+
layer: layer
|
|
579
|
+
});
|
|
580
|
+
} // 添加geoServer图层
|
|
501
581
|
|
|
502
|
-
|
|
582
|
+
}, {
|
|
583
|
+
key: "addGeoServerLayer",
|
|
584
|
+
value: function addGeoServerLayer(_url) {
|
|
585
|
+
var exist = this.olLayers.find(function (item) {
|
|
586
|
+
return item.address === _url;
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
if (exist) {
|
|
590
|
+
exist.layer.setVisible(true);
|
|
591
|
+
return;
|
|
592
|
+
} // 矢量数据源
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
var vectorSource = new ol.source.Vector({
|
|
596
|
+
// 设置格式化类型
|
|
597
|
+
format: new ol.format.GeoJSON(),
|
|
598
|
+
// url(extent) 在地图范围变化时调用,返回当前的地图范围
|
|
599
|
+
url: function url(extent) {
|
|
600
|
+
return "".concat(_url, "&bbox=").concat(extent.join(','));
|
|
601
|
+
},
|
|
602
|
+
strategy: ol.loadingstrategy.bbox
|
|
603
|
+
}); // 矢量图层
|
|
604
|
+
|
|
605
|
+
var layer = new ol.layer.Vector({
|
|
606
|
+
// 设置数据源
|
|
607
|
+
source: vectorSource,
|
|
608
|
+
// 设置图层样式也可以 function (feature) { /** 根据内容动态加载样式 **/ return Style}
|
|
609
|
+
style: function style(feature) {
|
|
610
|
+
var _icon$;
|
|
611
|
+
|
|
612
|
+
var el = feature.A || {};
|
|
613
|
+
var icon = JSON.parse(el.icon || '[]');
|
|
614
|
+
var mapIcon = (_icon$ = icon[0]) !== null && _icon$ !== void 0 && _icon$.id ? "/cloudFile/common/downloadFile?id=".concat(icon[0].id) : require("../images/defaultMarker.png");
|
|
615
|
+
return new ol.style.Style({
|
|
616
|
+
// 点位图标
|
|
617
|
+
image: new ol.style.Icon({
|
|
618
|
+
scale: 1,
|
|
619
|
+
src: mapIcon
|
|
620
|
+
}),
|
|
621
|
+
// 线样式
|
|
622
|
+
stroke: new ol.style.Stroke({
|
|
623
|
+
color: el.color || '#1890ff',
|
|
624
|
+
width: 4
|
|
625
|
+
}),
|
|
626
|
+
// 面样式
|
|
627
|
+
fill: new ol.style.Fill({
|
|
628
|
+
color: el.color || 'rgba(255,255,255, 0.5)'
|
|
629
|
+
})
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
}); // 将图层添加到地图上
|
|
633
|
+
|
|
634
|
+
this.state.gis.addLayer(layer);
|
|
635
|
+
this.olLayers.push({
|
|
636
|
+
address: _url,
|
|
637
|
+
layer: layer
|
|
638
|
+
});
|
|
503
639
|
} // 初始化对外方法
|
|
504
640
|
|
|
505
641
|
}, {
|
|
@@ -3563,7 +3699,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3563
3699
|
isSetAreaRestriction = nextProps.isSetAreaRestriction,
|
|
3564
3700
|
areaRestriction = nextProps.areaRestriction,
|
|
3565
3701
|
isClearAreaRestriction = nextProps.isClearAreaRestriction,
|
|
3566
|
-
isClearAll = nextProps.isClearAll
|
|
3702
|
+
isClearAll = nextProps.isClearAll,
|
|
3703
|
+
olProps = nextProps.olProps; // 等待地图加载
|
|
3567
3704
|
|
|
3568
3705
|
if (!t.state.mapCreated) return;
|
|
3569
3706
|
/*点数据处理
|
|
@@ -3865,6 +4002,11 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3865
4002
|
|
|
3866
4003
|
if (nextProps.showControl && JSON.stringify(nextProps.showControl) != JSON.stringify(t.props.showControl)) {
|
|
3867
4004
|
t.showControl(nextProps);
|
|
4005
|
+
} // 更新需要加载的图层
|
|
4006
|
+
|
|
4007
|
+
|
|
4008
|
+
if (nextProps.olProps && JSON.stringify(nextProps.olProps) !== JSON.stringify(t.props.olProps)) {
|
|
4009
|
+
t.loadLayers(nextProps.olProps.olCoverage, t.props.olProps.olCoverage);
|
|
3868
4010
|
}
|
|
3869
4011
|
} // 地图事件
|
|
3870
4012
|
//地图点击事件
|
|
@@ -4077,33 +4219,32 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
4077
4219
|
}, {
|
|
4078
4220
|
key: "clickGraphic",
|
|
4079
4221
|
value: function clickGraphic(id, e) {
|
|
4080
|
-
var
|
|
4222
|
+
var target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
4223
|
+
var t = this; //编辑中的图元关闭其他事件返回
|
|
4081
4224
|
|
|
4082
|
-
if (id)
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
t.props.clickGraphic(obj);
|
|
4106
|
-
}
|
|
4225
|
+
if (t.editId == id) return false;
|
|
4226
|
+
|
|
4227
|
+
if (typeof t.props.clickGraphic === 'function') {
|
|
4228
|
+
var _e$pixel = _slicedToArray(e.pixel, 2),
|
|
4229
|
+
clientX = _e$pixel[0],
|
|
4230
|
+
clientY = _e$pixel[1];
|
|
4231
|
+
|
|
4232
|
+
var param = t.getGraphic(id, clientX, clientY);
|
|
4233
|
+
var obj = {
|
|
4234
|
+
param: param,
|
|
4235
|
+
info: target,
|
|
4236
|
+
type: param ? param.geometry.type : null,
|
|
4237
|
+
//图元类型
|
|
4238
|
+
attributes: param ? _objectSpread(_objectSpread({}, param.attributes.other), {
|
|
4239
|
+
config: param.attributes.config
|
|
4240
|
+
}) : null,
|
|
4241
|
+
//添加时图元信息
|
|
4242
|
+
top: clientY,
|
|
4243
|
+
//当前点所在的位置(屏幕)
|
|
4244
|
+
left: clientX,
|
|
4245
|
+
e: e
|
|
4246
|
+
};
|
|
4247
|
+
t.props.clickGraphic(obj);
|
|
4107
4248
|
}
|
|
4108
4249
|
}
|
|
4109
4250
|
}, {
|