@vtx/map 1.2.15 → 1.2.17

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.
@@ -41,6 +41,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
41
41
 
42
42
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
43
43
 
44
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
45
+
46
+ 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."); }
47
+
48
+ 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; }
49
+
50
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
51
+
44
52
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
45
53
 
46
54
  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; }
@@ -247,13 +255,16 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
247
255
  showControl: props.showControl || false,
248
256
  coverageType: props.coverageType || 'sl',
249
257
  // 自定义右上角功能
250
- customNodes: props.customNodes || null
258
+ customNodes: props.customNodes || null,
259
+ // 查询模式
260
+ searchMode: props.searchMode || 'keyword'
251
261
  };
252
262
  _this.TextEnum = _objectSpread({
253
263
  locationTitleText: '定位',
254
264
  drawTitleText: '绘制',
255
265
  searchConfirmBtnText: '查询',
256
266
  searchResetBtnText: '清空',
267
+ locateLnglatText: '定位',
257
268
  searchRelocateBtnText: '校正',
258
269
  searchGlobalBtnText: '返回全局地图',
259
270
  searchRedrawBtnText: '重新绘制',
@@ -265,10 +276,14 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
265
276
  footerConfirmBtnText: '确定',
266
277
  footerCancelBtnText: '关闭',
267
278
  msgConfirmInputText: '请输入搜索关键字',
279
+ msgConfirmInputLnglatText: '请输入经纬度定位',
268
280
  msgEndEditingDrawText: '请双击结束图元编辑',
269
281
  msgClickGraphicEditText: '请点击图元进行编辑',
270
282
  msgDoNotAllowOtherGraph: '不允许编辑其它参考图元',
271
283
  placeholderSearchInputText: '输入关键字',
284
+ placeholderSearchInputLngLatText: '输入经纬度,逗号分隔',
285
+ radioLabelKeywordText: '关键字',
286
+ radioLabelLnglatText: '坐标定位',
272
287
  lengthText: '长度',
273
288
  areaText: '面积'
274
289
  }, props.customEnumText || {});
@@ -342,10 +357,21 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
342
357
  break;
343
358
 
344
359
  case 'rectangle':
345
- this.props[fun](this.state.graphicValue ? {
346
- rings: distinct(this.state.graphicValue.geometry.rings),
347
- area: this.state.graphicValue.area
348
- } : null);
360
+ if (this.state.graphicValue) {
361
+ this.props[fun](this.state.graphicValue ? {
362
+ rings: distinct(this.state.graphicValue.geometry.rings),
363
+ area: this.state.graphicValue.area
364
+ } : null);
365
+ } else if (this.map.getGraphic(editGraphicId)) {
366
+ var _p3 = this.map.GM.allParam[editGraphicId];
367
+ this.props[fun]({
368
+ rings: distinct(_p3.geometry.rings),
369
+ area: this.map.getPolygonArea(distinct(_p3.geometry.rings))
370
+ });
371
+ } else {
372
+ this.props[fun](null);
373
+ }
374
+
349
375
  break;
350
376
 
351
377
  case 'polyline':
@@ -355,11 +381,11 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
355
381
  }
356
382
 
357
383
  if (this.map.getGraphic(editGraphicId)) {
358
- var _p3 = this.map.getGraphic(editGraphicId);
384
+ var _p4 = this.map.getGraphic(editGraphicId);
359
385
 
360
386
  this.props[fun]({
361
- paths: _p3.geometry.paths,
362
- length: this.map.calculateDistance(_p3.geometry.paths)
387
+ paths: _p4.geometry.paths,
388
+ length: this.map.calculateDistance(_p4.geometry.paths)
363
389
  });
364
390
  } else {
365
391
  this.props[fun](this.state.graphicValue ? {
@@ -466,6 +492,36 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
466
492
  this.setState({
467
493
  searchValue: e.target.value
468
494
  });
495
+ } // 根据经纬度定位中心点
496
+
497
+ }, {
498
+ key: "locateByLnglat",
499
+ value: function locateByLnglat() {
500
+ var t = this;
501
+
502
+ if (!t.state.searchValue) {
503
+ _message["default"].warn(t.TextEnum.msgConfirmInputLnglatText);
504
+
505
+ return;
506
+ }
507
+
508
+ var _t$state$searchValue$ = t.state.searchValue.split(','),
509
+ _t$state$searchValue$2 = _slicedToArray(_t$state$searchValue$, 2),
510
+ longitude = _t$state$searchValue$2[0],
511
+ latitude = _t$state$searchValue$2[1];
512
+
513
+ t.setState({
514
+ mapCenter: [longitude, latitude],
515
+ setCenter: true
516
+ }, function () {
517
+ t.setState({
518
+ setCenter: false
519
+ });
520
+
521
+ if (t.state.graphicType == 'point') {
522
+ t.correction();
523
+ }
524
+ });
469
525
  } //根据关键字搜索数据
470
526
 
471
527
  }, {
@@ -477,16 +533,13 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
477
533
  _message["default"].warn(this.TextEnum.msgConfirmInputText);
478
534
 
479
535
  return;
480
- } // if(window.AMap){
481
- // t.searchPoints();
482
- // }else {
483
- // $.getScript("//webapi.amap.com/maps?v=1.4.14&key=e59ef9272e3788ac59d9a22f0f8cf9fe&plugin=AMap.PlaceSearch",()=>{
484
- // t.searchPoints();
485
- // })
486
- // }
487
-
536
+ }
488
537
 
