@vtx/map 1.2.8 → 1.2.10

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.
@@ -267,7 +267,9 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
267
267
  msgConfirmInputText: '请输入搜索关键字',
268
268
  msgEndEditingDrawText: '请双击结束图元编辑',
269
269
  msgClickGraphicEditText: '请点击图元进行编辑',
270
- placeholderSearchInputText: '输入关键字'
270
+ placeholderSearchInputText: '输入关键字',
271
+ lengthText: '长度',
272
+ areaText: '面积'
271
273
  }, props.customEnumText || {});
272
274
  return _this;
273
275
  } // 绘制多个图元时返回参数
@@ -822,49 +824,114 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
822
824
  break;
823
825
  }
824
826
  }
827
+ }, {
828
+ key: "computeGraphic",
829
+ value: function computeGraphic() {
830
+ var _this7 = this;
831
+
832
+ var str = '';
833
+ var _this$state4 = this.state,
834
+ graphicValue = _this$state4.graphicValue,
835
+ editGraphicId = _this$state4.editGraphicId;
836
+
837
+ switch (this.state.graphicType) {
838
+ case 'circle':
839
+ if (this.map.getGraphic(editGraphicId)) {
840
+ var p = this.map.getGraphic(editGraphicId);
841
+ str = "".concat(this.TextEnum.areaText, "\uFF1A").concat(formatNumber(Math.PI * Math.pow(p.geometry.radius, 2)), "\u33A1");
842
+ } else {
843
+ str = "".concat(this.TextEnum.areaText, "\uFF1A").concat(graphicValue ? formatNumber(graphicValue.area) : '-', "\u33A1");
844
+ }
845
+
846
+ break;
847
+
848
+ case 'polygon':
849
+ if (this.map.getGraphic(editGraphicId)) {
850
+ var _p4 = this.map.getGraphic(editGraphicId);
851
+
852
+ str = "".concat(this.TextEnum.areaText, "\uFF1A").concat(formatNumber(this.map.getPolygonArea(distinct(_p4.geometry.rings))), "\u33A1");
853
+ } else {
854
+ str = "".concat(this.TextEnum.areaText, "\uFF1A").concat(graphicValue ? formatNumber(graphicValue.area) : '-', "\u33A1");
855
+ }
856
+
857
+ break;
858
+
859
+ case 'rectangle':
860
+ str = "".concat(this.TextEnum.areaText, "\uFF1A").concat(graphicValue ? formatNumber(graphicValue.area) : '-', "\u33A1");
861
+ break;
862
+
863
+ case 'polyline':
864
+ if (this.map.getGraphic(editGraphicId)) {
865
+ var _p5 = this.map.getGraphic(editGraphicId);
866
+
867
+ str = "".concat(this.TextEnum.lengthText, "\uFF1A").concat(formatNumber(this.map.calculateDistance(_p5.geometry.paths)), "m");
868
+ } else {
869
+ str = "".concat(this.TextEnum.lengthText, "\uFF1A").concat(graphicValue ? formatNumber(this.map.calculateDistance(graphicValue.geometry.paths)) : '-', "m");
870
+ }
871
+
872
+ break;
873
+ }
874
+
875
+ if (str) {
876
+ return /*#__PURE__*/_react["default"].createElement("span", {
877
+ style: {
878
+ display: 'inline-block',
879
+ marginLeft: '10px'
880
+ }
881
+ }, /*#__PURE__*/_react["default"].createElement("span", null, str), /*#__PURE__*/_react["default"].createElement("span", {
882
+ onClick: function onClick() {
883
+ _this7.setState({
884
+ flag: Math.random()
885
+ });
886
+ }
887
+ }, getIcon('sync')));
888
+ } else {
889
+ return null;
890
+ }
891
+ }
825
892
  }, {
826
893
  key: "render",
827
894
  value: function render() {
828
- var _this7 = this;
895
+ var _this8 = this;
829
896
 
830
897
  var t = this;
831
898
  var TextEnum = t.TextEnum;
832
- var _this$state4 = this.state,
833
- isShowList = _this$state4.isShowList,
834
- searchValue = _this$state4.searchValue,
835
- locationPoint = _this$state4.locationPoint,
836
- listPoint = _this$state4.listPoint,
837
- listMess = _this$state4.listMess,
838
- mapZoomLevel = _this$state4.mapZoomLevel,
839
- setZoomLevel = _this$state4.setZoomLevel,
840
- maxZoom = _this$state4.maxZoom,
841
- minZoom = _this$state4.minZoom,
842
- wkid = _this$state4.wkid,
843
- mapServer = _this$state4.mapServer,
844
- mapCenter = _this$state4.mapCenter,
845
- setCenter = _this$state4.setCenter,
846
- mapType = _this$state4.mapType,
847
- mapStyle = _this$state4.mapStyle,
848
- mapVisiblePoints = _this$state4.mapVisiblePoints,
849
- setVisiblePoints = _this$state4.setVisiblePoints,
850
- isDoEdit = _this$state4.isDoEdit,
851
- editGraphicId = _this$state4.editGraphicId,
852
- isEndEdit = _this$state4.isEndEdit,
853
- modal1Visible = _this$state4.modal1Visible,
854
- drawGraphID = _this$state4.drawGraphID,
855
- isShowOther = _this$state4.isShowOther,
856
- otherText = _this$state4.otherText,
857
- isShowOtherGraph = _this$state4.isShowOtherGraph,
858
- editGraphic = _this$state4.editGraphic,
859
- graphicType = _this$state4.graphicType,
860
- graphicValue = _this$state4.graphicValue,
861
- olProps = _this$state4.olProps,
862
- isChangeMapType = _this$state4.isChangeMapType,
863
- currentMap = _this$state4.currentMap,
864
- showControl = _this$state4.showControl,
865
- coverageType = _this$state4.coverageType,
866
- customNodes = _this$state4.customNodes,
867
- language = _this$state4.language;
899
+ var _this$state5 = this.state,
900
+ isShowList = _this$state5.isShowList,
901
+ searchValue = _this$state5.searchValue,
902
+ locationPoint = _this$state5.locationPoint,
903
+ listPoint = _this$state5.listPoint,
904
+ listMess = _this$state5.listMess,
905
+ mapZoomLevel = _this$state5.mapZoomLevel,
906
+ setZoomLevel = _this$state5.setZoomLevel,
907
+ maxZoom = _this$state5.maxZoom,
908
+ minZoom = _this$state5.minZoom,
909
+ wkid = _this$state5.wkid,
910
+ mapServer = _this$state5.mapServer,
911
+ mapCenter = _this$state5.mapCenter,
912
+ setCenter = _this$state5.setCenter,
913
+ mapType = _this$state5.mapType,
914
+ mapStyle = _this$state5.mapStyle,
915
+ mapVisiblePoints = _this$state5.mapVisiblePoints,
916
+ setVisiblePoints = _this$state5.setVisiblePoints,
917
+ isDoEdit = _this$state5.isDoEdit,
918
+ editGraphicId = _this$state5.editGraphicId,
919
+ isEndEdit = _this$state5.isEndEdit,
920
+ modal1Visible = _this$state5.modal1Visible,
921
+ drawGraphID = _this$state5.drawGraphID,
922
+ isShowOther = _this$state5.isShowOther,
923
+ otherText = _this$state5.otherText,
924
+ isShowOtherGraph = _this$state5.isShowOtherGraph,
925
+ editGraphic = _this$state5.editGraphic,
926
+ graphicType = _this$state5.graphicType,
927
+ graphicValue = _this$state5.graphicValue,
928
+ olProps = _this$state5.olProps,
929
+ isChangeMapType = _this$state5.isChangeMapType,
930
+ currentMap = _this$state5.currentMap,
931
+ showControl = _this$state5.showControl,
932
+ coverageType = _this$state5.coverageType,
933
+ customNodes = _this$state5.customNodes,
934
+ language = _this$state5.language;
868
935
  var InputProps = {
869
936
  style: {
870
937
  'width': '200px'
@@ -882,19 +949,19 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
882
949
  isDraw: this.state.isDraw,
883
950
  isCloseDraw: this.state.isCloseDraw,
884
951
  drawEnd: function drawEnd(obj) {
885
- _this7.isDrawStatus = false;
886
- _this7.isClickMap = false;
952
+ _this8.isDrawStatus = false;
953
+ _this8.isClickMap = false;
887
954
  var objparam = {
888
- graphicValue: _this7.multiDraw ? [].concat(_toConsumableArray(graphicValue || []), [obj]) : obj,
889
- isDoEdit: !_this7.multiDraw,
890
- isDraw: _this7.multiDraw
955
+ graphicValue: _this8.multiDraw ? [].concat(_toConsumableArray(graphicValue || []), [obj]) : obj,
956
+ isDoEdit: !_this8.multiDraw,
957
+ isDraw: _this8.multiDraw
891
958
  };
892
959
 
893
- if (!_this7.multiDraw && (obj.geometryType == 'polyline' || obj.geometryType == 'polygon')) {
960
+ if (!_this8.multiDraw && (obj.geometryType == 'polyline' || obj.geometryType == 'polygon')) {
894
961
  objparam.editGraphicId = obj.id;
895
962
  }
896
963
 
897
- _this7.setState(objparam);
964
+ _this8.setState(objparam);
898
965
  },
899
966
  mapDraw: {
900
967
  geometryType: this.state.graphicType,
@@ -992,8 +1059,8 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
992
1059
  },
993
1060
  maskClosable: false,
994
1061
  onModalResize: function onModalResize() {
995
- if (_this7.state.mapType == 'olmap') {
996
- _this7.map.updateSize();
1062
+ if (_this8.state.mapType == 'olmap') {
1063
+ _this8.map.updateSize();
997
1064
  }
998
1065
  },
999
1066
  onCancel: this.closeModal.bind(this),
@@ -1002,13 +1069,13 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1002
1069
  }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
1003
1070
  type: "primary",
1004
1071
  onClick: function onClick() {
1005
- if (_this7.multiDraw && _this7.state.isDoEdit && !_this7.state.isEndEdit) {
1006
- _this7.continueDraw(_this7.callback.bind(_this7));
1072
+ if (_this8.multiDraw && _this8.state.isDoEdit && !_this8.state.isEndEdit) {
1073
+ _this8.continueDraw(_this8.callback.bind(_this8));
1007
1074
 
1008
1075
  return;
1009
1076
  }
1010
1077
 
1011
- _this7.callback();
1078
+ _this8.callback();
1012
1079
  },
1013
1080
  icon: getIcon('check')
1014
1081
  }, TextEnum.footerConfirmBtnText), /*#__PURE__*/_react["default"].createElement(_button["default"], {
@@ -1038,10 +1105,10 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1038
1105
  }, TextEnum.searchRelocateBtnText) : null, this.state.graphicType != 'point' ? /*#__PURE__*/_react["default"].createElement(_button["default"], {
1039
1106
  disabled: this.isDrawStatus,
1040
1107
  onClick: function onClick() {
1041
- _this7.isDrawStatus = true;
1108
+ _this8.isDrawStatus = true;
1042
1109
 
1043
- if (_this7.multiDraw) {
1044
- _this7.clickable = false;
1110
+ if (_this8.multiDraw) {
1111
+ _this8.clickable = false;
1045
1112
  graphicValue === null || graphicValue === void 0 ? void 0 : graphicValue.forEach(function (item) {
1046
1113
  return t.map.removeGraphic(item.id, 'draw');
1047
1114
  });
@@ -1049,21 +1116,21 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1049
1116
  return t.map.removeGraphic(item.id, 'draw');
1050
1117
  });
1051
1118
 
1052
- _this7.setState({
1119
+ _this8.setState({
1053
1120
  isDraw: false,
1054
1121
  isCloseDraw: true,
1055
1122
  isEndEdit: false,
1056
1123
  graphicValue: null,
1057
1124
  editGraphic: null
1058
1125
  }, function () {
1059
- _this7.setState({
1126
+ _this8.setState({
1060
1127
  isDraw: true,
1061
1128
  isCloseDraw: false,
1062
1129
  isEndEdit: true
1063
1130
  });
1064
1131
  });
1065
1132
  } else {
1066
- _this7.setState({
1133
+ _this8.setState({
1067
1134
  isDraw: true,
1068
1135
  graphicValue: null,
1069
1136
  editGraphic: null,
@@ -1076,7 +1143,7 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1076
1143
  });
1077
1144
  }
1078
1145
 
1079
- _this7.callback('editDraw');
1146
+ _this8.callback('editDraw');
1080
1147
  },
1081
1148
  icon: getIcon('edit')
1082
1149
  }, TextEnum.searchRedrawBtnText) : null, this.multiDraw && /*#__PURE__*/_react["default"].createElement(_button["default"], {
@@ -1088,14 +1155,14 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1088
1155
  }, TextEnum.searchEditGraphicBtnText), /*#__PURE__*/_react["default"].createElement(_button["default"], {
1089
1156
  onClick: this.setFitView.bind(this),
1090
1157
  icon: getIcon('sync')
1091
- }, TextEnum.searchGlobalBtnText)), /*#__PURE__*/_react["default"].createElement("div", {
1158
+ }, TextEnum.searchGlobalBtnText), !this.multiDraw && this.map && this.computeGraphic()), /*#__PURE__*/_react["default"].createElement("div", {
1092
1159
  className: styles.top_right
1093
1160
  }, typeof customNodes == 'function' && customNodes(t.map), isShowOther ? /*#__PURE__*/_react["default"].createElement("div", {
1094
1161
  className: styles.otherModal
1095
1162
  }, /*#__PURE__*/_react["default"].createElement(_checkbox["default"], {
1096
1163
  checked: isShowOtherGraph,
1097
1164
  onChange: function onChange(e) {
1098
- _this7.setState({
1165
+ _this8.setState({
1099
1166
  isShowOtherGraph: e.target.checked
1100
1167
  });
1101
1168
  }
@@ -1106,7 +1173,7 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1106
1173
  var key = _ref.key;
1107
1174
  console.log(key);
1108
1175
 
1109
- _this7.setState({
1176
+ _this8.setState({
1110
1177
  coverageType: key
1111
1178
  });
1112
1179
  },
@@ -1141,7 +1208,7 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1141
1208
  className: styles.title
1142
1209
  }, TextEnum.labelSearchResultText), /*#__PURE__*/_react["default"].createElement("div", {
1143
1210
  onClick: function onClick() {
1144
- return _this7.showOrhidden(false);
1211
+ return _this8.showOrhidden(false);
1145
1212
  },
1146
1213
  className: styles.btn
1147
1214
  }, /*#__PURE__*/_react["default"].createElement(_default2.VtxMapIcon, {
@@ -1152,13 +1219,13 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1152
1219
  return /*#__PURE__*/_react["default"].createElement("div", {
1153
1220
  key: index,
1154
1221
  onClick: function onClick() {
1155
- return _this7.chooseAddress(item.id);
1222
+ return _this8.chooseAddress(item.id);
1156
1223
  },
1157
1224
  className: "".concat(styles.lists, " ").concat(item.isSelect ? styles.select : '')
1158
1225
  }, item.title);
1159
1226
  }))), /*#__PURE__*/_react["default"].createElement("div", {
1160
1227
  onClick: function onClick() {
1161
- return _this7.showOrhidden(true);
1228
+ return _this8.showOrhidden(true);
1162
1229
  },
1163
1230
  className: "".concat(styles.btn, " ").concat(!isShowList ? styles.show : styles.hidden)
1164
1231
  }, /*#__PURE__*/_react["default"].createElement(_default2.VtxMapIcon, {
@@ -1167,7 +1234,7 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1167
1234
  className: styles.content_right
1168
1235
  }, /*#__PURE__*/_react["default"].createElement(_VtxMap.VtxMap, _extends({
1169
1236
  getMapInstance: function getMapInstance(map) {
1170
- if (map) _this7.map = map;
1237
+ if (map) _this8.map = map;
1171
1238
  },
1172
1239
  mapType: mapType,
1173
1240
  mapStyle: mapStyle,
@@ -1203,25 +1270,25 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1203
1270
  }, {
1204
1271
  key: "initSearchMap",
1205
1272
  value: function initSearchMap() {
1206
- var _this8 = this;
1273
+ var _this9 = this;
1207
1274
 
1208
1275
  if (this.props.modal1Visible
1209
1276
  /*&& !this.state.locationPoint[0]*/
1210
1277
  ) {
1211
1278
  if (this.map) {
1212
1279
  this.map.loadMapComplete.then(function () {
1213
- if (!_this8.mapLoaded) {
1214
- var _this8$props$editPara, _this8$props$editPara2;
1280
+ if (!_this9.mapLoaded) {
1281
+ var _this9$props$editPara, _this9$props$editPara2;
1215
1282
 
1216
- _this8.mapLoaded = true;
1283
+ _this9.mapLoaded = true;
1217
1284
 
1218
- _this8.drawLocationPoint();
1285
+ _this9.drawLocationPoint();
1219
1286
 
1220
- if ((_this8$props$editPara = _this8.props.editParam) !== null && _this8$props$editPara !== void 0 && _this8$props$editPara.rings || (_this8$props$editPara2 = _this8.props.editParam) !== null && _this8$props$editPara2 !== void 0 && _this8$props$editPara2.paths) {
1287
+ if ((_this9$props$editPara = _this9.props.editParam) !== null && _this9$props$editPara !== void 0 && _this9$props$editPara.rings || (_this9$props$editPara2 = _this9.props.editParam) !== null && _this9$props$editPara2 !== void 0 && _this9$props$editPara2.paths) {
1221
1288
  var timer = setTimeout(function () {
1222
- var _this8$props$editPara3, _this8$props$editPara4;
1289
+ var _this9$props$editPara3, _this9$props$editPara4;
1223
1290
 
1224
- _this8.map.fitView(((_this8$props$editPara3 = _this8.props.editParam) === null || _this8$props$editPara3 === void 0 ? void 0 : _this8$props$editPara3.rings) || ((_this8$props$editPara4 = _this8.props.editParam) === null || _this8$props$editPara4 === void 0 ? void 0 : _this8$props$editPara4.paths) || []);
1291
+ _this9.map.fitView(((_this9$props$editPara3 = _this9.props.editParam) === null || _this9$props$editPara3 === void 0 ? void 0 : _this9$props$editPara3.rings) || ((_this9$props$editPara4 = _this9.props.editParam) === null || _this9$props$editPara4 === void 0 ? void 0 : _this9$props$editPara4.paths) || []);
1225
1292
 
1226
1293
  clearTimeout(timer);
1227
1294
  }, 100);
@@ -1246,7 +1313,7 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1246
1313
  }, {
1247
1314
  key: "UNSAFE_componentWillReceiveProps",
1248
1315
  value: function UNSAFE_componentWillReceiveProps(nextProps) {
1249
- var _this9 = this;
1316
+ var _this10 = this;
1250
1317
 
1251
1318
  var t = this;
1252
1319
  this.isClickMap = false;
@@ -1284,49 +1351,49 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1284
1351
  setTimeout(function () {
1285
1352
  //实现2+次进入时,清理数据
1286
1353
  if (nextProps.modal1Visible) {
1287
- _this9.clearList();
1354
+ _this10.clearList();
1288
1355
 
1289
- _this9.setState({
1356
+ _this10.setState({
1290
1357
  setZoomLevel: true
1291
1358
  }, function () {
1292
- _this9.setState({
1359
+ _this10.setState({
1293
1360
  setZoomLevel: false
1294
1361
  });
1295
1362
  });
1296
1363
 
1297
- if (!!_this9.map && !!_this9.state.locationPoint[0] && nextProps.mapCenter && !!nextProps.mapCenter[0]) {
1298
- if (_this9.map.getGraphic('locationPoint')) {
1364
+ if (!!_this10.map && !!_this10.state.locationPoint[0] && nextProps.mapCenter && !!nextProps.mapCenter[0]) {
1365
+ if (_this10.map.getGraphic('locationPoint')) {
1299
1366
  switch (nextProps.mapType) {
1300
1367
  case 'bmap':
1301
- _this9.map.getGraphic('locationPoint').mapLayer.setPosition(new BMap.Point(nextProps.mapCenter[0], nextProps.mapCenter[1]));
1368
+ _this10.map.getGraphic('locationPoint').mapLayer.setPosition(new BMap.Point(nextProps.mapCenter[0], nextProps.mapCenter[1]));
1302
1369
 
1303
1370
  break;
1304
1371
 
1305
1372
  case 'amap':
1306
- _this9.map.getGraphic('locationPoint').mapLayer.setPosition(new AMap.LngLat(nextProps.mapCenter[0], nextProps.mapCenter[1]));
1373
+ _this10.map.getGraphic('locationPoint').mapLayer.setPosition(new AMap.LngLat(nextProps.mapCenter[0], nextProps.mapCenter[1]));
1307
1374
 
1308
1375
  break;
1309
1376
 
1310
1377
  case 'tmap':
1311
- _this9.map.getGraphic('locationPoint').mapLayer.setLngLat(new T.LngLat(nextProps.mapCenter[0], nextProps.mapCenter[1]));
1378
+ _this10.map.getGraphic('locationPoint').mapLayer.setLngLat(new T.LngLat(nextProps.mapCenter[0], nextProps.mapCenter[1]));
1312
1379
 
1313
1380
  break;
1314
1381
 
1315
1382
  case 'gmap':
1316
- _this9.map.getGraphic('locationPoint').mapLayer.geometry.setLatitude(nextProps.mapCenter[1]);
1383
+ _this10.map.getGraphic('locationPoint').mapLayer.geometry.setLatitude(nextProps.mapCenter[1]);
1317
1384
 
1318
- _this9.map.getGraphic('locationPoint').mapLayer.geometry.setLongitude(nextProps.mapCenter[0]);
1385
+ _this10.map.getGraphic('locationPoint').mapLayer.geometry.setLongitude(nextProps.mapCenter[0]);
1319
1386
 
1320
- _this9.map.state.gis.graphics.refresh();
1387
+ _this10.map.state.gis.graphics.refresh();
1321
1388
 
1322
1389
  case 'olMap':
1323
- _this9.map.getGraphic('locationPoint').mapLayer.setGeometry(new ol.geom.Point(nextProps.mapCenter));
1390
+ _this10.map.getGraphic('locationPoint').mapLayer.setGeometry(new ol.geom.Point(nextProps.mapCenter));
1324
1391
 
1325
1392
  break;
1326
1393
  }
1327
1394
  }
1328
1395
 
1329
- _this9.map.setCenter(nextProps.mapCenter);
1396
+ _this10.map.setCenter(nextProps.mapCenter);
1330
1397
  }
1331
1398
  }
1332
1399
  }, 100);
@@ -1348,5 +1415,10 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1348
1415
 
1349
1416
  var _default = VtxSearchMap;
1350
1417
  exports["default"] = _default;
1418
+
1419
+ function formatNumber(num) {
1420
+ return Number(num).toFixed(2);
1421
+ }
1422
+
1351
1423
  module.exports = exports["default"];
1352
1424
  //# sourceMappingURL=VtxSearchMap.js.map