@vtx/map 1.1.12 → 1.1.15
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/OlMap/Map.js
CHANGED
|
@@ -446,13 +446,15 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
446
446
|
|
|
447
447
|
if (!projection) {
|
|
448
448
|
projection = 'EPSG:4326';
|
|
449
|
-
}
|
|
449
|
+
} //中心点
|
|
450
|
+
|
|
450
451
|
|
|
452
|
+
var center = mapCenter && mapCenter instanceof Array && mapCenter.length == 2 ? mapCenter : [116.400433, 39.906705];
|
|
453
|
+
center = [parseFloat(center[0]), parseFloat(center[1])];
|
|
451
454
|
window.VtxMap[mapId] = t.state.gis = new ol.Map({
|
|
452
455
|
target: mapId.toString(),
|
|
453
456
|
view: new ol.View({
|
|
454
|
-
center:
|
|
455
|
-
//中心点
|
|
457
|
+
center: center,
|
|
456
458
|
zoom: mapZoomLevel || 10,
|
|
457
459
|
projection: projection,
|
|
458
460
|
minZoom: minZoom,
|
|
@@ -466,8 +468,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
466
468
|
}); // 基本地图视图
|
|
467
469
|
|
|
468
470
|
t.viewer = new ol.View({
|
|
469
|
-
center:
|
|
470
|
-
//中心点
|
|
471
|
+
center: center,
|
|
471
472
|
zoom: mapZoomLevel || 10,
|
|
472
473
|
projection: projection,
|
|
473
474
|
minZoom: minZoom,
|
|
@@ -868,6 +869,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
868
869
|
scale: drawParam.parameter.scale || 1
|
|
869
870
|
})
|
|
870
871
|
});
|
|
872
|
+
var geometryFunction;
|
|
871
873
|
|
|
872
874
|
switch (drawParam.geometryType) {
|
|
873
875
|
case 'point':
|
|
@@ -909,6 +911,11 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
909
911
|
});
|
|
910
912
|
break;
|
|
911
913
|
|
|
914
|
+
case 'rectangle':
|
|
915
|
+
type = 'Circle';
|
|
916
|
+
geometryFunction = ol.interaction.Draw.createBox();
|
|
917
|
+
break;
|
|
918
|
+
|
|
912
919
|
case 'circle':
|
|
913
920
|
type = 'Circle';
|
|
914
921
|
style = new ol.style.Style({
|
|
@@ -927,7 +934,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
927
934
|
if (!t.drawToolbar) {
|
|
928
935
|
t.drawToolbar = new ol.interaction.Draw({
|
|
929
936
|
source: t.drawSource,
|
|
930
|
-
type: type
|
|
937
|
+
type: type,
|
|
938
|
+
geometryFunction: geometryFunction // style: style
|
|
931
939
|
|
|
932
940
|
});
|
|
933
941
|
gis.addInteraction(t.drawToolbar);
|
|
@@ -945,6 +953,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
945
953
|
lng = _gc$flatCoordinates[0],
|
|
946
954
|
lat = _gc$flatCoordinates[1];
|
|
947
955
|
|
|
956
|
+
gc.x = lng;
|
|
957
|
+
gc.y = lat;
|
|
948
958
|
t.addPoint([{
|
|
949
959
|
id: t.drawParam.data.id,
|
|
950
960
|
longitude: lng,
|
|
@@ -1056,14 +1066,42 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1056
1066
|
};
|
|
1057
1067
|
}
|
|
1058
1068
|
|
|
1059
|
-
if (t.drawParam.geometryType == '
|
|
1060
|
-
var
|
|
1069
|
+
if (t.drawParam.geometryType == 'rectangle') {
|
|
1070
|
+
var _path3 = e.feature.getGeometry().getCoordinates()[0];
|
|
1071
|
+
t.addPolygon([{
|
|
1072
|
+
id: t.drawParam.data.id,
|
|
1073
|
+
rings: _path3,
|
|
1074
|
+
config: _objectSpread({}, t.drawParam.parameter)
|
|
1075
|
+
}], t.drawParam.geometryType); //处理线返回参数
|
|
1061
1076
|
|
|
1062
|
-
var
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
// let circleRadius = radius / metersPerUnit;
|
|
1077
|
+
var _t$dealData5 = t.dealData(_path3),
|
|
1078
|
+
_lnglatAry3 = _t$dealData5.lnglatAry,
|
|
1079
|
+
_extent4 = _t$dealData5._extent;
|
|
1066
1080
|
|
|
1081
|
+
param = {
|
|
1082
|
+
lnglatAry: _lnglatAry3,
|
|
1083
|
+
id: t.drawParam.data.id,
|
|
1084
|
+
geometry: _objectSpread(_objectSpread({}, e.geometry), {}, {
|
|
1085
|
+
rings: _path3,
|
|
1086
|
+
type: t.drawParam.geometryType,
|
|
1087
|
+
_extent: _extent4
|
|
1088
|
+
}),
|
|
1089
|
+
attributes: {
|
|
1090
|
+
id: t.drawParam.data.id,
|
|
1091
|
+
config: _objectSpread({}, t.drawParam.parameter)
|
|
1092
|
+
},
|
|
1093
|
+
area: (0, _MapToolFunction.getPolygonArea)(_path3),
|
|
1094
|
+
geometryType: t.drawParam.geometryType,
|
|
1095
|
+
mapLayer: t.GM.getGraphic(t.drawParam.data.id)
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
if (t.drawParam.geometryType == 'circle') {
|
|
1100
|
+
var center = e.feature.getGeometry().getCenter();
|
|
1101
|
+
var cur = e.feature.getProperties().geometry;
|
|
1102
|
+
var sketchCoords_ = [cur.flatCoordinates[0], cur.flatCoordinates[1]];
|
|
1103
|
+
var sketchCoords_2 = [cur.flatCoordinates[2], cur.flatCoordinates[3]];
|
|
1104
|
+
var radius = ol.sphere.getDistance(sketchCoords_, sketchCoords_2);
|
|
1067
1105
|
t.addCircle([{
|
|
1068
1106
|
id: t.drawParam.data.id,
|
|
1069
1107
|
longitude: center[0],
|
|
@@ -1726,7 +1764,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1726
1764
|
|
|
1727
1765
|
|
|
1728
1766
|
var feature = new ol.Feature({
|
|
1729
|
-
geometry: new ol.geom.Point([item.longitude, item.latitude]),
|
|
1767
|
+
geometry: new ol.geom.Point([parseFloat(item.longitude), parseFloat(item.latitude)]),
|
|
1730
1768
|
name: item.name,
|
|
1731
1769
|
id: item.id,
|
|
1732
1770
|
params: _objectSpread({}, item)
|
|
@@ -1757,7 +1795,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1757
1795
|
|
|
1758
1796
|
var pop = new ol.Overlay({
|
|
1759
1797
|
id: item.id,
|
|
1760
|
-
position: [item.longitude, item.latitude],
|
|
1798
|
+
position: [parseFloat(item.longitude), parseFloat(item.latitude)],
|
|
1761
1799
|
positioning: 'center-center',
|
|
1762
1800
|
element: nodes,
|
|
1763
1801
|
autoPanMargin: 20,
|
|
@@ -1862,8 +1900,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1862
1900
|
geometryType: 'point',
|
|
1863
1901
|
geometry: {
|
|
1864
1902
|
type: 'point',
|
|
1865
|
-
x: item.longitude,
|
|
1866
|
-
y: item.latitude
|
|
1903
|
+
x: parseFloat(item.longitude),
|
|
1904
|
+
y: parseFloat(item.latitude)
|
|
1867
1905
|
},
|
|
1868
1906
|
source: source
|
|
1869
1907
|
});
|
|
@@ -1920,7 +1958,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1920
1958
|
var overlay = t.state.gis.getOverlayById(item.id);
|
|
1921
1959
|
var nodes = t.parseDom(item.markerContent)[0];
|
|
1922
1960
|
overlay.setElement(nodes);
|
|
1923
|
-
overlay.setPosition([item.longitude, item.latitude]);
|
|
1961
|
+
overlay.setPosition([parseFloat(item.longitude), parseFloat(item.latitude)]);
|
|
1924
1962
|
t.state.gis.changed();
|
|
1925
1963
|
} else {
|
|
1926
1964
|
canvasDataURL(item.url || require("../images/defaultMarker.png"), {
|
|
@@ -1979,7 +2017,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1979
2017
|
}
|
|
1980
2018
|
}
|
|
1981
2019
|
|
|
1982
|
-
gc.setGeometry(new ol.geom.Point([item.longitude, item.latitude]));
|
|
2020
|
+
gc.setGeometry(new ol.geom.Point([parseFloat(item.longitude), parseFloat(item.latitude)]));
|
|
1983
2021
|
|
|
1984
2022
|
_this3.GM.setGraphicParam(item.id, {
|
|
1985
2023
|
attributes: _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -1988,8 +2026,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1988
2026
|
geometryType: 'point',
|
|
1989
2027
|
geometry: {
|
|
1990
2028
|
type: 'point',
|
|
1991
|
-
x: item.longitude,
|
|
1992
|
-
y: item.latitude
|
|
2029
|
+
x: parseFloat(item.longitude),
|
|
2030
|
+
y: parseFloat(item.latitude)
|
|
1993
2031
|
},
|
|
1994
2032
|
source: gp.source
|
|
1995
2033
|
});
|
|
@@ -2719,8 +2757,8 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2719
2757
|
value: function setAreaRestriction(areaRestriction) {
|
|
2720
2758
|
var t = this;
|
|
2721
2759
|
|
|
2722
|
-
var _t$
|
|
2723
|
-
_et = _t$
|
|
2760
|
+
var _t$dealData6 = t.dealData(areaRestriction),
|
|
2761
|
+
_et = _t$dealData6._extent;
|
|
2724
2762
|
|
|
2725
2763
|
t.areaRestriction = t.state.gis.getView().setProperties({
|
|
2726
2764
|
extent: [_et.xmax, _et.ymax, _et.xmin, _et.ymin]
|
|
@@ -2817,7 +2855,7 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
2817
2855
|
|
|
2818
2856
|
function clusterMemberStyle(clusterMember) {
|
|
2819
2857
|
var style = clusterMember.getStyle();
|
|
2820
|
-
var image = style.getImage();
|
|
2858
|
+
var image = style && style.getImage ? style.getImage() : null;
|
|
2821
2859
|
return new ol.style.Style({
|
|
2822
2860
|
geometry: clusterMember.getGeometry(),
|
|
2823
2861
|
image: image
|
|
@@ -3747,12 +3785,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3747
3785
|
var obj = t.getMapExtent();
|
|
3748
3786
|
obj.e = e;
|
|
3749
3787
|
obj.clickLngLat = {
|
|
3750
|
-
lng:
|
|
3751
|
-
lat:
|
|
3788
|
+
lng: e.coordinate ? e.coordinate[0] : undefined,
|
|
3789
|
+
lat: e.coordinate ? e.coordinate[1] : undefined
|
|
3752
3790
|
};
|
|
3753
3791
|
obj.pixel = {
|
|
3754
|
-
x:
|
|
3755
|
-
y:
|
|
3792
|
+
x: e.pixel ? e.pixel[0] : undefined,
|
|
3793
|
+
y: e.pixel ? e.pixel[1] : undefined
|
|
3756
3794
|
};
|
|
3757
3795
|
t.props.clickMap(obj);
|
|
3758
3796
|
}
|