489
- t.searchPointsLBS();
538
+ if (t.state.searchMode === 'lnglat') {
539
+ t.locateByLnglat();
540
+ } else {
541
+ t.searchPointsLBS();
542
+ }
490
543
  } // 从lbs中查询
491
544
 
492
545
  }, {
@@ -872,9 +925,9 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
872
925
 
873
926
  case 'polygon':
874
927
  if (this.map.getGraphic(editGraphicId)) {
875
- var _p4 = this.map.getGraphic(editGraphicId);
928
+ var _p5 = this.map.getGraphic(editGraphicId);
876
929
 
877
- str = "".concat(this.TextEnum.areaText, "\uFF1A").concat(formatNumber(this.map.getPolygonArea(distinct(_p4.geometry.rings))), "\u33A1");
930
+ str = "".concat(this.TextEnum.areaText, "\uFF1A").concat(formatNumber(this.map.getPolygonArea(distinct(_p5.geometry.rings))), "\u33A1");
878
931
  } else {
879
932
  str = "".concat(this.TextEnum.areaText, "\uFF1A").concat(graphicValue ? formatNumber(graphicValue.area) : '-', "\u33A1");
880
933
  }
@@ -887,9 +940,9 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
887
940
 
888
941
  case 'polyline':
889
942
  if (this.map.getGraphic(editGraphicId)) {
890
- var _p5 = this.map.getGraphic(editGraphicId);
943
+ var _p6 = this.map.getGraphic(editGraphicId);
891
944
 
892
- str = "".concat(this.TextEnum.lengthText, "\uFF1A").concat(formatNumber(this.map.calculateDistance(_p5.geometry.paths)), "m");
945
+ str = "".concat(this.TextEnum.lengthText, "\uFF1A").concat(formatNumber(this.map.calculateDistance(_p6.geometry.paths)), "m");
893
946
  } else {
894
947
  str = "".concat(this.TextEnum.lengthText, "\uFF1A").concat(graphicValue ? formatNumber(this.map.calculateDistance(graphicValue.geometry.paths)) : '-', "m");
895
948
  }
@@ -961,7 +1014,7 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
961
1014
  style: {
962
1015
  'width': '200px'
963
1016
  },
964
- placeholder: TextEnum.placeholderSearchInputText,
1017
+ placeholder: this.state.searchMode == 'keyword' ? TextEnum.placeholderSearchInputText : TextEnum.placeholderSearchInputLngLatText,
965
1018
  value: searchValue,
966
1019
  onChange: this.changeValue.bind(this),
967
1020
  onPressEnter: this.searchList.bind(this),
@@ -1113,9 +1166,21 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1113
1166
  className: styles.top
1114
1167
  }, /*#__PURE__*/_react["default"].createElement("div", {
1115
1168
  className: styles.top_left
1116
- }, [/*#__PURE__*/_react["default"].createElement(_input["default"], _extends({
1169
+ }, /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_antd.Radio.Group, {
1170
+ value: this.state.searchMode,
1171
+ onChange: function onChange(e) {
1172
+ _this8.setState({
1173
+ searchMode: e.target.value,
1174
+ searchValue: ''
1175
+ });
1176
+ }
1177
+ }, /*#__PURE__*/_react["default"].createElement(_antd.Radio, {
1178
+ value: 'keyword'
1179
+ }, this.TextEnum.radioLabelKeywordText), /*#__PURE__*/_react["default"].createElement(_antd.Radio, {
1180
+ value: 'lnglat'
1181
+ }, this.TextEnum.radioLabelLnglatText)), /*#__PURE__*/_react["default"].createElement(_input["default"], _extends({
1117
1182
  key: "1"
1118
- }, InputProps)), /*#__PURE__*/_react["default"].createElement(_button["default"], {
1183
+ }, InputProps)), this.state.searchMode === 'keyword' ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_button["default"], {
1119
1184
  key: "2",
1120
1185
  type: "primary",
1121
1186
  onClick: this.searchList.bind(this),
@@ -1124,7 +1189,11 @@ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
1124
1189
  key: "3",
1125
1190
  onClick: this.clearList.bind(this),
1126
1191
  icon: getIcon('close')
1127
- }, TextEnum.searchResetBtnText)], this.state.graphicType == 'point' ? /*#__PURE__*/_react["default"].createElement(_button["default"], {
1192
+ }, TextEnum.searchResetBtnText)) : /*#__PURE__*/_react["default"].createElement(_button["default"], {
1193
+ key: "4",
1194
+ type: "primary",
1195
+ onClick: this.locateByLnglat.bind(this)
1196
+ }, TextEnum.locateLnglatText)), this.state.graphicType == 'point' ? /*#__PURE__*/_react["default"].createElement(_button["default"], {
1128
1197
  onClick: this.correction.bind(this),
1129
1198
  icon: getIcon('environment')
1130
1199
  }, TextEnum.searchRelocateBtnText) : null, this.state.graphicType != 'point' ? /*#__PURE__*/_react["default"].createElement(_button["default"], {