@vtx/map 1.1.5 → 1.1.7-beta.0
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/README.md +44 -44
- package/lib/VtxMap/BMap/Map.js +1 -1
- package/lib/VtxMap/OMap/Map.js +43 -43
- package/lib/VtxMap/OMap/Map.less +70 -70
- package/lib/VtxMap/OlMap/Map.js +412 -101
- package/lib/VtxMap/OlMap/Map.less +121 -121
- package/lib/VtxMap/TMap/TMap.js +18 -18
- package/lib/VtxModal/VtxModal.css +0 -62
- package/lib/VtxModal/VtxModal.js +7 -9
- package/lib/VtxModal/VtxModal.less +6 -4
- package/lib/VtxModal/draggableModal.js +1 -1
- package/lib/VtxSearchMap/VtxSearchMap.css +0 -170
- package/lib/VtxSearchMap/VtxSearchMap.js +5 -5
- package/lib/VtxSearchMap/VtxSearchMap.less +14 -12
- package/lib/default.js +3 -1
- package/package.json +1 -1
package/lib/VtxMap/OlMap/Map.js
CHANGED
|
@@ -96,13 +96,26 @@ var OlMap = function (_React$Component) {
|
|
|
96
96
|
sketch: null,
|
|
97
97
|
helpTooltipElement: null,
|
|
98
98
|
helpTooltip: null,
|
|
99
|
-
deleteContent: null,
|
|
100
99
|
measureTooltipElement: null,
|
|
101
100
|
measureTooltip: null,
|
|
101
|
+
deleteToolTipElement: null,
|
|
102
102
|
deleteToolTip: null,
|
|
103
103
|
continuePolygonMsg: '点击继续绘制图形',
|
|
104
104
|
continueLineMsg: '点击继续绘制线',
|
|
105
|
-
listener: null
|
|
105
|
+
listener: null,
|
|
106
|
+
drawElements: [],
|
|
107
|
+
drawLayer: null,
|
|
108
|
+
feature: null,
|
|
109
|
+
draw: null
|
|
110
|
+
};
|
|
111
|
+
_this.clusterInfo = {
|
|
112
|
+
clickFeature: null,
|
|
113
|
+
clickResolution: null,
|
|
114
|
+
hoverFeature: null,
|
|
115
|
+
clusterSource: null,
|
|
116
|
+
clusterHulls: null,
|
|
117
|
+
clusters: null,
|
|
118
|
+
clusterCircles: null
|
|
106
119
|
};
|
|
107
120
|
_this.state = {
|
|
108
121
|
gis: null, //地图对象
|
|
@@ -142,7 +155,12 @@ var OlMap = function (_React$Component) {
|
|
|
142
155
|
resolve();
|
|
143
156
|
});
|
|
144
157
|
});
|
|
145
|
-
Promise
|
|
158
|
+
var Client9 = new Promise(function (resolve, reject) {
|
|
159
|
+
$.getScript(_default2.default.openlayerServerURL + '/iclient9-openlayers.js', function () {
|
|
160
|
+
resolve();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
Promise.all([PointCollection, Client9]).then(function () {
|
|
146
164
|
resolve(window.OlMap);
|
|
147
165
|
});
|
|
148
166
|
});
|
|
@@ -318,10 +336,10 @@ var OlMap = function (_React$Component) {
|
|
|
318
336
|
var projection = olProps.projection,
|
|
319
337
|
olCoverage = olProps.olCoverage;
|
|
320
338
|
|
|
321
|
-
if (window.
|
|
322
|
-
window.
|
|
339
|
+
if (window.VtxMap) {
|
|
340
|
+
window.VtxMap[mapId] = null;
|
|
323
341
|
} else {
|
|
324
|
-
window.
|
|
342
|
+
window.VtxMap = {};
|
|
325
343
|
}
|
|
326
344
|
if (!minZoom) {
|
|
327
345
|
minZoom = 2;
|
|
@@ -332,7 +350,7 @@ var OlMap = function (_React$Component) {
|
|
|
332
350
|
if (!projection) {
|
|
333
351
|
projection = 'EPSG:4326';
|
|
334
352
|
}
|
|
335
|
-
window.
|
|
353
|
+
window.VtxMap[mapId] = t.state.gis = new ol.Map({
|
|
336
354
|
target: mapId.toString(),
|
|
337
355
|
view: new ol.View({
|
|
338
356
|
center: mapCenter && mapCenter instanceof Array && mapCenter.length == 2 ? mapCenter : [116.400433, 39.906705], //中心点
|
|
@@ -357,14 +375,22 @@ var OlMap = function (_React$Component) {
|
|
|
357
375
|
});
|
|
358
376
|
if ((olCoverage || []).length > 0) {
|
|
359
377
|
(olCoverage || []).map(function (item) {
|
|
360
|
-
if (
|
|
361
|
-
|
|
378
|
+
if (item.coverage.startsWith("http") || item.coverage.startsWith('/')) {
|
|
379
|
+
// 超图图层
|
|
380
|
+
var _layer = new ol.layer.Tile({
|
|
381
|
+
source: new ol.source.TileSuperMapRest({
|
|
382
|
+
url: item.coverage
|
|
383
|
+
})
|
|
384
|
+
});
|
|
362
385
|
t.state.gis.addLayer(_layer);
|
|
386
|
+
} else if (OL_SCREEN[item.coverage]) {
|
|
387
|
+
var _layer2 = eval(OL_SCREEN[item.coverage].initLayer);
|
|
388
|
+
t.state.gis.addLayer(_layer2);
|
|
363
389
|
}
|
|
364
390
|
});
|
|
365
391
|
} else {
|
|
366
|
-
var
|
|
367
|
-
t.state.gis.addLayer(
|
|
392
|
+
var _layer3 = eval(OL_SCREEN.default.initLayer);
|
|
393
|
+
t.state.gis.addLayer(_layer3);
|
|
368
394
|
}
|
|
369
395
|
}
|
|
370
396
|
// 设置中心点
|
|
@@ -633,7 +659,7 @@ var OlMap = function (_React$Component) {
|
|
|
633
659
|
if ('editGraphicChange' in t.props && typeof t.props.editGraphicChange == 'function') {
|
|
634
660
|
t.props.editGraphicChange(param);
|
|
635
661
|
}
|
|
636
|
-
t.GM.setGraphic(id, feature).setGraphicParam(id, _extends({}, param));
|
|
662
|
+
t.GM.setGraphic(id, feature).setGraphicParam(id, _extends({}, param, { source: gp.source }));
|
|
637
663
|
});
|
|
638
664
|
}
|
|
639
665
|
t.editId = id;
|
|
@@ -928,28 +954,94 @@ var OlMap = function (_React$Component) {
|
|
|
928
954
|
};
|
|
929
955
|
}
|
|
930
956
|
}
|
|
931
|
-
|
|
957
|
+
/*工具方法*/
|
|
932
958
|
|
|
933
959
|
}, {
|
|
934
|
-
key: '
|
|
935
|
-
value: function
|
|
960
|
+
key: 'vtxRangingTool',
|
|
961
|
+
value: function vtxRangingTool() {
|
|
936
962
|
var t = this;
|
|
937
|
-
var
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
963
|
+
var source = new ol.source.Vector({});
|
|
964
|
+
t.rangingInfo.drawLayer = new ol.layer.Vector({
|
|
965
|
+
source: source,
|
|
966
|
+
style: new ol.style.Style({
|
|
967
|
+
fill: new ol.style.Fill({
|
|
968
|
+
color: 'rgba(255, 255, 255, 0.2)'
|
|
969
|
+
}),
|
|
970
|
+
stroke: new ol.style.Stroke({
|
|
971
|
+
color: '#ffcc33',
|
|
972
|
+
width: 4
|
|
973
|
+
}),
|
|
974
|
+
image: new ol.style.Circle({
|
|
975
|
+
radius: 7,
|
|
976
|
+
fill: new ol.style.Fill({
|
|
977
|
+
color: '#ffcc33'
|
|
978
|
+
})
|
|
979
|
+
})
|
|
980
|
+
})
|
|
981
|
+
});
|
|
982
|
+
t.rangingInfo.draw = new ol.interaction.Draw({
|
|
983
|
+
source: source,
|
|
984
|
+
type: 'LineString',
|
|
985
|
+
style: new ol.style.Style({
|
|
986
|
+
fill: new ol.style.Fill({
|
|
987
|
+
color: 'rgba(255, 255, 255, 0.2)'
|
|
988
|
+
}),
|
|
989
|
+
stroke: new ol.style.Stroke({
|
|
990
|
+
color: 'rgba(0, 0, 0, 0.5)',
|
|
991
|
+
lineDash: [10, 10],
|
|
992
|
+
width: 4
|
|
993
|
+
}),
|
|
994
|
+
image: new ol.style.Circle({
|
|
995
|
+
radius: 5,
|
|
996
|
+
stroke: new ol.style.Stroke({
|
|
997
|
+
color: 'rgba(0, 0, 0, 0.7)'
|
|
998
|
+
}),
|
|
999
|
+
fill: new ol.style.Fill({
|
|
1000
|
+
color: 'rgba(255, 255, 255, 0.2)'
|
|
1001
|
+
})
|
|
1002
|
+
})
|
|
1003
|
+
})
|
|
1004
|
+
});
|
|
1005
|
+
var obj = {};
|
|
1006
|
+
t.createHelpTooltip();
|
|
1007
|
+
t.createMeasureTooltip();
|
|
1008
|
+
t.createDeleteTooltip();
|
|
1009
|
+
t.state.gis.addLayer(t.rangingInfo.drawLayer);
|
|
1010
|
+
t.state.gis.addInteraction(t.rangingInfo.draw);
|
|
1011
|
+
// 开始监听绘制
|
|
1012
|
+
t.rangingInfo.draw.on('drawstart', function (evt) {
|
|
1013
|
+
t.rangingInfo.feature = evt.feature;
|
|
1014
|
+
var tooltipCoord = evt.coordinate;
|
|
1015
|
+
t.rangingInfo.listener = evt.feature.getGeometry().on('change', function (evt) {
|
|
1016
|
+
var geom = evt.target;
|
|
1017
|
+
var flatCoordinates = geom.flatCoordinates;
|
|
1018
|
+
|
|
1019
|
+
var lngLats = [[flatCoordinates[0], flatCoordinates[1]], [flatCoordinates[2], flatCoordinates[3]]];
|
|
1020
|
+
var output = t.formatLength(geom);
|
|
1021
|
+
tooltipCoord = geom.getLastCoordinate();
|
|
1022
|
+
obj = {
|
|
1023
|
+
distance: output,
|
|
1024
|
+
lnglats: lngLats
|
|
1025
|
+
};
|
|
1026
|
+
t.rangingInfo.measureTooltipElement.innerHTML = output;
|
|
1027
|
+
t.rangingInfo.measureTooltip.setPosition(tooltipCoord);
|
|
1028
|
+
t.rangingInfo.deleteToolTip.setPosition(tooltipCoord);
|
|
1029
|
+
t.rangingInfo.deleteToolTip.setOffset([20, 10]);
|
|
1030
|
+
});
|
|
1031
|
+
});
|
|
1032
|
+
// 双击绘制完成
|
|
1033
|
+
t.rangingInfo.draw.on('drawend', function () {
|
|
1034
|
+
t.rangingInfo.measureTooltipElement.className = 'ol-tooltip ol-tooltip-static';
|
|
1035
|
+
t.rangingInfo.measureTooltip.setOffset([0, -7]);
|
|
1036
|
+
t.rangingInfo.feature = null;
|
|
1037
|
+
t.rangingInfo.measureTooltipElement = null;
|
|
1038
|
+
// t.createMeasureTooltip();
|
|
1039
|
+
new ol.Observable.unByKey(t.rangingInfo.listener);
|
|
1040
|
+
t.state.gis.removeInteraction(t.rangingInfo.draw);
|
|
1041
|
+
if ('mapRangingTool' in t.props) {
|
|
1042
|
+
t.props.mapRangingTool(obj);
|
|
1043
|
+
}
|
|
951
1044
|
});
|
|
952
|
-
gis.addOverlay(drawInfo.measureTooltip);
|
|
953
1045
|
}
|
|
954
1046
|
// 绘图时创建提示
|
|
955
1047
|
|
|
@@ -957,42 +1049,88 @@ var OlMap = function (_React$Component) {
|
|
|
957
1049
|
key: 'createHelpTooltip',
|
|
958
1050
|
value: function createHelpTooltip() {
|
|
959
1051
|
var t = this;
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
if (drawInfo.helpTooltipElement) {
|
|
964
|
-
drawInfo.helpTooltipElement.parentNode.removeChild(helpTooltipElement);
|
|
1052
|
+
if (t.rangingTool.helpTooltipElement) {
|
|
1053
|
+
t.rangingTool.helpTooltipElement.parentNode.removeChild(t.rangingTool.helpTooltipElement);
|
|
965
1054
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
element:
|
|
1055
|
+
t.rangingTool.helpTooltipElement = document.createElement('div');
|
|
1056
|
+
t.rangingTool.helpTooltipElement.className = 'ol-tooltip hidden';
|
|
1057
|
+
t.rangingTool.helpTooltip = new ol.Overlay({
|
|
1058
|
+
element: t.rangingTool.helpTooltipElement,
|
|
970
1059
|
offset: [15, 0],
|
|
971
1060
|
positioning: 'center-left'
|
|
972
1061
|
});
|
|
973
|
-
gis.addOverlay(
|
|
1062
|
+
t.state.gis.addOverlay(t.rangingTool.helpTooltip);
|
|
974
1063
|
}
|
|
975
|
-
|
|
1064
|
+
// 工具画图提示
|
|
976
1065
|
|
|
977
1066
|
}, {
|
|
978
|
-
key: '
|
|
979
|
-
value: function
|
|
1067
|
+
key: 'createMeasureTooltip',
|
|
1068
|
+
value: function createMeasureTooltip() {
|
|
980
1069
|
var t = this;
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
//开启测距状态
|
|
984
|
-
if (!t.rangingTool.isRanging) {
|
|
985
|
-
t.rangingTool.isRanging = true;
|
|
986
|
-
}
|
|
987
|
-
//初始测距回调
|
|
988
|
-
if (!t.rangingTool.mapRangingTool) {
|
|
989
|
-
t.rangingTool.mapRangingTool = mapRangingTool;
|
|
1070
|
+
if (t.rangingInfo.measureTooltipElement) {
|
|
1071
|
+
t.rangingInfo.measureTooltipElement.parentNode.removeChild(t.rangingInfo.measureTooltipElement);
|
|
990
1072
|
}
|
|
1073
|
+
t.rangingInfo.measureTooltipElement = document.createElement('div');
|
|
1074
|
+
t.rangingInfo.measureTooltipElement.className = 'ol-tooltip ol-tooltip-measure';
|
|
1075
|
+
t.rangingInfo.measureTooltip = new ol.Overlay({
|
|
1076
|
+
element: t.rangingInfo.measureTooltipElement,
|
|
1077
|
+
offset: [0, -15],
|
|
1078
|
+
positioning: 'bottom-center',
|
|
1079
|
+
stopEvent: false,
|
|
1080
|
+
insertFirst: false
|
|
1081
|
+
});
|
|
1082
|
+
t.state.gis.addOverlay(t.rangingInfo.measureTooltip);
|
|
991
1083
|
}
|
|
992
|
-
//
|
|
1084
|
+
// 创建删除提示
|
|
1085
|
+
|
|
1086
|
+
}, {
|
|
1087
|
+
key: 'createDeleteTooltip',
|
|
1088
|
+
value: function createDeleteTooltip() {
|
|
1089
|
+
var t = this;
|
|
1090
|
+
if (t.rangingInfo.deleteToolTipElement) {
|
|
1091
|
+
t.rangingInfo.deleteToolTipElement.parentNode.removeChild(t.rangingInfo.deleteToolTipElement);
|
|
1092
|
+
}
|
|
1093
|
+
t.rangingInfo.deleteToolTipElement = document.createElement('div');
|
|
1094
|
+
t.rangingInfo.deleteToolTipElement.className = 'ol-tooltip-delete';
|
|
1095
|
+
t.rangingInfo.deleteToolTipElement.innerHTML = 'X';
|
|
1096
|
+
t.rangingInfo.deleteToolTipElement.addEventListener('click', function (e) {
|
|
1097
|
+
t.rangingInfo.measureTooltipElement = null;
|
|
1098
|
+
t.rangingInfo.helpTooltipElement = null;
|
|
1099
|
+
t.rangingInfo.deleteToolTipElement = null;
|
|
1100
|
+
t.state.gis.removeOverlay(t.rangingInfo.measureTooltip);
|
|
1101
|
+
t.state.gis.removeOverlay(t.rangingTool.helpTooltip);
|
|
1102
|
+
t.state.gis.removeOverlay(t.rangingInfo.deleteToolTip);
|
|
1103
|
+
new ol.Observable.unByKey(t.rangingInfo.listener);
|
|
1104
|
+
t.state.gis.removeInteraction(t.rangingInfo.draw);
|
|
1105
|
+
t.state.gis.removeLayer(t.rangingInfo.drawLayer);
|
|
1106
|
+
});
|
|
1107
|
+
t.rangingInfo.deleteToolTip = new ol.Overlay({
|
|
1108
|
+
element: t.rangingInfo.deleteToolTipElement,
|
|
1109
|
+
offset: [15, 15],
|
|
1110
|
+
positioning: 'bottom-center',
|
|
1111
|
+
stopEvent: false,
|
|
1112
|
+
insertFirst: true
|
|
1113
|
+
});
|
|
1114
|
+
t.state.gis.addOverlay(t.rangingInfo.deleteToolTip);
|
|
1115
|
+
}
|
|
1116
|
+
}, {
|
|
1117
|
+
key: 'formatLength',
|
|
1118
|
+
value: function formatLength(line) {
|
|
1119
|
+
var flatCoordinates = line.flatCoordinates;
|
|
993
1120
|
|
|
1121
|
+
var length = new ol.sphere.getDistance([flatCoordinates[0], flatCoordinates[1]], [flatCoordinates[2], flatCoordinates[3]]);
|
|
1122
|
+
var output = '';
|
|
1123
|
+
if (length > 100) {
|
|
1124
|
+
output = Math.round(length / 1000 * 100) / 100 + ' ' + 'km';
|
|
1125
|
+
} else {
|
|
1126
|
+
output = Math.round(length * 100) / 100 + ' ' + 'm';
|
|
1127
|
+
}
|
|
1128
|
+
return output;
|
|
1129
|
+
}
|
|
994
1130
|
}, {
|
|
995
1131
|
key: 'getMapExtent',
|
|
1132
|
+
|
|
1133
|
+
// 获取地图的当前位置状态信息
|
|
996
1134
|
value: function getMapExtent() {
|
|
997
1135
|
var t = this;
|
|
998
1136
|
var gis = t.state.gis;
|
|
@@ -1022,10 +1160,10 @@ var OlMap = function (_React$Component) {
|
|
|
1022
1160
|
}
|
|
1023
1161
|
}
|
|
1024
1162
|
//将制定图元展示在视野内 (强制改变地图中心位置)
|
|
1025
|
-
/*
|
|
1026
|
-
参数arg格式如下1,2
|
|
1027
|
-
1.string 格式如:'1,a,2,3,4'
|
|
1028
|
-
2.数组 ['1','2']
|
|
1163
|
+
/*
|
|
1164
|
+
参数arg格式如下1,2
|
|
1165
|
+
1.string 格式如:'1,a,2,3,4'
|
|
1166
|
+
2.数组 ['1','2']
|
|
1029
1167
|
*/
|
|
1030
1168
|
|
|
1031
1169
|
}, {
|
|
@@ -1060,28 +1198,31 @@ var OlMap = function (_React$Component) {
|
|
|
1060
1198
|
}
|
|
1061
1199
|
if (typeof arg === 'string') {
|
|
1062
1200
|
ary = arg.split(',');
|
|
1063
|
-
obj = t.getFitView(ary);
|
|
1064
1201
|
} else if (arg instanceof Array) {
|
|
1065
|
-
|
|
1066
|
-
obj = gis.getFitView(ary[0]);
|
|
1067
|
-
} else {
|
|
1068
|
-
obj = t.getFitView(arg);
|
|
1069
|
-
}
|
|
1202
|
+
ary = arg;
|
|
1070
1203
|
}
|
|
1071
|
-
|
|
1072
|
-
|
|
1204
|
+
for (var i = 0; i < ary.length; i++) {
|
|
1205
|
+
var g = t.GM.getGraphicParam(ary[i]);
|
|
1206
|
+
if (g) {
|
|
1207
|
+
switch (g.geometry.type) {
|
|
1208
|
+
case 'point':
|
|
1209
|
+
obj.push([g.geometry.x, g.geometry.y]);
|
|
1210
|
+
case 'circle':
|
|
1211
|
+
obj.push([g.geometry.x, g.geometry.y]);
|
|
1212
|
+
break;
|
|
1213
|
+
case 'polyline':
|
|
1214
|
+
obj = [].concat(_toConsumableArray(obj), _toConsumableArray(g.geometry.paths));
|
|
1215
|
+
break;
|
|
1216
|
+
case 'polygon':
|
|
1217
|
+
obj = [].concat(_toConsumableArray(obj), _toConsumableArray(g.geometry.rings));
|
|
1218
|
+
break;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1073
1221
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
gis.getView().fit(
|
|
1222
|
+
if (obj.length > 0) {
|
|
1223
|
+
var displayRange = new ol.extent.boundingExtent(obj);
|
|
1224
|
+
gis.getView().fit(displayRange, gis.getSize());
|
|
1077
1225
|
}
|
|
1078
|
-
// if(!type || type == 'all'){
|
|
1079
|
-
|
|
1080
|
-
// }else if(type == 'zoom'){
|
|
1081
|
-
// gis.getView().setZoom(zoom)
|
|
1082
|
-
// }else if(type == 'center'){
|
|
1083
|
-
// gis.getView().setCenter(obj.lngLat);
|
|
1084
|
-
// }
|
|
1085
1226
|
}
|
|
1086
1227
|
}, {
|
|
1087
1228
|
key: 'getFitView',
|
|
@@ -1340,6 +1481,7 @@ var OlMap = function (_React$Component) {
|
|
|
1340
1481
|
var t = this;
|
|
1341
1482
|
var ps = [];
|
|
1342
1483
|
var psids = [].concat(_toConsumableArray(t.state.pointIds));
|
|
1484
|
+
console.log('addPoint', mapPoints);
|
|
1343
1485
|
mapPoints.map(function (item, index) {
|
|
1344
1486
|
//如果id重复,直接跳过不执行.
|
|
1345
1487
|
if (_this2.GM.isRepetition(item.id)) {
|
|
@@ -1484,6 +1626,7 @@ var OlMap = function (_React$Component) {
|
|
|
1484
1626
|
var mapPoints = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1485
1627
|
|
|
1486
1628
|
var t = this;
|
|
1629
|
+
console.log('updatePoint', mapPoints);
|
|
1487
1630
|
mapPoints.map(function (item, index) {
|
|
1488
1631
|
//判断图元是否存在.
|
|
1489
1632
|
if (_this3.GM.isRepetition(item.id)) {
|
|
@@ -1493,6 +1636,7 @@ var OlMap = function (_React$Component) {
|
|
|
1493
1636
|
return false;
|
|
1494
1637
|
}
|
|
1495
1638
|
var gc = t.GM.getGraphic(item.id);
|
|
1639
|
+
var gp = t.GM.getGraphicParam(item.id);
|
|
1496
1640
|
var cg = {
|
|
1497
1641
|
width: 30,
|
|
1498
1642
|
height: 30,
|
|
@@ -1569,7 +1713,7 @@ var OlMap = function (_React$Component) {
|
|
|
1569
1713
|
x: item.longitude,
|
|
1570
1714
|
y: item.latitude
|
|
1571
1715
|
},
|
|
1572
|
-
source:
|
|
1716
|
+
source: gp.source
|
|
1573
1717
|
});
|
|
1574
1718
|
} else {
|
|
1575
1719
|
console.warn('\u66F4\u65B0\u7684\u70B9\u4F4Did\u4E0D\u5B58\u5728!');
|
|
@@ -1820,6 +1964,7 @@ var OlMap = function (_React$Component) {
|
|
|
1820
1964
|
}
|
|
1821
1965
|
//获取原有的图元
|
|
1822
1966
|
var gc = _this7.GM.getGraphic(item.id);
|
|
1967
|
+
var gp = t.GM.getGraphicParam(item.id);
|
|
1823
1968
|
//获取原有的面属性,转换key值
|
|
1824
1969
|
var cg = {
|
|
1825
1970
|
lineType: 'solid',
|
|
@@ -1857,7 +2002,7 @@ var OlMap = function (_React$Component) {
|
|
|
1857
2002
|
type: 'polygon',
|
|
1858
2003
|
rings: pts
|
|
1859
2004
|
},
|
|
1860
|
-
source:
|
|
2005
|
+
source: gp.source
|
|
1861
2006
|
});
|
|
1862
2007
|
} else {
|
|
1863
2008
|
console.warn('\u66F4\u65B0\u7684\u591A\u8FB9\u5F62id\u4E0D\u5B58\u5728!');
|
|
@@ -1968,6 +2113,7 @@ var OlMap = function (_React$Component) {
|
|
|
1968
2113
|
}
|
|
1969
2114
|
//获取原有的图元
|
|
1970
2115
|
var gc = t.GM.getGraphic(item.id);
|
|
2116
|
+
var gp = t.GM.getGraphicParam(item.id);
|
|
1971
2117
|
//获取原有的面属性,转换key值
|
|
1972
2118
|
var cg = {
|
|
1973
2119
|
lineType: 'solid',
|
|
@@ -2003,7 +2149,7 @@ var OlMap = function (_React$Component) {
|
|
|
2003
2149
|
y: parseFloat(item.latitude),
|
|
2004
2150
|
radius: parseFloat(item.radius)
|
|
2005
2151
|
},
|
|
2006
|
-
source:
|
|
2152
|
+
source: gp.source
|
|
2007
2153
|
});
|
|
2008
2154
|
});
|
|
2009
2155
|
//刷新图元
|
|
@@ -2113,11 +2259,28 @@ var OlMap = function (_React$Component) {
|
|
|
2113
2259
|
return item.name == 'heatMap';
|
|
2114
2260
|
})[0];
|
|
2115
2261
|
hMap.getSource().clear();
|
|
2116
|
-
|
|
2262
|
+
gis.removeLayer(layer);
|
|
2117
2263
|
}
|
|
2118
2264
|
t.heatmap = null;
|
|
2119
2265
|
t.movePoints = [];
|
|
2266
|
+
t.pointLayers.map(function (item) {
|
|
2267
|
+
gis.removeLayer(item);
|
|
2268
|
+
t.pointLayers = [];
|
|
2269
|
+
});
|
|
2120
2270
|
t.clearAllPointCollection();
|
|
2271
|
+
t.closeDraw();
|
|
2272
|
+
if (t.clusterInfo.clusterHulls || t.clusterInfo.clusters || t.clusterInfo.clusterCircles) {
|
|
2273
|
+
t.clusterHulls.getSource().clear();
|
|
2274
|
+
t.clusterInfo.clusterSource = null;
|
|
2275
|
+
gis.removeLayer(t.clusterInfo.clusterHulls);
|
|
2276
|
+
gis.removeLayer(t.clusterInfo.clusters);
|
|
2277
|
+
gis.removeLayer(t.clusterInfo.clusterCircles);
|
|
2278
|
+
t.clusterInfo.clusterHulls = null;
|
|
2279
|
+
t.clusterInfo.clusters = null;
|
|
2280
|
+
t.clusterInfo.clusterCircles = null;
|
|
2281
|
+
}
|
|
2282
|
+
//清空缓存数据
|
|
2283
|
+
t.GM.clearAll();
|
|
2121
2284
|
//循环所有id删除
|
|
2122
2285
|
var _t$state = t.state,
|
|
2123
2286
|
pointIds = _t$state.pointIds,
|
|
@@ -2249,6 +2412,152 @@ var OlMap = function (_React$Component) {
|
|
|
2249
2412
|
if (y > ymax1) y = ymax1 - 0.1;
|
|
2250
2413
|
t.state.gis.getView().setCenter([x, y]);
|
|
2251
2414
|
}
|
|
2415
|
+
//聚合地图图元(arg为空时聚合全部点)
|
|
2416
|
+
|
|
2417
|
+
}, {
|
|
2418
|
+
key: 'cluster',
|
|
2419
|
+
value: function cluster(arg) {
|
|
2420
|
+
var t = this;
|
|
2421
|
+
var ary = [];
|
|
2422
|
+
if (!arg) {
|
|
2423
|
+
var pointIds = t.state.pointIds;
|
|
2424
|
+
|
|
2425
|
+
ary = pointIds;
|
|
2426
|
+
} else {
|
|
2427
|
+
if (Object.prototype.toString.apply(arg) === '[object Array]') {
|
|
2428
|
+
ary = arg;
|
|
2429
|
+
} else if (typeof arg === 'string') {
|
|
2430
|
+
ary = arg.split(',');
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
t.pointLayers.map(function (item) {
|
|
2434
|
+
t.state.gis.removeLayer(item.layer);
|
|
2435
|
+
t.pointLayers = [];
|
|
2436
|
+
});
|
|
2437
|
+
var ms = this.GM.getMoreGraphic(ary).filter(function (item, index) {
|
|
2438
|
+
// return !item && item != 0 ? false : true;
|
|
2439
|
+
return item && item.getGeometry().getType() === 'Point' && !item.label;
|
|
2440
|
+
});
|
|
2441
|
+
var source = new ol.source.Vector({
|
|
2442
|
+
features: ms
|
|
2443
|
+
});
|
|
2444
|
+
t.clusterInfo.clusterSource = new ol.source.Cluster({
|
|
2445
|
+
distance: 80,
|
|
2446
|
+
minDistance: 0,
|
|
2447
|
+
source: source
|
|
2448
|
+
});
|
|
2449
|
+
t.clusterInfo.clusterHulls = new ol.layer.Vector({
|
|
2450
|
+
source: t.clusterInfo.clusterSource,
|
|
2451
|
+
style: clusterHullStyle
|
|
2452
|
+
});
|
|
2453
|
+
t.state.gis.addLayer(t.clusterInfo.clusterHulls);
|
|
2454
|
+
t.clusterInfo.clusters = new ol.layer.Vector({
|
|
2455
|
+
source: t.clusterInfo.clusterSource,
|
|
2456
|
+
style: clusterStyle
|
|
2457
|
+
});
|
|
2458
|
+
t.state.gis.addLayer(t.clusterInfo.clusters);
|
|
2459
|
+
t.clusterInfo.clusterCircles = new ol.layer.Vector({
|
|
2460
|
+
source: t.clusterInfo.clusterSource,
|
|
2461
|
+
style: clusterCircleStyle
|
|
2462
|
+
});
|
|
2463
|
+
t.state.gis.addLayer(t.clusterInfo.clusterCircles);
|
|
2464
|
+
function clusterMemberStyle(clusterMember) {
|
|
2465
|
+
var style = clusterMember.getStyle();
|
|
2466
|
+
var image = style.getImage();
|
|
2467
|
+
return new ol.style.Style({
|
|
2468
|
+
geometry: clusterMember.getGeometry(),
|
|
2469
|
+
image: image
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2472
|
+
function clusterCircleStyle(cluster, resolution) {
|
|
2473
|
+
if (cluster !== t.clusterInfo.clickFeature || resolution !== t.clusterInfo.clickResolution) {
|
|
2474
|
+
return;
|
|
2475
|
+
}
|
|
2476
|
+
var clusterMembers = cluster.get('features');
|
|
2477
|
+
var centerCoordinates = cluster.getGeometry().getCoordinates();
|
|
2478
|
+
return generatePointsCircle(clusterMembers.length, cluster.getGeometry().getCoordinates(), resolution).reduce(function (styles, coordinates, i) {
|
|
2479
|
+
var point = new ol.geom.Point(coordinates);
|
|
2480
|
+
var line = new ol.geom.LineString([centerCoordinates, coordinates]);
|
|
2481
|
+
styles.unshift(new ol.style.Style({
|
|
2482
|
+
geometry: line,
|
|
2483
|
+
stroke: new ol.style.Stroke({
|
|
2484
|
+
color: 'rgba(204, 85, 0, 1)',
|
|
2485
|
+
width: 1.5
|
|
2486
|
+
})
|
|
2487
|
+
}));
|
|
2488
|
+
styles.push(clusterMemberStyle(new ol.Feature(_extends({}, clusterMembers[i].getProperties(), {
|
|
2489
|
+
geometry: point
|
|
2490
|
+
}))));
|
|
2491
|
+
return styles;
|
|
2492
|
+
}, []);
|
|
2493
|
+
}
|
|
2494
|
+
function generatePointsCircle(count, clusterCenter, resolution) {
|
|
2495
|
+
var circumference = 1 * 28 * (2 + count);
|
|
2496
|
+
var legLength = circumference / (Math.PI * 2); //radius from circumference
|
|
2497
|
+
var angleStep = Math.PI * 2 / count;
|
|
2498
|
+
var res = [];
|
|
2499
|
+
var angle = void 0;
|
|
2500
|
+
legLength = Math.max(legLength, 35) * resolution; // Minimum distance to get outside the cluster icon.
|
|
2501
|
+
for (var i = 0; i < count; ++i) {
|
|
2502
|
+
// Clockwise, like spiral.
|
|
2503
|
+
angle = Math.PI / 2 + i * angleStep;
|
|
2504
|
+
res.push([clusterCenter[0] + legLength * Math.cos(angle), clusterCenter[1] + legLength * Math.sin(angle)]);
|
|
2505
|
+
}
|
|
2506
|
+
return res;
|
|
2507
|
+
}
|
|
2508
|
+
function clusterHullStyle(cluster) {
|
|
2509
|
+
if (cluster !== t.clusterInfo.hoverFeature) {
|
|
2510
|
+
return;
|
|
2511
|
+
}
|
|
2512
|
+
var originalFeatures = cluster.get('features');
|
|
2513
|
+
var points = originalFeatures.map(function (feature) {
|
|
2514
|
+
return feature.getGeometry().getCoordinates();
|
|
2515
|
+
});
|
|
2516
|
+
return new ol.style.Style({
|
|
2517
|
+
geometry: new ol.geom.Polygon(points),
|
|
2518
|
+
fill: new ol.style.Fill({
|
|
2519
|
+
color: 'rgba(255, 153, 0, 0.4)'
|
|
2520
|
+
}),
|
|
2521
|
+
stroke: new ol.style.Stroke({
|
|
2522
|
+
color: 'rgba(204, 85, 0, 1)',
|
|
2523
|
+
width: 1.5
|
|
2524
|
+
})
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
function clusterStyle(feature) {
|
|
2528
|
+
var size = feature.get('features').length;
|
|
2529
|
+
if (size > 1) {
|
|
2530
|
+
return [new ol.style.Style({
|
|
2531
|
+
image: new ol.style.Circle({
|
|
2532
|
+
radius: 20,
|
|
2533
|
+
fill: new ol.style.Fill({
|
|
2534
|
+
color: 'rgba(255, 153, 102, 0.3)'
|
|
2535
|
+
})
|
|
2536
|
+
})
|
|
2537
|
+
}), new ol.style.Style({
|
|
2538
|
+
image: new ol.style.Circle({
|
|
2539
|
+
radius: 14,
|
|
2540
|
+
fill: new ol.style.Fill({
|
|
2541
|
+
color: 'rgba(255, 165, 0, 0.7)'
|
|
2542
|
+
})
|
|
2543
|
+
}),
|
|
2544
|
+
text: new ol.style.Text({
|
|
2545
|
+
text: size.toString(),
|
|
2546
|
+
fill: new ol.style.Fill({
|
|
2547
|
+
color: '#fff'
|
|
2548
|
+
}),
|
|
2549
|
+
stroke: new ol.style.Stroke({
|
|
2550
|
+
color: 'rgba(0, 0, 0, 0.6)',
|
|
2551
|
+
width: 3
|
|
2552
|
+
})
|
|
2553
|
+
})
|
|
2554
|
+
})];
|
|
2555
|
+
} else {
|
|
2556
|
+
var originalFeature = feature.get('features')[0];
|
|
2557
|
+
return clusterMemberStyle(originalFeature);
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2252
2561
|
/*公共方法*/
|
|
2253
2562
|
//判断extent1是否在extent2内部
|
|
2254
2563
|
|
|
@@ -2284,7 +2593,7 @@ var OlMap = function (_React$Component) {
|
|
|
2284
2593
|
}, {
|
|
2285
2594
|
key: 'calculatePointsDistance',
|
|
2286
2595
|
value: function calculatePointsDistance(fp, ep) {
|
|
2287
|
-
return Math.round(ol.sphere.getDistance(fp, ep));
|
|
2596
|
+
return Math.round(new ol.sphere.getDistance(fp, ep));
|
|
2288
2597
|
}
|
|
2289
2598
|
//计算多个点的距离(常用于线计算)
|
|
2290
2599
|
|
|
@@ -2695,11 +3004,13 @@ var OlMap = function (_React$Component) {
|
|
|
2695
3004
|
// 等待地图加载
|
|
2696
3005
|
|
|
2697
3006
|
if (!t.state.mapCreated) return;
|
|
2698
|
-
/*点数据处理
|
|
2699
|
-
pointData[2]相同的点,执行刷新
|
|
2700
|
-
pointData[1]的数据在idsForGraphicId中不存在的,执行新增
|
|
2701
|
-
pointData[0]数据中多余的id,执行删除
|
|
3007
|
+
/*点数据处理
|
|
3008
|
+
pointData[2]相同的点,执行刷新
|
|
3009
|
+
pointData[1]的数据在idsForGraphicId中不存在的,执行新增
|
|
3010
|
+
pointData[0]数据中多余的id,执行删除
|
|
2702
3011
|
*/
|
|
3012
|
+
console.log(mapPoints, t.props.mapPoints);
|
|
3013
|
+
console.log(!t.deepEqual(mapPoints, t.props.mapPoints));
|
|
2703
3014
|
if (mapPoints instanceof Array && t.props.mapPoints instanceof Array && !t.deepEqual(mapPoints, t.props.mapPoints)) {
|
|
2704
3015
|
var oldMapPoints = t.props.mapPoints;
|
|
2705
3016
|
var newMapPoints = mapPoints;
|
|
@@ -2758,9 +3069,9 @@ var OlMap = function (_React$Component) {
|
|
|
2758
3069
|
//更新
|
|
2759
3070
|
t.updatePoint([].concat(_toConsumableArray(upds), _toConsumableArray(otherupds)));
|
|
2760
3071
|
}
|
|
2761
|
-
/*
|
|
2762
|
-
线数据处理
|
|
2763
|
-
先全删除,再新增
|
|
3072
|
+
/*
|
|
3073
|
+
线数据处理
|
|
3074
|
+
先全删除,再新增
|
|
2764
3075
|
*/
|
|
2765
3076
|
if (mapLines instanceof Array && t.props.mapLines instanceof Array && !t.deepEqual(mapLines, t.props.mapLines)) {
|
|
2766
3077
|
var oldMapLines = t.props.mapLines;
|
|
@@ -2819,9 +3130,9 @@ var OlMap = function (_React$Component) {
|
|
|
2819
3130
|
//更新
|
|
2820
3131
|
t.updateLine([].concat(_toConsumableArray(_upds), _toConsumableArray(_otherupds)));
|
|
2821
3132
|
}
|
|
2822
|
-
/*
|
|
2823
|
-
面数据处理
|
|
2824
|
-
先全删除,再新增
|
|
3133
|
+
/*
|
|
3134
|
+
面数据处理
|
|
3135
|
+
先全删除,再新增
|
|
2825
3136
|
*/
|
|
2826
3137
|
if (mapPolygons instanceof Array && t.props.mapPolygons instanceof Array && !t.deepEqual(mapPolygons, t.props.mapPolygons)) {
|
|
2827
3138
|
var oldMapPolygons = t.props.mapPolygons;
|
|
@@ -2880,9 +3191,9 @@ var OlMap = function (_React$Component) {
|
|
|
2880
3191
|
//更新
|
|
2881
3192
|
t.updatePolygon([].concat(_toConsumableArray(_upds2), _toConsumableArray(_otherupds2)));
|
|
2882
3193
|
}
|
|
2883
|
-
/*
|
|
2884
|
-
圆数据处理
|
|
2885
|
-
先全删除,再新增
|
|
3194
|
+
/*
|
|
3195
|
+
圆数据处理
|
|
3196
|
+
先全删除,再新增
|
|
2886
3197
|
*/
|
|
2887
3198
|
if (mapCircles instanceof Array && t.props.mapCircles instanceof Array && !t.deepEqual(mapCircles, t.props.mapCircles)) {
|
|
2888
3199
|
var oldMapCircles = t.props.mapCircles;
|
|
@@ -3038,8 +3349,8 @@ var OlMap = function (_React$Component) {
|
|
|
3038
3349
|
e: e,
|
|
3039
3350
|
id: id,
|
|
3040
3351
|
param: t.getGraphic(id),
|
|
3041
|
-
top: e.
|
|
3042
|
-
left: e.
|
|
3352
|
+
top: e.pixel ? e.pixel[0] : undefined, //当前点所在的位置(屏幕)
|
|
3353
|
+
left: e.pixel ? e.pixel[1] : undefined
|
|
3043
3354
|
};
|
|
3044
3355
|
t.props.mouseOverGraphic(obj);
|
|
3045
3356
|
}
|
|
@@ -3057,8 +3368,8 @@ var OlMap = function (_React$Component) {
|
|
|
3057
3368
|
e: e,
|
|
3058
3369
|
id: id,
|
|
3059
3370
|
param: t.getGraphic(id),
|
|
3060
|
-
top: e.
|
|
3061
|
-
left: e.
|
|
3371
|
+
top: e.pixel ? e.pixel[0] : undefined, //当前点所在的位置(屏幕)
|
|
3372
|
+
left: e.pixel ? e.pixel[1] : undefined
|
|
3062
3373
|
};
|
|
3063
3374
|
t.props.mouseOutGraphic(obj);
|
|
3064
3375
|
}
|
|
@@ -3201,9 +3512,9 @@ var OlMap = function (_React$Component) {
|
|
|
3201
3512
|
//编辑中的图元关闭其他事件返回
|
|
3202
3513
|
if (t.editId == id) return false;
|
|
3203
3514
|
if (typeof t.props.clickGraphic === 'function') {
|
|
3204
|
-
var _e$
|
|
3205
|
-
clientX = _e$
|
|
3206
|
-
clientY = _e$
|
|
3515
|
+
var _e$pixel = _slicedToArray(e.pixel, 2),
|
|
3516
|
+
clientX = _e$pixel[0],
|
|
3517
|
+
clientY = _e$pixel[1];
|
|
3207
3518
|
|
|
3208
3519
|
var param = t.getGraphic(id, clientX, clientY);
|
|
3209
3520
|
var obj = {
|
|
@@ -3232,7 +3543,7 @@ var OlMap = function (_React$Component) {
|
|
|
3232
3543
|
clearInterval(t.animTimer[j]);
|
|
3233
3544
|
}
|
|
3234
3545
|
}
|
|
3235
|
-
window.
|
|
3546
|
+
window.VtxMap[t.state.mapId] = null;
|
|
3236
3547
|
}
|
|
3237
3548
|
}]);
|
|
3238
3549
|
|