@vtx/map 1.1.8 → 1.1.11

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.
Files changed (66) hide show
  1. package/lib/VtxMap/AMap/AMap.js +3287 -2990
  2. package/lib/VtxMap/AMap/AMap.js.map +1 -0
  3. package/lib/VtxMap/BMap/Map.js +3517 -3146
  4. package/lib/VtxMap/BMap/Map.js.map +1 -0
  5. package/lib/VtxMap/GMap/Map.js +4572 -4021
  6. package/lib/VtxMap/GMap/Map.js.map +1 -0
  7. package/lib/VtxMap/Map.js +77 -63
  8. package/lib/VtxMap/Map.js.map +1 -0
  9. package/lib/VtxMap/MapToolFunction.js +422 -370
  10. package/lib/VtxMap/MapToolFunction.js.map +1 -0
  11. package/lib/VtxMap/OMap/Map.css +2 -2
  12. package/lib/VtxMap/OMap/Map.js +4345 -3782
  13. package/lib/VtxMap/OMap/Map.js.map +1 -0
  14. package/lib/VtxMap/OlMap/Map.css +47 -1
  15. package/lib/VtxMap/OlMap/Map.js +4022 -3557
  16. package/lib/VtxMap/OlMap/Map.js.map +1 -0
  17. package/lib/VtxMap/OlMap/Map.less +43 -0
  18. package/lib/VtxMap/TMap/TMap.css +0 -1
  19. package/lib/VtxMap/TMap/TMap.js +3475 -3139
  20. package/lib/VtxMap/TMap/TMap.js.map +1 -0
  21. package/lib/VtxMap/images/defaultMarker.png +0 -0
  22. package/lib/VtxMap/images/defaultMarker_selected.png +0 -0
  23. package/lib/VtxMap/index.js +37 -24
  24. package/lib/VtxMap/index.js.map +1 -0
  25. package/lib/VtxMap/mapPlayer.js +353 -308
  26. package/lib/VtxMap/mapPlayer.js.map +1 -0
  27. package/lib/VtxMap/optimizingPointMap.js +245 -205
  28. package/lib/VtxMap/optimizingPointMap.js.map +1 -0
  29. package/lib/VtxMap/style/css.js +16 -0
  30. package/lib/VtxMap/style/css.js.map +1 -0
  31. package/lib/VtxMap/style/index.js +16 -0
  32. package/lib/VtxMap/style/index.js.map +1 -0
  33. package/lib/VtxMap/zoomMap.js +120 -101
  34. package/lib/VtxMap/zoomMap.js.map +1 -0
  35. package/lib/VtxModal/VtxModal.css +62 -0
  36. package/lib/VtxModal/VtxModal.js +223 -213
  37. package/lib/VtxModal/VtxModal.js.map +1 -0
  38. package/lib/VtxModal/VtxModal.less +2 -2
  39. package/lib/VtxModal/VtxModalAntd3.css +62 -0
  40. package/lib/VtxModal/VtxModalAntd3.less +67 -0
  41. package/lib/VtxModal/draggableModal.js +138 -119
  42. package/lib/VtxModal/draggableModal.js.map +1 -0
  43. package/lib/VtxModal/index.js +21 -14
  44. package/lib/VtxModal/index.js.map +1 -0
  45. package/lib/VtxModal/style/css.js +21 -0
  46. package/lib/VtxModal/style/css.js.map +1 -0
  47. package/lib/VtxModal/style/index.js +21 -0
  48. package/lib/VtxModal/style/index.js.map +1 -0
  49. package/lib/VtxSearchMap/VtxSearchMap.css +171 -0
  50. package/lib/VtxSearchMap/VtxSearchMap.js +866 -819
  51. package/lib/VtxSearchMap/VtxSearchMap.js.map +1 -0
  52. package/lib/VtxSearchMap/VtxSearchMapAntd3.css +0 -0
  53. package/lib/VtxSearchMap/VtxSearchMapAntd3.less +1 -0
  54. package/lib/VtxSearchMap/index.js +9 -9
  55. package/lib/VtxSearchMap/index.js.map +1 -0
  56. package/lib/VtxSearchMap/mapping.js +15 -12
  57. package/lib/VtxSearchMap/mapping.js.map +1 -0
  58. package/lib/VtxSearchMap/style/css.js +47 -0
  59. package/lib/VtxSearchMap/style/css.js.map +1 -0
  60. package/lib/VtxSearchMap/style/index.js +47 -0
  61. package/lib/VtxSearchMap/style/index.js.map +1 -0
  62. package/lib/default.js +32 -27
  63. package/lib/default.js.map +1 -0
  64. package/lib/index.js +9 -10
  65. package/lib/index.js.map +1 -0
  66. package/package.json +25 -4
@@ -1,891 +1,938 @@
1
- 'use strict';
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
4
 
3
5
  Object.defineProperty(exports, "__esModule", {
4
- value: true
6
+ value: true
5
7
  });
8
+ exports["default"] = void 0;
6
9
 
7
- var _extends = Object.assign || 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; };
10
+ var _react = _interopRequireDefault(require("react"));
8
11
 
9
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
12
+ var _button = _interopRequireDefault(require("antd/lib/button"));
10
13
 
11
- var _react = require('react');
14
+ var _input = _interopRequireDefault(require("antd/lib/input"));
12
15
 
13
- var _react2 = _interopRequireDefault(_react);
16
+ var _message = _interopRequireDefault(require("antd/lib/message"));
14
17
 
15
- require('./VtxSearchMap.less');
18
+ var _checkbox = _interopRequireDefault(require("antd/lib/checkbox"));
16
19
 
17
- var _button = require('antd/lib/button');
20
+ var _VtxModal = require("../VtxModal");
18
21
 
19
- var _button2 = _interopRequireDefault(_button);
22
+ var _VtxMap = require("../VtxMap");
20
23
 
21
- require('antd/lib/button/style');
24
+ var _default2 = _interopRequireWildcard(require("../default"));
22
25
 
23
- var _input = require('antd/lib/input');
26
+ var _mapping = require("./mapping");
24
27
 
25
- var _input2 = _interopRequireDefault(_input);
28
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
26
29
 
27
- require('antd/lib/input/style');
30
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
31
 
29
- var _message = require('antd/lib/message');
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
30
33
 
31
- var _message2 = _interopRequireDefault(_message);
34
+ 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); }
32
35
 
33
- require('antd/lib/message/style');
36
+ 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; }
34
37
 
35
- var _checkbox = require('antd/lib/checkbox');
38
+ 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; }
36
39
 
37
- var _checkbox2 = _interopRequireDefault(_checkbox);
40
+ 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; }
38
41
 
39
- require('antd/lib/checkbox/style');
42
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
40
43
 
41
- var _VtxModal = require('../VtxModal');
44
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
42
45
 
43
- var _VtxMap = require('../VtxMap');
46
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
44
47
 
45
- var _default = require('../default');
48
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
46
49
 
47
- var _default2 = _interopRequireDefault(_default);
50
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
48
51
 
49
- var _mapping = require('./mapping');
52
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
50
53
 
51
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
54
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
52
55
 
53
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
56
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
54
57
 
55
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
58
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
56
59
 
57
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
60
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
58
61
 
59
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
62
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
60
63
 
61
- var styles = {
62
- searchModal: 'vtx-ui-searchmap-searchmodal',
63
- searchMap: 'vtx-ui-searchmap-searchmap',
64
- top: 'vtx-ui-searchmap-top',
65
- bottom: 'vtx-ui-searchmap-bottom',
66
- content: 'vtx-ui-searchmap-content',
67
- show: 'vtx-ui-searchmap-show',
68
- hidden: 'vtx-ui-searchmap-hidden',
69
- w_l: 'vtx-ui-searchmap-w_l',
70
- content_left: 'vtx-ui-searchmap-content_left',
71
- listTitle: 'vtx-ui-searchmap-listtitle',
72
- title: 'vtx-ui-searchmap-title',
73
- btn: 'vtx-ui-searchmap-btn',
74
- lists: 'vtx-ui-searchmap-lists',
75
- select: 'vtx-ui-searchmap-select',
76
- scrollauto: 'vtx-ui-searchmap-scrollauto',
77
- content_right: 'vtx-ui-searchmap-content_right',
78
- showLabel: 'vtx-ui-searchmap-showlabel',
79
- hiddenLabel: 'vtx-ui-searchmap-hiddenlabel',
80
- otherModal: 'vtx-ui-searchmap-othermodal'
81
- };
82
- // import Icon from 'antd/lib/icon';
83
- // import 'antd/lib/icon/style/css';
64
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
84
65
 
85
- //公共地址配置
66
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
86
67
 
68
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
87
69
 
88
- // message.config({
70
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
71
+
72
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
73
+
74
+ var styles = {
75
+ searchModal: 'vtx-ui-searchmap-searchmodal',
76
+ searchMap: 'vtx-ui-searchmap-searchmap',
77
+ top: 'vtx-ui-searchmap-top',
78
+ bottom: 'vtx-ui-searchmap-bottom',
79
+ content: 'vtx-ui-searchmap-content',
80
+ show: 'vtx-ui-searchmap-show',
81
+ hidden: 'vtx-ui-searchmap-hidden',
82
+ w_l: 'vtx-ui-searchmap-w_l',
83
+ content_left: 'vtx-ui-searchmap-content_left',
84
+ listTitle: 'vtx-ui-searchmap-listtitle',
85
+ title: 'vtx-ui-searchmap-title',
86
+ btn: 'vtx-ui-searchmap-btn',
87
+ lists: 'vtx-ui-searchmap-lists',
88
+ select: 'vtx-ui-searchmap-select',
89
+ scrollauto: 'vtx-ui-searchmap-scrollauto',
90
+ content_right: 'vtx-ui-searchmap-content_right',
91
+ showLabel: 'vtx-ui-searchmap-showlabel',
92
+ hiddenLabel: 'vtx-ui-searchmap-hiddenlabel',
93
+ otherModal: 'vtx-ui-searchmap-othermodal'
94
+ }; // message.config({
89
95
  // top: document.getElementById('root').offsetHeight/3,
90
96
  // duration: 5,
91
97
  // });
98
+
92
99
  var warning = function warning() {
93
- _message2.default.warning('位置点查询失败,请缩小比例尺或切换关键字后再重新查询!');
100
+ _message["default"].warning('位置点查询失败,请缩小比例尺或切换关键字后再重新查询!');
94
101
  };
102
+
95
103
  function distinct(ary) {
96
- var pts = [].concat(_toConsumableArray(ary));
97
- if (pts[0][0] == pts[pts.length - 1][0] && pts[0][1] == pts[pts.length - 1][1]) {
98
- pts.pop();
99
- return distinct(pts);
100
- } else {
101
- return pts;
102
- }
104
+ var pts = _toConsumableArray(ary);
105
+
106
+ if (pts[0][0] == pts[pts.length - 1][0] && pts[0][1] == pts[pts.length - 1][1]) {
107
+ pts.pop();
108
+ return distinct(pts);
109
+ } else {
110
+ return pts;
111
+ }
103
112
  }
104
113
 
105
114
  var getIcon = function getIcon(type) {
106
- return _default.antdMajorVersion === '4' ? _react2.default.createElement(_default.VtxMapIcon, { type: 'icon-' + _mapping.iconMapping[type] }) : type;
115
+ return _default2.antdMajorVersion === '4' ? /*#__PURE__*/_react["default"].createElement(_default2.VtxMapIcon, {
116
+ type: "icon-".concat(_mapping.iconMapping[type])
117
+ }) : type;
107
118
  };
108
119
 
109
- var VtxSearchMap = function (_React$Component) {
110
- _inherits(VtxSearchMap, _React$Component);
111
-
112
- function VtxSearchMap(props) {
113
- _classCallCheck(this, VtxSearchMap);
114
-
115
- var _this = _possibleConstructorReturn(this, (VtxSearchMap.__proto__ || Object.getPrototypeOf(VtxSearchMap)).call(this, props));
116
-
117
- _this.map = null; //Map组件的ref对象
118
- _this.mapLoaded = false;
119
- _this.isDrawStatus = false;
120
- _this.isClickMap = false;
121
- _this.apid = []; //所有点id,除编辑点外
122
- _this.loadExtent = null;
123
- _this.mapId = 'searchMap' + new Date().getTime();
124
- _this.state = {
125
- //列表和地图宽度切换的动画需要
126
- isShowList: false,
127
- //可拖动用于定位的点
128
- locationPoint: [],
129
- //搜索框文字
130
- searchValue: '',
131
- //搜索出来的列表点位
132
- listPoint: [],
133
- //列表数据
134
- listMess: [],
135
- // 返回点位/图形
136
- graphicType: props.graphicType || 'point',
137
- isDraw: props.graphicType !== 'point',
138
- parameter: props.drawParameter,
139
- graphicValue: null,
140
- drawGraphID: 'drawnGraph',
141
- /*地图Api参数*/
142
- mapCenter: props.mapCenter || '',
143
- maxZoom: props.maxZoom,
144
- minZoom: props.minZoom,
145
- wkid: props.wkid,
146
- mapType: props.mapType || 'bmap',
147
- mapServer: props.mapServer,
148
- setCenter: false,
149
- mapVisiblePoints: {
150
- fitView: [],
151
- type: 'all'
152
- },
153
- setVisiblePoints: false,
154
- isDoEdit: false,
155
- isEndEdit: false,
156
- editGraphicId: '',
157
- editGraphic: null,
158
- mapZoomLevel: props.mapZoomLevel || 11,
159
- setZoomLevel: false,
160
- /*modal参数*/
161
- modal1Visible: props.modal1Visible || false,
162
- isShowOther: props.isShowOther || false,
163
- otherText: props.otherText || '显示服务区域',
164
- isShowOtherGraph: props.isShowOther || false,
165
- // openlayer
166
- olProps: props.olProps
167
- };
168
- return _this;
169
- }
170
- //经纬度回调
171
-
172
-
173
- _createClass(VtxSearchMap, [{
174
- key: 'callback',
175
- value: function callback() {
176
- var fun = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'callback';
177
-
178
- if (fun in this.props && typeof this.props[fun] === 'function') {
179
- var editGraphicId = this.state.editGraphicId;
180
-
181
- switch (this.state.graphicType) {
182
- case 'point':
183
- var locationPoint = this.state.locationPoint;
184
-
185
- if (this.map.getGraphic('locationPoint')) {
186
- var p = this.map.getGraphic(locationPoint[0].id).geometry;
187
- this.props[fun]([p.x, p.y]);
188
- } else {
189
- return [];
190
- }
191
- break;
192
- case 'circle':
193
- this.props[fun](this.state.graphicValue ? {
194
- x: this.state.graphicValue.geometry.x,
195
- y: this.state.graphicValue.geometry.y,
196
- radius: this.state.graphicValue.geometry.radius,
197
- area: this.state.graphicValue.area
198
- } : null);
199
- break;
200
- case 'polygon':
201
- if (this.map.getGraphic(editGraphicId)) {
202
- var _p = this.map.getGraphic(editGraphicId);
203
- this.props[fun]({
204
- rings: distinct(_p.geometry.rings),
205
- area: this.map.getPolygonArea(distinct(_p.geometry.rings))
206
- });
207
- } else {
208
- this.props[fun](this.state.graphicValue ? {
209
- rings: distinct(this.state.graphicValue.geometry.rings),
210
- area: this.state.graphicValue.area
211
- } : null);
212
- }
213
- break;
214
- case 'rectangle':
215
- this.props[fun](this.state.graphicValue ? {
216
- rings: distinct(this.state.graphicValue.geometry.rings),
217
- area: this.state.graphicValue.area
218
- } : null);
219
- break;
220
- case 'polyline':
221
- if (this.map.getGraphic(editGraphicId)) {
222
- var _p2 = this.map.getGraphic(editGraphicId);
223
- this.props[fun]({
224
- paths: _p2.geometry.paths,
225
- length: this.map.calculateDistance(_p2.geometry.paths)
226
- });
227
- } else {
228
- this.props[fun](this.state.graphicValue ? {
229
- paths: this.state.graphicValue.geometry.paths,
230
- length: this.map.calculateDistance(this.state.graphicValue.geometry.paths)
231
- } : null);
232
- }
233
- break;
234
- }
120
+ var VtxSearchMap = /*#__PURE__*/function (_React$Component) {
121
+ _inherits(VtxSearchMap, _React$Component);
122
+
123
+ var _super = _createSuper(VtxSearchMap);
124
+
125
+ function VtxSearchMap(props) {
126
+ var _this;
127
+
128
+ _classCallCheck(this, VtxSearchMap);
129
+
130
+ _this = _super.call(this, props);
131
+ _this.map = null; //Map组件的ref对象
132
+
133
+ _this.mapLoaded = false;
134
+ _this.isDrawStatus = false;
135
+ _this.isClickMap = false;
136
+ _this.apid = []; //所有点id,除编辑点外
137
+
138
+ _this.loadExtent = null;
139
+ _this.mapId = "searchMap".concat(new Date().getTime());
140
+ _this.state = {
141
+ //列表和地图宽度切换的动画需要
142
+ isShowList: false,
143
+ //可拖动用于定位的点
144
+ locationPoint: [],
145
+ //搜索框文字
146
+ searchValue: '',
147
+ //搜索出来的列表点位
148
+ listPoint: [],
149
+ //列表数据
150
+ listMess: [],
151
+ // 返回点位/图形
152
+ graphicType: props.graphicType || 'point',
153
+ isDraw: props.graphicType !== 'point',
154
+ parameter: props.drawParameter,
155
+ graphicValue: null,
156
+ drawGraphID: 'drawnGraph',
157
+
158
+ /*地图Api参数*/
159
+ mapCenter: props.mapCenter || '',
160
+ maxZoom: props.maxZoom,
161
+ minZoom: props.minZoom,
162
+ wkid: props.wkid,
163
+ mapType: props.mapType || 'bmap',
164
+ mapStyle: props.mapStyle,
165
+ mapServer: props.mapServer,
166
+ setCenter: false,
167
+ mapVisiblePoints: {
168
+ fitView: [],
169
+ type: 'all'
170
+ },
171
+ setVisiblePoints: false,
172
+ isDoEdit: false,
173
+ isEndEdit: false,
174
+ editGraphicId: '',
175
+ editGraphic: null,
176
+ mapZoomLevel: props.mapZoomLevel || 11,
177
+ setZoomLevel: false,
178
+
179
+ /*modal参数*/
180
+ modal1Visible: props.modal1Visible || false,
181
+ isShowOther: props.isShowOther || false,
182
+ otherText: props.otherText || '显示服务区域',
183
+ isShowOtherGraph: props.isShowOther || false,
184
+ // openlayer
185
+ olProps: props.olProps
186
+ };
187
+ return _this;
188
+ } //经纬度回调
189
+
190
+
191
+ _createClass(VtxSearchMap, [{
192
+ key: "callback",
193
+ value: function callback() {
194
+ var fun = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'callback';
195
+
196
+ if (fun in this.props && typeof this.props[fun] === 'function') {
197
+ var editGraphicId = this.state.editGraphicId;
198
+
199
+ switch (this.state.graphicType) {
200
+ case 'point':
201
+ var locationPoint = this.state.locationPoint;
202
+
203
+ if (this.map.getGraphic('locationPoint')) {
204
+ var p = this.map.getGraphic(locationPoint[0].id).geometry;
205
+ this.props[fun]([p.x, p.y]);
206
+ } else {
207
+ return [];
235
208
  }
236
- if (this.props.clearDrawnGraph) {
237
- this.clearDrawnGraph();
209
+
210
+ break;
211
+
212
+ case 'circle':
213
+ this.props[fun](this.state.graphicValue ? {
214
+ x: this.state.graphicValue.geometry.x,
215
+ y: this.state.graphicValue.geometry.y,
216
+ radius: this.state.graphicValue.geometry.radius,
217
+ area: this.state.graphicValue.area
218
+ } : null);
219
+ break;
220
+
221
+ case 'polygon':
222
+ if (this.map.getGraphic(editGraphicId)) {
223
+ var _p = this.map.getGraphic(editGraphicId);
224
+
225
+ this.props[fun]({
226
+ rings: distinct(_p.geometry.rings),
227
+ area: this.map.getPolygonArea(distinct(_p.geometry.rings))
228
+ });
229
+ } else {
230
+ this.props[fun](this.state.graphicValue ? {
231
+ rings: distinct(this.state.graphicValue.geometry.rings),
232
+ area: this.state.graphicValue.area
233
+ } : null);
238
234
  }
239
- }
240
- }, {
241
- key: 'showOrhidden',
242
- value: function showOrhidden(bealoon) {
243
- this.setState({
244
- isShowList: bealoon
245
- });
246
- }
247
- //绘制定位点(以当前的中心点位参照 => 同时开启点位编辑)
248
-
249
- }, {
250
- key: 'drawLocationPoint',
251
- value: function drawLocationPoint() {
252
- var t = this;
253
- //判断arcgis,是: 判断中心点是否已经确定,确定,继续走逻辑.不确认.轮询等待
254
- if (this.props.mapType !== 'gmap' || this.map.state.gis.extent && !!this.map.state.gis.extent.xmax) {
255
- var lglt = this.map.getMapExtent(),
256
- editGraphic = null,
257
- editGraphicId = 'locationPoint';
258
- if (this.props.editParam) {
259
- // && (this.props.graphicType == 'polyline' || this.props.graphicType == 'polygon')
260
- editGraphic = _extends({}, this.props.editParam, { id: 'drawnGraph' });
261
- editGraphicId = 'drawnGraph';
262
- }
263
- this.isinit = false;
264
- this.setState({
265
- editGraphic: editGraphic,
266
- locationPoint: [{
267
- id: 'locationPoint',
268
- longitude: (t.props.mapCenter || [])[0] || lglt.nowCenter.lng,
269
- latitude: (t.props.mapCenter || [])[1] || lglt.nowCenter.lat,
270
- url: _default2.default.mapServerURL + '/images/defaultMarker.png',
271
- config: {
272
- zIndex: 1000
273
- }
274
- }]
275
- }, function () {
276
- t.setState({
277
- isDoEdit: true,
278
- editGraphicId: editGraphicId
279
- }, function () {
280
- setTimeout(function () {
281
- t.setState({
282
- isDoEdit: false
283
- });
284
- }, 500);
285
- });
286
- });
235
+
236
+ break;
237
+
238
+ case 'rectangle':
239
+ this.props[fun](this.state.graphicValue ? {
240
+ rings: distinct(this.state.graphicValue.geometry.rings),
241
+ area: this.state.graphicValue.area
242
+ } : null);
243
+ break;
244
+
245
+ case 'polyline':
246
+ if (this.map.getGraphic(editGraphicId)) {
247
+ var _p2 = this.map.getGraphic(editGraphicId);
248
+
249
+ this.props[fun]({
250
+ paths: _p2.geometry.paths,
251
+ length: this.map.calculateDistance(_p2.geometry.paths)
252
+ });
287
253
  } else {
288
- t.loadExtent = setTimeout(function () {
289
- t.drawLocationPoint();
290
- }, 50);
254
+ this.props[fun](this.state.graphicValue ? {
255
+ paths: this.state.graphicValue.geometry.paths,
256
+ length: this.map.calculateDistance(this.state.graphicValue.geometry.paths)
257
+ } : null);
291
258
  }
259
+
260
+ break;
292
261
  }
293
- //校正定位的点位位置到当前的中心点
294
-
295
- }, {
296
- key: 'correction',
297
- value: function correction() {
298
- var t = this;
299
- //获取当前中心点经纬度
300
- var lglt = this.map.getMapExtent();
301
- var locationPoint = t.state.locationPoint;
302
-
303
- locationPoint = locationPoint.map(function (item, index) {
304
- return _extends({}, item, {
305
- longitude: lglt.nowCenter.lng,
306
- latitude: lglt.nowCenter.lat
307
- });
308
- });
309
- this.map.updatePoint(locationPoint);
262
+ }
263
+
264
+ if (this.props.clearDrawnGraph) {
265
+ this.clearDrawnGraph();
266
+ }
267
+ }
268
+ }, {
269
+ key: "showOrhidden",
270
+ value: function showOrhidden(bealoon) {
271
+ this.setState({
272
+ isShowList: bealoon
273
+ });
274
+ } //绘制定位点(以当前的中心点位参照 => 同时开启点位编辑)
275
+
276
+ }, {
277
+ key: "drawLocationPoint",
278
+ value: function drawLocationPoint() {
279
+ var t = this; //判断arcgis,是: 判断中心点是否已经确定,确定,继续走逻辑.不确认.轮询等待
280
+
281
+ if (this.props.mapType !== 'gmap' || this.map.state.gis.extent && !!this.map.state.gis.extent.xmax) {
282
+ var lglt = this.map.getMapExtent(),
283
+ editGraphic = null,
284
+ editGraphicId = 'locationPoint';
285
+
286
+ if (this.props.editParam) {
287
+ // && (this.props.graphicType == 'polyline' || this.props.graphicType == 'polygon')
288
+ editGraphic = _objectSpread(_objectSpread({}, this.props.editParam), {}, {
289
+ id: 'drawnGraph'
290
+ });
291
+ editGraphicId = 'drawnGraph';
310
292
  }
311
- //搜索关键字切换
312
293
 
313
- }, {
314
- key: 'changeValue',
315
- value: function changeValue(e) {
316
- this.setState({
317
- searchValue: e.target.value
294
+ this.isinit = false;
295
+ this.setState({
296
+ editGraphic: editGraphic,
297
+ locationPoint: [{
298
+ id: 'locationPoint',
299
+ longitude: (t.props.mapCenter || [])[0] || lglt.nowCenter.lng,
300
+ latitude: (t.props.mapCenter || [])[1] || lglt.nowCenter.lat,
301
+ // url: `${configUrl.mapServerURL}/images/defaultMarker.png`,
302
+ url: require("../VtxMap/images/defaultMarker.png"),
303
+ config: {
304
+ zIndex: 1000
305
+ }
306
+ }]
307
+ }, function () {
308
+ t.setState({
309
+ isDoEdit: true,
310
+ editGraphicId: editGraphicId
311
+ }, function () {
312
+ setTimeout(function () {
313
+ t.setState({
314
+ isDoEdit: false
315
+ });
316
+ }, 500);
317
+ });
318
+ });
319
+ } else {
320
+ t.loadExtent = setTimeout(function () {
321
+ t.drawLocationPoint();
322
+ }, 50);
323
+ }
324
+ } //校正定位的点位位置到当前的中心点
325
+
326
+ }, {
327
+ key: "correction",
328
+ value: function correction() {
329
+ var t = this; //获取当前中心点经纬度
330
+
331
+ var lglt = this.map.getMapExtent();
332
+ var locationPoint = t.state.locationPoint;
333
+ locationPoint = locationPoint.map(function (item, index) {
334
+ return _objectSpread(_objectSpread({}, item), {}, {
335
+ longitude: lglt.nowCenter.lng,
336
+ latitude: lglt.nowCenter.lat
337
+ });
338
+ });
339
+ this.map.updatePoint(locationPoint);
340
+ } //搜索关键字切换
341
+
342
+ }, {
343
+ key: "changeValue",
344
+ value: function changeValue(e) {
345
+ this.setState({
346
+ searchValue: e.target.value
347
+ });
348
+ } //根据关键字搜索数据
349
+
350
+ }, {
351
+ key: "searchList",
352
+ value: function searchList() {
353
+ //因为antd组件问题,这边使用手动关键位,控制方法执行
354
+ var t = this;
355
+ var searchPoints = t.map.searchPoints(this.state.searchValue);
356
+ searchPoints.then(function (results) {
357
+ if (results.length > 0) {
358
+ var lsp = [],
359
+ lsm = [];
360
+ t.apid = [];
361
+
362
+ for (var i = 0; i < results.length; i++) {
363
+ var r = results[i];
364
+ lsp.push(_objectSpread(_objectSpread({}, results[i]), {}, {
365
+ // url: `${configUrl.mapServerURL}/images/defaultMarker_selected.png`,
366
+ url: require("../VtxMap/images/defaultMarker_selected.png"),
367
+ labelClass: styles.hiddenLabel
368
+ }));
369
+ lsm.push({
370
+ id: r.id,
371
+ title: r.config.labelContent,
372
+ isSelect: false
318
373
  });
374
+ t.apid.push(r.id);
375
+ }
376
+
377
+ t.setState({
378
+ listPoint: lsp,
379
+ listMess: lsm,
380
+ isShowList: true
381
+ });
382
+ t.setFitView();
383
+ } else {
384
+ warning();
319
385
  }
320
- //根据关键字搜索数据
321
-
322
- }, {
323
- key: 'searchList',
324
- value: function searchList() {
325
- //因为antd组件问题,这边使用手动关键位,控制方法执行
326
- var t = this;
327
- var searchPoints = t.map.searchPoints(this.state.searchValue);
328
- searchPoints.then(function (results) {
329
- if (results.length > 0) {
330
- var lsp = [],
331
- lsm = [];
332
- t.apid = [];
333
- for (var i = 0; i < results.length; i++) {
334
- var r = results[i];
335
- lsp.push(_extends({}, results[i], {
336
- url: _default2.default.mapServerURL + '/images/defaultMarker_selected.png',
337
- labelClass: styles.hiddenLabel
338
- }));
339
- lsm.push({
340
- id: r.id,
341
- title: r.config.labelContent,
342
- isSelect: false
343
- });
344
- t.apid.push(r.id);
345
- }
346
- t.setState({
347
- listPoint: lsp,
348
- listMess: lsm,
349
- isShowList: true
350
- });
351
- t.setFitView();
352
- } else {
353
- warning();
354
- }
355
- });
386
+ });
387
+ } //返回最佳位置(zoom,center)
388
+
389
+ }, {
390
+ key: "setFitView",
391
+ value: function setFitView() {
392
+ var _this2 = this;
393
+
394
+ this.setState({
395
+ mapVisiblePoints: {
396
+ fitView: this.apid,
397
+ type: 'all'
398
+ },
399
+ setVisiblePoints: true
400
+ }, function () {
401
+ _this2.setState({
402
+ setVisiblePoints: false
403
+ });
404
+ });
405
+ } //清空列表的所有数据(包括点位)
406
+
407
+ }, {
408
+ key: "clearList",
409
+ value: function clearList() {
410
+ this.apid = [];
411
+ this.setState({
412
+ searchValue: '',
413
+ listPoint: [],
414
+ listMess: [],
415
+ isShowList: false
416
+ });
417
+ } //列表选中地址
418
+
419
+ }, {
420
+ key: "chooseAddress",
421
+ value: function chooseAddress(id) {
422
+ var t = this;
423
+ var _this$state = this.state,
424
+ listPoint = _this$state.listPoint,
425
+ listMess = _this$state.listMess;
426
+ var mapCenter = [];
427
+ listPoint = listPoint.map(function (item, index) {
428
+ if (item.id === id) {
429
+ mapCenter = [item.longitude, item.latitude];
430
+ return _objectSpread(_objectSpread({}, item), {}, {
431
+ labelClass: styles.showLabel
432
+ });
433
+ } else {
434
+ return _objectSpread(_objectSpread({}, item), {}, {
435
+ labelClass: styles.hiddenLabel
436
+ });
356
437
  }
357
- //返回最佳位置(zoom,center)
358
-
359
- }, {
360
- key: 'setFitView',
361
- value: function setFitView() {
362
- var _this2 = this;
363
-
364
- this.setState({
365
- mapVisiblePoints: {
366
- fitView: this.apid,
367
- type: 'all'
368
- },
369
- setVisiblePoints: true
370
- }, function () {
371
- _this2.setState({
372
- setVisiblePoints: false
373
- });
374
- });
438
+ });
439
+ listMess = listMess.map(function (item, index) {
440
+ if (item.id === id) {
441
+ return _objectSpread(_objectSpread({}, item), {}, {
442
+ isSelect: true
443
+ });
444
+ } else {
445
+ return _objectSpread(_objectSpread({}, item), {}, {
446
+ isSelect: false
447
+ });
375
448
  }
376
- //清空列表的所有数据(包括点位)
377
-
378
- }, {
379
- key: 'clearList',
380
- value: function clearList() {
381
- this.apid = [];
382
- this.setState({
383
- searchValue: '',
384
- listPoint: [],
385
- listMess: [],
386
- isShowList: false
387
- });
449
+ });
450
+ this.setState({
451
+ listPoint: listPoint,
452
+ listMess: listMess,
453
+ mapCenter: mapCenter,
454
+ setCenter: true
455
+ }, function () {
456
+ t.setState({
457
+ setCenter: false
458
+ });
459
+
460
+ if (t.state.graphicType == 'point') {
461
+ t.correction();
388
462
  }
389
- //列表选中地址
390
-
391
- }, {
392
- key: 'chooseAddress',
393
- value: function chooseAddress(id) {
394
- var t = this;
395
- var _state = this.state,
396
- listPoint = _state.listPoint,
397
- listMess = _state.listMess;
398
-
399
- var mapCenter = [];
400
- listPoint = listPoint.map(function (item, index) {
401
- if (item.id === id) {
402
- mapCenter = [item.longitude, item.latitude];
403
- return _extends({}, item, {
404
- labelClass: styles.showLabel
405
- });
406
- } else {
407
- return _extends({}, item, {
408
- labelClass: styles.hiddenLabel
409
- });
410
- }
411
- });
412
- listMess = listMess.map(function (item, index) {
413
- if (item.id === id) {
414
- return _extends({}, item, {
415
- isSelect: true
416
- });
417
- } else {
418
- return _extends({}, item, {
419
- isSelect: false
420
- });
421
- }
422
- });
423
- this.setState({
424
- listPoint: listPoint,
425
- listMess: listMess,
426
- mapCenter: mapCenter,
427
- setCenter: true
428
- }, function () {
429
- t.setState({
430
- setCenter: false
431
- });
432
- if (t.state.graphicType == 'point') {
433
- t.correction();
434
- }
463
+ });
464
+ }
465
+ }, {
466
+ key: "clickGraphic",
467
+ value: function clickGraphic(obj) {
468
+ if (obj.type === 'point' && obj.attributes.other === 'search') {
469
+ this.chooseAddress(obj.attributes.id);
470
+ }
471
+ }
472
+ }, {
473
+ key: "closeModal",
474
+ value: function closeModal(e) {
475
+ if (this.isDrawStatus && this.isClickMap) {
476
+ _message["default"].warning('请双击结束图元编辑');
477
+ } else {
478
+ if ('closeModal' in this.props) {
479
+ this.props.closeModal();
480
+ } else {
481
+ this.setState({
482
+ modal1Visible: false
483
+ });
484
+ } // if(this.props.clearDrawnGraph){
485
+
486
+
487
+ this.clearDrawnGraph(); // }
488
+ }
489
+ }
490
+ }, {
491
+ key: "clearDrawnGraph",
492
+ value: function clearDrawnGraph() {
493
+ var _this3 = this;
494
+
495
+ this.isDrawStatus = true;
496
+ this.setState({
497
+ isDraw: this.state.graphicType !== 'point',
498
+ graphicValue: null,
499
+ isEndEdit: this.state.graphicType !== 'point'
500
+ }, function () {
501
+ _this3.setState({
502
+ isEndEdit: false
503
+ });
504
+ });
505
+ }
506
+ }, {
507
+ key: "render",
508
+ value: function render() {
509
+ var _this4 = this;
510
+
511
+ var t = this;
512
+ var _this$state2 = this.state,
513
+ isShowList = _this$state2.isShowList,
514
+ searchValue = _this$state2.searchValue,
515
+ locationPoint = _this$state2.locationPoint,
516
+ listPoint = _this$state2.listPoint,
517
+ listMess = _this$state2.listMess,
518
+ mapZoomLevel = _this$state2.mapZoomLevel,
519
+ setZoomLevel = _this$state2.setZoomLevel,
520
+ maxZoom = _this$state2.maxZoom,
521
+ minZoom = _this$state2.minZoom,
522
+ wkid = _this$state2.wkid,
523
+ mapServer = _this$state2.mapServer,
524
+ mapCenter = _this$state2.mapCenter,
525
+ setCenter = _this$state2.setCenter,
526
+ mapType = _this$state2.mapType,
527
+ mapStyle = _this$state2.mapStyle,
528
+ mapVisiblePoints = _this$state2.mapVisiblePoints,
529
+ setVisiblePoints = _this$state2.setVisiblePoints,
530
+ isDoEdit = _this$state2.isDoEdit,
531
+ editGraphicId = _this$state2.editGraphicId,
532
+ isEndEdit = _this$state2.isEndEdit,
533
+ modal1Visible = _this$state2.modal1Visible,
534
+ drawGraphID = _this$state2.drawGraphID,
535
+ isShowOther = _this$state2.isShowOther,
536
+ otherText = _this$state2.otherText,
537
+ isShowOtherGraph = _this$state2.isShowOtherGraph,
538
+ editGraphic = _this$state2.editGraphic,
539
+ graphicType = _this$state2.graphicType,
540
+ olProps = _this$state2.olProps;
541
+ var InputProps = {
542
+ style: {
543
+ 'width': '200px'
544
+ },
545
+ placeholder: '输入关键字',
546
+ value: searchValue,
547
+ onChange: this.changeValue.bind(this),
548
+ onPressEnter: this.searchList.bind(this),
549
+ onKeyDown: this.changeValue.bind(this)
550
+ };
551
+ var drawProps = this.state.graphicType == 'point' || t.isinit ? {
552
+ isDraw: this.state.isDraw,
553
+ isCloseDraw: this.state.isCloseDraw
554
+ } : {
555
+ isDraw: this.state.isDraw,
556
+ isCloseDraw: this.state.isCloseDraw,
557
+ drawEnd: function drawEnd(obj) {
558
+ _this4.isDrawStatus = false;
559
+ _this4.isClickMap = false;
560
+ var objparam = {
561
+ graphicValue: obj,
562
+ isDraw: false
563
+ };
564
+
565
+ if (obj.geometryType == 'polyline' || obj.geometryType == 'polygon') {
566
+ objparam.editGraphicId = obj.id;
567
+ objparam.isDoEdit = true;
568
+ }
569
+
570
+ _this4.setState(objparam, function () {
571
+ _this4.setState({
572
+ isDoEdit: false
435
573
  });
574
+ });
575
+ },
576
+ mapDraw: {
577
+ geometryType: this.state.graphicType,
578
+ parameter: this.state.parameter || (this.state.graphicType == 'polyline' ? {
579
+ color: '#108edf',
580
+ //线颜色,
581
+ pellucidity: 1,
582
+ //线透明度,
583
+ lineWidth: 3,
584
+ //线宽度
585
+ lineType: 'solid'
586
+ } : this.state.graphicType == 'polygon' || this.state.graphicType == 'circle' || this.state.graphicType == 'rectangle' ? {
587
+ color: '#ffffff',
588
+ //填充色,
589
+ lineColor: '#108edf',
590
+ //线颜色,
591
+ lineOpacity: 1,
592
+ //线透明度,
593
+ lineWidth: 3,
594
+ //线宽度,
595
+ pellucidity: 0.8,
596
+ //填充透明度
597
+ lineType: 'solid'
598
+ } : {}),
599
+ data: {
600
+ id: drawGraphID
601
+ }
436
602
  }
437
- }, {
438
- key: 'clickGraphic',
439
- value: function clickGraphic(obj) {
440
- if (obj.type === 'point' && obj.attributes.other === 'search') {
441
- this.chooseAddress(obj.attributes.id);
442
- }
603
+ };
604
+ var mapPoints = [],
605
+ mapLines = [],
606
+ mapPolygons = [],
607
+ mapCircles = [];
608
+
609
+ if (graphicType == 'point') {
610
+ mapPoints = [].concat(_toConsumableArray(locationPoint), _toConsumableArray(listPoint));
611
+ } else {
612
+ mapPoints = _toConsumableArray(listPoint);
613
+ }
614
+
615
+ if (graphicType === 'polygon') {
616
+ if (editGraphic) {
617
+ mapPolygons.push(editGraphic);
618
+ drawProps = null;
443
619
  }
444
- }, {
445
- key: 'closeModal',
446
- value: function closeModal(e) {
447
- if (this.isDrawStatus && this.isClickMap) {
448
- _message2.default.warning('请双击结束图元编辑');
449
- } else {
450
- if ('closeModal' in this.props) {
451
- this.props.closeModal();
452
- } else {
453
- this.setState({
454
- modal1Visible: false
455
- });
456
- }
457
- // if(this.props.clearDrawnGraph){
458
- this.clearDrawnGraph();
459
- // }
460
- }
620
+ }
621
+
622
+ if (graphicType === 'polyline') {
623
+ if (editGraphic) {
624
+ mapLines.push(editGraphic);
625
+ drawProps = null;
461
626
  }
462
- }, {
463
- key: 'clearDrawnGraph',
464
- value: function clearDrawnGraph() {
465
- var _this3 = this;
466
-
467
- this.isDrawStatus = true;
468
- this.setState({
469
- isDraw: this.state.graphicType !== 'point',
470
- graphicValue: null,
471
- isEndEdit: this.state.graphicType !== 'point'
472
- }, function () {
473
- _this3.setState({ isEndEdit: false });
474
- });
627
+ }
628
+
629
+ if (graphicType === 'rectangle') {
630
+ if (editGraphic) {
631
+ mapPolygons.push(editGraphic);
632
+ drawProps = null;
475
633
  }
476
- }, {
477
- key: 'render',
478
- value: function render() {
479
- var _this4 = this;
480
-
481
- var t = this;
482
- var _state2 = this.state,
483
- isShowList = _state2.isShowList,
484
- searchValue = _state2.searchValue,
485
- locationPoint = _state2.locationPoint,
486
- listPoint = _state2.listPoint,
487
- listMess = _state2.listMess,
488
- mapZoomLevel = _state2.mapZoomLevel,
489
- setZoomLevel = _state2.setZoomLevel,
490
- maxZoom = _state2.maxZoom,
491
- minZoom = _state2.minZoom,
492
- wkid = _state2.wkid,
493
- mapServer = _state2.mapServer,
494
- mapCenter = _state2.mapCenter,
495
- setCenter = _state2.setCenter,
496
- mapType = _state2.mapType,
497
- mapVisiblePoints = _state2.mapVisiblePoints,
498
- setVisiblePoints = _state2.setVisiblePoints,
499
- isDoEdit = _state2.isDoEdit,
500
- editGraphicId = _state2.editGraphicId,
501
- isEndEdit = _state2.isEndEdit,
502
- modal1Visible = _state2.modal1Visible,
503
- drawGraphID = _state2.drawGraphID,
504
- isShowOther = _state2.isShowOther,
505
- otherText = _state2.otherText,
506
- isShowOtherGraph = _state2.isShowOtherGraph,
507
- editGraphic = _state2.editGraphic,
508
- graphicType = _state2.graphicType,
509
- olProps = _state2.olProps;
510
-
511
- var InputProps = {
512
- style: { 'width': '200px' },
513
- placeholder: '输入关键字',
514
- value: searchValue,
515
- onChange: this.changeValue.bind(this),
516
- onPressEnter: this.searchList.bind(this),
517
- onKeyDown: this.changeValue.bind(this)
518
- };
519
- var drawProps = this.state.graphicType == 'point' || t.isinit ? {
520
- isDraw: this.state.isDraw,
521
- isCloseDraw: this.state.isCloseDraw
522
- } : {
523
- isDraw: this.state.isDraw,
524
- isCloseDraw: this.state.isCloseDraw,
525
- drawEnd: function drawEnd(obj) {
526
- _this4.isDrawStatus = false;
527
- _this4.isClickMap = false;
528
- var objparam = {
529
- graphicValue: obj,
530
- isDraw: false
531
- };
532
- if (obj.geometryType == 'polyline' || obj.geometryType == 'polygon') {
533
- objparam.editGraphicId = obj.id;
534
- objparam.isDoEdit = true;
535
- }
536
- _this4.setState(objparam, function () {
537
- _this4.setState({
538
- isDoEdit: false
539
- });
540
- });
541
- },
542
- mapDraw: {
543
- geometryType: this.state.graphicType,
544
- parameter: this.state.parameter || (this.state.graphicType == 'polyline' ? {
545
- color: '#108edf', //线颜色,
546
- pellucidity: 1, //线透明度,
547
- lineWidth: 3, //线宽度
548
- lineType: 'solid'
549
- } : this.state.graphicType == 'polygon' || this.state.graphicType == 'circle' || this.state.graphicType == 'rectangle' ? {
550
- color: '#ffffff', //填充色,
551
- lineColor: '#108edf', //线颜色,
552
- lineOpacity: 1, //线透明度,
553
- lineWidth: 3, //线宽度,
554
- pellucidity: 0.8, //填充透明度
555
- lineType: 'solid'
556
- } : {}),
557
- data: { id: drawGraphID }
558
- }
559
- };
560
- var mapPoints = [],
561
- mapLines = [],
562
- mapPolygons = [],
563
- mapCircles = [];
564
- if (graphicType == 'point') {
565
- mapPoints = [].concat(_toConsumableArray(locationPoint), _toConsumableArray(listPoint));
566
- } else {
567
- mapPoints = [].concat(_toConsumableArray(listPoint));
568
- }
569
- if (graphicType === 'polygon') {
570
- if (editGraphic) {
571
- mapPolygons.push(editGraphic);
572
- drawProps = null;
573
- }
574
- }
575
- if (graphicType === 'polyline') {
576
- if (editGraphic) {
577
- mapLines.push(editGraphic);
578
- drawProps = null;
579
- }
580
- }
581
- if (graphicType === 'rectangle') {
582
- if (editGraphic) {
583
- mapPolygons.push(editGraphic);
584
- drawProps = null;
585
- }
586
- }
587
- if (graphicType === 'circle') {
588
- if (editGraphic) {
589
- mapCircles.push(editGraphic);
590
- drawProps = null;
591
- }
592
- }
593
- if (isShowOtherGraph) {
594
- var otherGraph = this.props.otherGraph;
595
-
596
- if (otherGraph) {
597
- mapPoints = [].concat(_toConsumableArray(mapPoints), _toConsumableArray(otherGraph.point || []));
598
- mapLines = [].concat(_toConsumableArray(mapLines), _toConsumableArray(otherGraph.polyline || []));
599
- mapPolygons = [].concat(_toConsumableArray(mapPolygons), _toConsumableArray(otherGraph.polygon || []));
600
- mapCircles = [].concat(_toConsumableArray(mapCircles), _toConsumableArray(otherGraph.circle || []));
601
- }
602
- }
603
- return _react2.default.createElement(
604
- _VtxModal.VtxModal,
605
- {
606
- title: this.state.graphicType == 'point' ? "定位" : "绘制",
607
- style: { top: 50 },
608
- visible: modal1Visible,
609
- maximize: true,
610
- isNotMoving: true,
611
- wrapClassName: styles.searchModal,
612
- bodyStyle: { height: window.innerHeight * 0.7 + 'px' },
613
- maskClosable: false,
614
- onCancel: this.closeModal.bind(this),
615
- footer: _react2.default.createElement(
616
- 'div',
617
- { className: styles.bottom },
618
- _react2.default.createElement(
619
- _button2.default,
620
- { type: 'primary', onClick: function onClick() {
621
- _this4.callback();
622
- }, icon: getIcon('check') },
623
- '\u786E\u5B9A'
624
- ),
625
- _react2.default.createElement(
626
- _button2.default,
627
- { onClick: this.closeModal.bind(this), icon: getIcon('close') },
628
- '\u5173\u95ED'
629
- )
630
- )
631
- },
632
- _react2.default.createElement(
633
- 'div',
634
- { className: styles.searchMap },
635
- _react2.default.createElement(
636
- 'div',
637
- { className: styles.top },
638
- mapType == 'gmap' || mapType == 'olmap' ? '' : [_react2.default.createElement(_input2.default, _extends({ key: '1' }, InputProps)), _react2.default.createElement(
639
- _button2.default,
640
- { key: '2', type: 'primary', onClick: this.searchList.bind(this), icon: getIcon('search') },
641
- '\u67E5\u8BE2'
642
- ), _react2.default.createElement(
643
- _button2.default,
644
- { key: '3', onClick: this.clearList.bind(this), icon: getIcon('close') },
645
- '\u6E05\u7A7A'
646
- )],
647
- this.state.graphicType == 'point' ? _react2.default.createElement(
648
- _button2.default,
649
- { onClick: this.correction.bind(this), icon: getIcon('environment') },
650
- '\u6821\u6B63'
651
- ) : null,
652
- this.state.graphicType != 'point' ? _react2.default.createElement(
653
- _button2.default,
654
- { disabled: this.isDrawStatus, onClick: function onClick() {
655
- _this4.isDrawStatus = true;
656
- _this4.setState({
657
- isDraw: true,
658
- graphicValue: null,
659
- editGraphic: null,
660
- isEndEdit: true
661
- }, function () {
662
- t.map.removeGraphic('drawnGraph', 'draw');
663
- t.setState({
664
- isEndEdit: false
665
- });
666
- });
667
- _this4.callback('editDraw');
668
- }, icon: getIcon('edit') },
669
- '\u91CD\u65B0\u7ED8\u5236'
670
- ) : null,
671
- mapType == 'gmap' || mapType == 'olmap' ? '' : _react2.default.createElement(
672
- _button2.default,
673
- { onClick: this.setFitView.bind(this), icon: getIcon('sync') },
674
- '\u8FD4\u56DE\u5168\u5C40\u5730\u56FE'
675
- ),
676
- isShowOther ? _react2.default.createElement(
677
- 'div',
678
- { className: styles.otherModal },
679
- _react2.default.createElement(
680
- _checkbox2.default,
681
- { checked: isShowOtherGraph, onChange: function onChange(e) {
682
- _this4.setState({ isShowOtherGraph: e.target.checked });
683
- } },
684
- otherText
685
- )
686
- ) : ''
687
- ),
688
- _react2.default.createElement(
689
- 'div',
690
- { className: styles.content, style: { paddingLeft: mapType == 'gmap' || mapType == 'olmap' ? '0px' : '25px' } },
691
- mapType == 'gmap' || mapType == 'olmap' ? '' : _react2.default.createElement(
692
- 'div',
693
- { className: styles.content_left + ' ' + (isShowList ? styles.w_l : '') },
694
- _react2.default.createElement(
695
- 'div',
696
- { className: '' + (isShowList ? styles.show : styles.hidden) },
697
- _react2.default.createElement(
698
- 'div',
699
- { className: styles.listTitle },
700
- _react2.default.createElement(
701
- 'div',
702
- { className: styles.title },
703
- '\u67E5\u8BE2\u7ED3\u679C'
704
- ),
705
- _react2.default.createElement(
706
- 'div',
707
- { onClick: function onClick() {
708
- return _this4.showOrhidden(false);
709
- }, className: styles.btn },
710
- _react2.default.createElement(_default.VtxMapIcon, { type: 'icon-doubleleft' })
711
- )
712
- ),
713
- _react2.default.createElement(
714
- 'div',
715
- { className: styles.scrollauto },
716
- listMess.map(function (item, index) {
717
- return _react2.default.createElement(
718
- 'div',
719
- {
720
- key: index,
721
- onClick: function onClick() {
722
- return _this4.chooseAddress(item.id);
723
- },
724
- className: styles.lists + ' ' + (item.isSelect ? styles.select : '')
725
- },
726
- item.title
727
- );
728
- })
729
- )
730
- ),
731
- _react2.default.createElement(
732
- 'div',
733
- { onClick: function onClick() {
734
- return _this4.showOrhidden(true);
735
- }, className: styles.btn + ' ' + (!isShowList ? styles.show : styles.hidden) },
736
- _react2.default.createElement(_default.VtxMapIcon, { type: 'icon-doubleright' })
737
- )
738
- ),
739
- _react2.default.createElement(
740
- 'div',
741
- { className: styles.content_right },
742
- _react2.default.createElement(_VtxMap.VtxMap, _extends({
743
- getMapInstance: function getMapInstance(map) {
744
- if (map) _this4.map = map;
745
- },
746
- mapType: mapType,
747
- mapServer: mapServer,
748
- wkid: wkid,
749
- mapId: t.mapId,
750
- setCenter: setCenter,
751
- mapCenter: mapCenter,
752
- minZoom: minZoom,
753
- maxZoom: maxZoom,
754
- mapZoomLevel: mapZoomLevel,
755
- setZoomLevel: setZoomLevel,
756
- mapPoints: mapPoints,
757
- mapLines: mapLines,
758
- mapPolygons: mapPolygons,
759
- mapCircles: mapCircles,
760
- mapVisiblePoints: mapVisiblePoints,
761
- setVisiblePoints: setVisiblePoints,
762
- isDoEdit: isDoEdit,
763
- isEndEdit: isEndEdit,
764
- editGraphicId: editGraphicId,
765
- editGraphicChange: function editGraphicChange() {},
766
- clickGraphic: this.clickGraphic.bind(this),
767
- clickMap: function clickMap() {
768
- t.isClickMap = true;
769
- },
770
- olProps: olProps
771
- }, drawProps))
772
- )
773
- )
774
- )
775
- );
634
+ }
635
+
636
+ if (graphicType === 'circle') {
637
+ if (editGraphic) {
638
+ mapCircles.push(editGraphic);
639
+ drawProps = null;
776
640
  }
777
- }, {
778
- key: 'initSearchMap',
779
- value: function initSearchMap() {
780
- var _this5 = this;
781
-
782
- if (this.props.modal1Visible /*&& !this.state.locationPoint[0]*/) {
783
- if (this.map) {
784
- this.map.loadMapComplete.then(function () {
785
- if (!_this5.mapLoaded) {
786
- _this5.mapLoaded = true;
787
- _this5.drawLocationPoint();
788
- }
789
- });
790
- }
791
- }
641
+ }
642
+
643
+ if (isShowOtherGraph) {
644
+ var otherGraph = this.props.otherGraph;
645
+
646
+ if (otherGraph) {
647
+ mapPoints = [].concat(_toConsumableArray(mapPoints), _toConsumableArray(otherGraph.point || []));
648
+ mapLines = [].concat(_toConsumableArray(mapLines), _toConsumableArray(otherGraph.polyline || []));
649
+ mapPolygons = [].concat(_toConsumableArray(mapPolygons), _toConsumableArray(otherGraph.polygon || []));
650
+ mapCircles = [].concat(_toConsumableArray(mapCircles), _toConsumableArray(otherGraph.circle || []));
792
651
  }
793
- }, {
794
- key: 'componentDidMount',
795
- value: function componentDidMount() {
796
- //绘制定位点(以当前的中心点位参照=>初始化好后才有ref可以获取中心点)
797
- this.initSearchMap();
652
+ }
653
+
654
+ return /*#__PURE__*/_react["default"].createElement(_VtxModal.VtxModal, {
655
+ title: this.state.graphicType == 'point' ? "定位" : "绘制",
656
+ style: {
657
+ top: 50
658
+ },
659
+ visible: modal1Visible,
660
+ maximize: true,
661
+ isNotMoving: true,
662
+ wrapClassName: styles.searchModal,
663
+ bodyStyle: {
664
+ height: "".concat(window.innerHeight * 0.7, "px")
665
+ },
666
+ maskClosable: false,
667
+ onCancel: this.closeModal.bind(this),
668
+ footer: /*#__PURE__*/_react["default"].createElement("div", {
669
+ className: styles.bottom
670
+ }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
671
+ type: "primary",
672
+ onClick: function onClick() {
673
+ _this4.callback();
674
+ },
675
+ icon: getIcon('check')
676
+ }, "\u786E\u5B9A"), /*#__PURE__*/_react["default"].createElement(_button["default"], {
677
+ onClick: this.closeModal.bind(this),
678
+ icon: getIcon('close')
679
+ }, "\u5173\u95ED"))
680
+ }, /*#__PURE__*/_react["default"].createElement("div", {
681
+ className: styles.searchMap
682
+ }, /*#__PURE__*/_react["default"].createElement("div", {
683
+ className: styles.top
684
+ }, mapType == 'gmap' || mapType == 'olmap' ? '' : [/*#__PURE__*/_react["default"].createElement(_input["default"], _extends({
685
+ key: "1"
686
+ }, InputProps)), /*#__PURE__*/_react["default"].createElement(_button["default"], {
687
+ key: "2",
688
+ type: "primary",
689
+ onClick: this.searchList.bind(this),
690
+ icon: getIcon('search')
691
+ }, "\u67E5\u8BE2"), /*#__PURE__*/_react["default"].createElement(_button["default"], {
692
+ key: "3",
693
+ onClick: this.clearList.bind(this),
694
+ icon: getIcon('close')
695
+ }, "\u6E05\u7A7A")], this.state.graphicType == 'point' ? /*#__PURE__*/_react["default"].createElement(_button["default"], {
696
+ onClick: this.correction.bind(this),
697
+ icon: getIcon('environment')
698
+ }, "\u6821\u6B63") : null, this.state.graphicType != 'point' ? /*#__PURE__*/_react["default"].createElement(_button["default"], {
699
+ disabled: this.isDrawStatus,
700
+ onClick: function onClick() {
701
+ _this4.isDrawStatus = true;
702
+
703
+ _this4.setState({
704
+ isDraw: true,
705
+ graphicValue: null,
706
+ editGraphic: null,
707
+ isEndEdit: true
708
+ }, function () {
709
+ t.map.removeGraphic('drawnGraph', 'draw');
710
+ t.setState({
711
+ isEndEdit: false
712
+ });
713
+ });
714
+
715
+ _this4.callback('editDraw');
716
+ },
717
+ icon: getIcon('edit')
718
+ }, "\u91CD\u65B0\u7ED8\u5236") : null, mapType == 'gmap' || mapType == 'olmap' ? '' : /*#__PURE__*/_react["default"].createElement(_button["default"], {
719
+ onClick: this.setFitView.bind(this),
720
+ icon: getIcon('sync')
721
+ }, "\u8FD4\u56DE\u5168\u5C40\u5730\u56FE"), isShowOther ? /*#__PURE__*/_react["default"].createElement("div", {
722
+ className: styles.otherModal
723
+ }, /*#__PURE__*/_react["default"].createElement(_checkbox["default"], {
724
+ checked: isShowOtherGraph,
725
+ onChange: function onChange(e) {
726
+ _this4.setState({
727
+ isShowOtherGraph: e.target.checked
728
+ });
798
729
  }
799
- }, {
800
- key: 'componentDidUpdate',
801
- value: function componentDidUpdate(prevProps, prevState) {
802
- //重新渲染结束
803
- this.initSearchMap();
730
+ }, otherText)) : ''), /*#__PURE__*/_react["default"].createElement("div", {
731
+ className: styles.content,
732
+ style: {
733
+ paddingLeft: mapType == 'gmap' || mapType == 'olmap' ? '0px' : '25px'
804
734
  }
805
- }, {
806
- key: 'componentWillReceiveProps',
807
- value: function componentWillReceiveProps(nextProps) {
808
- var _this6 = this;
809
-
810
- var t = this;
811
- this.isClickMap = false;
812
- if (t.state.graphicType !== nextProps.graphicType && !!this.map) {
813
- this.map.clearAll();
814
- t.mapLoaded = false;
815
- t.isinit = true;
816
- }
817
- if (nextProps.editParam) {
818
- t.mapLoaded = false;
735
+ }, mapType == 'gmap' || mapType == 'olmap' ? '' : /*#__PURE__*/_react["default"].createElement("div", {
736
+ className: "".concat(styles.content_left, " ").concat(isShowList ? styles.w_l : '')
737
+ }, /*#__PURE__*/_react["default"].createElement("div", {
738
+ className: "".concat(isShowList ? styles.show : styles.hidden)
739
+ }, /*#__PURE__*/_react["default"].createElement("div", {
740
+ className: styles.listTitle
741
+ }, /*#__PURE__*/_react["default"].createElement("div", {
742
+ className: styles.title
743
+ }, "\u67E5\u8BE2\u7ED3\u679C"), /*#__PURE__*/_react["default"].createElement("div", {
744
+ onClick: function onClick() {
745
+ return _this4.showOrhidden(false);
746
+ },
747
+ className: styles.btn
748
+ }, /*#__PURE__*/_react["default"].createElement(_default2.VtxMapIcon, {
749
+ type: "icon-doubleleft"
750
+ }))), /*#__PURE__*/_react["default"].createElement("div", {
751
+ className: styles.scrollauto
752
+ }, listMess.map(function (item, index) {
753
+ return /*#__PURE__*/_react["default"].createElement("div", {
754
+ key: index,
755
+ onClick: function onClick() {
756
+ return _this4.chooseAddress(item.id);
757
+ },
758
+ className: "".concat(styles.lists, " ").concat(item.isSelect ? styles.select : '')
759
+ }, item.title);
760
+ }))), /*#__PURE__*/_react["default"].createElement("div", {
761
+ onClick: function onClick() {
762
+ return _this4.showOrhidden(true);
763
+ },
764
+ className: "".concat(styles.btn, " ").concat(!isShowList ? styles.show : styles.hidden)
765
+ }, /*#__PURE__*/_react["default"].createElement(_default2.VtxMapIcon, {
766
+ type: "icon-doubleright"
767
+ }))), /*#__PURE__*/_react["default"].createElement("div", {
768
+ className: styles.content_right
769
+ }, /*#__PURE__*/_react["default"].createElement(_VtxMap.VtxMap, _extends({
770
+ getMapInstance: function getMapInstance(map) {
771
+ if (map) _this4.map = map;
772
+ },
773
+ mapType: mapType,
774
+ mapStyle: mapStyle,
775
+ mapServer: mapServer,
776
+ wkid: wkid,
777
+ mapId: t.mapId,
778
+ setCenter: setCenter,
779
+ mapCenter: mapCenter,
780
+ minZoom: minZoom,
781
+ maxZoom: maxZoom,
782
+ mapZoomLevel: mapZoomLevel,
783
+ setZoomLevel: setZoomLevel,
784
+ mapPoints: mapPoints,
785
+ mapLines: mapLines,
786
+ mapPolygons: mapPolygons,
787
+ mapCircles: mapCircles,
788
+ mapVisiblePoints: mapVisiblePoints,
789
+ setVisiblePoints: setVisiblePoints,
790
+ isDoEdit: isDoEdit,
791
+ isEndEdit: isEndEdit,
792
+ editGraphicId: editGraphicId,
793
+ editGraphicChange: function editGraphicChange() {},
794
+ clickGraphic: this.clickGraphic.bind(this),
795
+ clickMap: function clickMap() {
796
+ t.isClickMap = true;
797
+ },
798
+ olProps: olProps
799
+ }, drawProps))))));
800
+ }
801
+ }, {
802
+ key: "initSearchMap",
803
+ value: function initSearchMap() {
804
+ var _this5 = this;
805
+
806
+ if (this.props.modal1Visible
807
+ /*&& !this.state.locationPoint[0]*/
808
+ ) {
809
+ if (this.map) {
810
+ this.map.loadMapComplete.then(function () {
811
+ if (!_this5.mapLoaded) {
812
+ _this5.mapLoaded = true;
813
+
814
+ _this5.drawLocationPoint();
819
815
  }
820
- t.isDrawStatus = nextProps.graphicType !== 'point' && !nextProps.editParam;
821
- this.setState({
822
- modal1Visible: nextProps.modal1Visible,
823
- maxZoom: nextProps.maxZoom,
824
- minZoom: nextProps.minZoom,
825
- wkid: nextProps.wkid,
826
- mapCenter: nextProps.mapCenter || '',
827
- mapType: nextProps.mapType || 'bmap',
828
- mapServer: nextProps.mapServer,
829
- graphicType: nextProps.graphicType || 'point',
830
- isDraw: nextProps.graphicType !== 'point' && !nextProps.editParam,
831
- isCloseDraw: !(nextProps.graphicType !== 'point' && !nextProps.editParam),
832
- editGraphicId: ''
833
- }, function () {
834
- t.setState({
835
- isCloseDraw: false
836
- });
837
- t.initSearchMap();
838
- });
839
- setTimeout(function () {
840
- //实现2+次进入时,清理数据
841
- if (nextProps.modal1Visible) {
842
- _this6.clearList();
843
- _this6.setState({
844
- setZoomLevel: true
845
- }, function () {
846
- _this6.setState({
847
- setZoomLevel: false
848
- });
849
- });
850
- if (!!_this6.map && !!_this6.state.locationPoint[0] && nextProps.mapCenter && !!nextProps.mapCenter[0]) {
851
- if (_this6.map.getGraphic('locationPoint')) {
852
- switch (nextProps.mapType) {
853
- case 'bmap':
854
- _this6.map.getGraphic('locationPoint').mapLayer.setPosition(new BMap.Point(nextProps.mapCenter[0], nextProps.mapCenter[1]));
855
- break;
856
- case 'amap':
857
- _this6.map.getGraphic('locationPoint').mapLayer.setPosition(new AMap.LngLat(nextProps.mapCenter[0], nextProps.mapCenter[1]));
858
- break;
859
- case 'tmap':
860
- _this6.map.getGraphic('locationPoint').mapLayer.setLngLat(new T.LngLat(nextProps.mapCenter[0], nextProps.mapCenter[1]));
861
- break;
862
- case 'gmap':
863
- _this6.map.getGraphic('locationPoint').mapLayer.geometry.setLatitude(nextProps.mapCenter[1]);
864
- _this6.map.getGraphic('locationPoint').mapLayer.geometry.setLongitude(nextProps.mapCenter[0]);
865
- _this6.map.state.gis.graphics.refresh();
866
- case 'olMap':
867
- _this6.map.getGraphic('locationPoint').mapLayer.setGeometry(new ol.geom.Point(nextProps.mapCenter));
868
- break;
869
- }
870
- }
871
- _this6.map.setCenter(nextProps.mapCenter);
872
- }
873
- }
874
- }, 100);
816
+ });
875
817
  }
876
- }, {
877
- key: 'componentWillUnmount',
878
- value: function componentWillUnmount() {
879
- //关闭moveTo定时
880
- var t = this;
881
- if (t.loadExtent) {
882
- clearInterval(t.loadExtent);
818
+ }
819
+ }
820
+ }, {
821
+ key: "componentDidMount",
822
+ value: function componentDidMount() {
823
+ //绘制定位点(以当前的中心点位参照=>初始化好后才有ref可以获取中心点)
824
+ this.initSearchMap();
825
+ }
826
+ }, {
827
+ key: "componentDidUpdate",
828
+ value: function componentDidUpdate(prevProps, prevState) {
829
+ //重新渲染结束
830
+ this.initSearchMap();
831
+ }
832
+ }, {
833
+ key: "componentWillReceiveProps",
834
+ value: function componentWillReceiveProps(nextProps) {
835
+ var _this6 = this;
836
+
837
+ var t = this;
838
+ this.isClickMap = false;
839
+
840
+ if (t.state.graphicType !== nextProps.graphicType && !!this.map) {
841
+ this.map.clearAll();
842
+ t.mapLoaded = false;
843
+ t.isinit = true;
844
+ }
845
+
846
+ if (nextProps.editParam) {
847
+ t.mapLoaded = false;
848
+ }
849
+
850
+ t.isDrawStatus = nextProps.graphicType !== 'point' && !nextProps.editParam;
851
+ this.setState({
852
+ modal1Visible: nextProps.modal1Visible,
853
+ maxZoom: nextProps.maxZoom,
854
+ minZoom: nextProps.minZoom,
855
+ wkid: nextProps.wkid,
856
+ mapCenter: nextProps.mapCenter || '',
857
+ mapType: nextProps.mapType || 'bmap',
858
+ mapStyle: nextProps.mapStyle,
859
+ mapServer: nextProps.mapServer,
860
+ graphicType: nextProps.graphicType || 'point',
861
+ isDraw: nextProps.graphicType !== 'point' && !nextProps.editParam,
862
+ isCloseDraw: !(nextProps.graphicType !== 'point' && !nextProps.editParam),
863
+ editGraphicId: ''
864
+ }, function () {
865
+ t.setState({
866
+ isCloseDraw: false
867
+ });
868
+ t.initSearchMap();
869
+ });
870
+ setTimeout(function () {
871
+ //实现2+次进入时,清理数据
872
+ if (nextProps.modal1Visible) {
873
+ _this6.clearList();
874
+
875
+ _this6.setState({
876
+ setZoomLevel: true
877
+ }, function () {
878
+ _this6.setState({
879
+ setZoomLevel: false
880
+ });
881
+ });
882
+
883
+ if (!!_this6.map && !!_this6.state.locationPoint[0] && nextProps.mapCenter && !!nextProps.mapCenter[0]) {
884
+ if (_this6.map.getGraphic('locationPoint')) {
885
+ switch (nextProps.mapType) {
886
+ case 'bmap':
887
+ _this6.map.getGraphic('locationPoint').mapLayer.setPosition(new BMap.Point(nextProps.mapCenter[0], nextProps.mapCenter[1]));
888
+
889
+ break;
890
+
891
+ case 'amap':
892
+ _this6.map.getGraphic('locationPoint').mapLayer.setPosition(new AMap.LngLat(nextProps.mapCenter[0], nextProps.mapCenter[1]));
893
+
894
+ break;
895
+
896
+ case 'tmap':
897
+ _this6.map.getGraphic('locationPoint').mapLayer.setLngLat(new T.LngLat(nextProps.mapCenter[0], nextProps.mapCenter[1]));
898
+
899
+ break;
900
+
901
+ case 'gmap':
902
+ _this6.map.getGraphic('locationPoint').mapLayer.geometry.setLatitude(nextProps.mapCenter[1]);
903
+
904
+ _this6.map.getGraphic('locationPoint').mapLayer.geometry.setLongitude(nextProps.mapCenter[0]);
905
+
906
+ _this6.map.state.gis.graphics.refresh();
907
+
908
+ case 'olMap':
909
+ _this6.map.getGraphic('locationPoint').mapLayer.setGeometry(new ol.geom.Point(nextProps.mapCenter));
910
+
911
+ break;
912
+ }
883
913
  }
914
+
915
+ _this6.map.setCenter(nextProps.mapCenter);
916
+ }
884
917
  }
885
- }]);
918
+ }, 100);
919
+ }
920
+ }, {
921
+ key: "componentWillUnmount",
922
+ value: function componentWillUnmount() {
923
+ //关闭moveTo定时
924
+ var t = this;
925
+
926
+ if (t.loadExtent) {
927
+ clearInterval(t.loadExtent);
928
+ }
929
+ }
930
+ }]);
886
931
 
887
- return VtxSearchMap;
888
- }(_react2.default.Component);
932
+ return VtxSearchMap;
933
+ }(_react["default"].Component);
889
934
 
890
- exports.default = VtxSearchMap;
891
- module.exports = exports['default'];
935
+ var _default = VtxSearchMap;
936
+ exports["default"] = _default;
937
+ module.exports = exports["default"];
938
+ //# sourceMappingURL=VtxSearchMap.js.map